Ticket #16843: 16843.3.diff
File 16843.3.diff, 3.0 KB (added by , 12 years ago) |
---|
-
wp-includes/post.php
3099 3099 if ( 'attachment' == $post_type ) { 3100 3100 // Attachment slugs must be unique across all types. 3101 3101 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1"; 3102 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) ); 3102 $post_name_check = in_array( $slug, $feeds ) 3103 || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) 3104 || $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) ); 3103 3105 3104 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug )) {3106 if ( $post_name_check ) { 3105 3107 $suffix = 2; 3106 3108 do { 3107 3109 $alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; … … 3116 3118 // Page slugs must be unique within their own trees. Pages are in a separate 3117 3119 // namespace than posts so page slugs are allowed to overlap post slugs. 3118 3120 $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"; 3119 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) ); 3121 $post_name_check = in_array( $slug, $feeds ) 3122 || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) 3123 || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) 3124 || $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) ); 3120 3125 3121 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 )) {3126 if ( $post_name_check ) { 3122 3127 $suffix = 2; 3123 3128 do { 3124 3129 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; … … 3130 3135 } else { 3131 3136 // Post slugs must be unique across all posts. 3132 3137 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; 3133 $post_ name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ));3138 $post_type_obj = get_post_type_object( $post_type ); 3134 3139 3135 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 3140 $post_name_check = in_array( $slug, $feeds ) 3141 || ( $post_type_obj->has_archive && $wp_rewrite->pagination_base == $slug ) 3142 || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) 3143 || $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 3144 3145 if ( $post_name_check ) { 3136 3146 $suffix = 2; 3137 3147 do { 3138 3148 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";