WordPress.org

Make WordPress Core

Ticket #16843: 16843.diff

File 16843.diff, 3.1 KB (added by scribu, 3 years ago)
  • wp-includes/post.php

     
    27772777        if ( 'attachment' == $post_type ) { 
    27782778                // Attachment slugs must be unique across all types. 
    27792779                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1"; 
    2780                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) ); 
    27812780 
    2782                 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) { 
     2781                $post_name_check = in_array( $slug, $feeds ) || 
     2782                        apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) || 
     2783                        $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) ); 
     2784 
     2785                if ( $post_name_check ) { 
    27832786                        $suffix = 2; 
    27842787                        do { 
    27852788                                $alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 
     
    27922795                // Page slugs must be unique within their own trees. Pages are in a separate 
    27932796                // namespace than posts so page slugs are allowed to overlap post slugs. 
    27942797                $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"; 
    2795                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) ); 
    27962798 
    2797                 if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug )  || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) ) { 
     2799                $post_name_check = in_array( $slug, $feeds ) || 
     2800                        preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) || 
     2801                        apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) || 
     2802                        $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) ); 
     2803 
     2804                if ( $post_name_check ) { 
    27982805                        $suffix = 2; 
    27992806                        do { 
    28002807                                $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 
     
    28062813        } else { 
    28072814                // Post slugs must be unique across all posts. 
    28082815                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; 
    2809                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 
    28102816 
    2811                 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 
     2817                $post_type_obj = get_post_type_object( $post_type ); 
     2818 
     2819                $post_name_check = in_array( $slug, $feeds ) || 
     2820                        ( $post_type_obj->has_archive && $wp_rewrite->pagination_base == $slug ) || 
     2821                        apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) || 
     2822                        $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 
     2823 
     2824                if ( $post_name_check ) { 
    28122825                        $suffix = 2; 
    28132826                        do { 
    28142827                                $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 
     
    52365249} 
    52375250add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' ); 
    52385251 
    5239 ?> 
    5240  No newline at end of file 
     5252?>