Make WordPress Core


Ignore:
Timestamp:
11/01/2014 08:36:23 PM (9 years ago)
Author:
wonderboymusic
Message:

All duplicate slugs across different post types.

Adds unit test.

Props mboynes, nacin.
Fixes #18962.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r30155 r30158  
    36743674        $feeds = array();
    36753675
    3676     $hierarchical_post_types = get_post_types( array('hierarchical' => true) );
    36773676    if ( 'attachment' == $post_type ) {
    36783677        // Attachment slugs must be unique across all types.
     
    36973696            $slug = $alt_post_name;
    36983697        }
    3699     } elseif ( in_array( $post_type, $hierarchical_post_types ) ) {
     3698    } elseif ( is_post_type_hierarchical( $post_type ) ) {
    37003699        if ( 'nav_menu_item' == $post_type )
    37013700            return $slug;
     
    37053704         * namespace than posts so page slugs are allowed to overlap post slugs.
    37063705         */
    3707         $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";
    3708         $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
     3706        $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";
     3707        $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
    37093708
    37103709        /**
Note: See TracChangeset for help on using the changeset viewer.