Ticket #6437: 9437.2.diff
File 9437.2.diff, 1.6 KB (added by , 15 years ago) |
---|
-
wp-includes/post.php
1709 1709 function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) { 1710 1710 global $wpdb, $wp_rewrite; 1711 1711 if ( !in_array( $post_status, array( 'draft', 'pending' ) ) ) { 1712 $post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1", $slug, $post_type, $post_ID, $post_parent)); 1712 if ( $post_type == 'page' ) { 1713 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'attachment') AND ID != %d AND post_parent = %d LIMIT 1"; 1714 } else { 1715 $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"; 1716 } 1717 $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID, $post_parent)); 1713 1718 1714 1719 if ($post_name_check || in_array($slug, $wp_rewrite->feeds) ) { 1715 1720 $suffix = 2; 1716 1721 do { 1717 1722 $alt_post_name = substr($slug, 0, 200-(strlen($suffix)+1)). "-$suffix"; 1718 $post_name_check = $wpdb->get_var($wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1", $alt_post_name, $post_type, $post_ID, $post_parent));1723 $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID, $post_parent)); 1719 1724 $suffix++; 1720 1725 } while ($post_name_check); 1721 1726 $slug = $alt_post_name;