Ticket #6437: 6437.diff
| File 6437.diff, 1.8 KB (added by , 17 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 $hierarchical_post_types = apply_filters('hierarchical_post_types', array('page', 'attachment')); 1713 if ( in_array($post_type, $hierarchical_post_types) ) { 1714 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, " . implode(',', add_magic_quotes($hierarchical_post_types)) . ") AND ID != %d AND post_parent = %d LIMIT 1"; 1715 } else { 1716 $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"; 1717 } 1718 $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID, $post_parent)); 1713 1719 1714 1720 if ($post_name_check || in_array($slug, $wp_rewrite->feeds) ) { 1715 1721 $suffix = 2; 1716 1722 do { 1717 1723 $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));1724 $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID, $post_parent)); 1719 1725 $suffix++; 1720 1726 } while ($post_name_check); 1721 1727 $slug = $alt_post_name;