mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-10 07:34:34 +00:00
All duplicate slugs across different post types.
Adds unit test. Props mboynes, nacin. Fixes #18962. git-svn-id: https://develop.svn.wordpress.org/trunk@30158 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3673,7 +3673,6 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
||||
if ( ! is_array( $feeds ) )
|
||||
$feeds = array();
|
||||
|
||||
$hierarchical_post_types = get_post_types( array('hierarchical' => true) );
|
||||
if ( 'attachment' == $post_type ) {
|
||||
// Attachment slugs must be unique across all types.
|
||||
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
|
||||
@@ -3696,7 +3695,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
||||
} while ( $post_name_check );
|
||||
$slug = $alt_post_name;
|
||||
}
|
||||
} elseif ( in_array( $post_type, $hierarchical_post_types ) ) {
|
||||
} elseif ( is_post_type_hierarchical( $post_type ) ) {
|
||||
if ( 'nav_menu_item' == $post_type )
|
||||
return $slug;
|
||||
|
||||
@@ -3704,8 +3703,8 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
||||
* Page slugs must be unique within their own trees. Pages are in a separate
|
||||
* namespace than posts so page slugs are allowed to overlap post slugs.
|
||||
*/
|
||||
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
|
||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
|
||||
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1";
|
||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
|
||||
|
||||
/**
|
||||
* Filter whether the post slug would make a bad hierarchical post slug.
|
||||
|
||||
Reference in New Issue
Block a user