Ticket #16843: 16843.diff
File 16843.diff, 3.1 KB (added by , 14 years ago) |
---|
-
wp-includes/post.php
2777 2777 if ( 'attachment' == $post_type ) { 2778 2778 // Attachment slugs must be unique across all types. 2779 2779 $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 ) );2781 2780 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 ) { 2783 2786 $suffix = 2; 2784 2787 do { 2785 2788 $alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; … … 2792 2795 // Page slugs must be unique within their own trees. Pages are in a separate 2793 2796 // namespace than posts so page slugs are allowed to overlap post slugs. 2794 2797 $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 ) );2796 2798 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 ) { 2798 2805 $suffix = 2; 2799 2806 do { 2800 2807 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; … … 2806 2813 } else { 2807 2814 // Post slugs must be unique across all posts. 2808 2815 $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 ) );2810 2816 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 ) { 2812 2825 $suffix = 2; 2813 2826 do { 2814 2827 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; … … 5236 5249 } 5237 5250 add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' ); 5238 5251 5239 ?> 5240 No newline at end of file 5252 ?>