Changeset 11125
- Timestamp:
- 04/29/2009 07:04:27 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r11109 r11125 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)); 1713 1714 if ($post_name_check || in_array($slug, $wp_rewrite->feeds) ) { 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 ( '" . implode("', '", $wpdb->escape($hierarchical_post_types)) . "' ) AND ID != %d AND post_parent = %d LIMIT 1"; 1715 $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID, $post_parent)); 1716 } else { 1717 $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"; 1718 $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID, $post_parent)); 1719 } 1720 1721 if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) { 1715 1722 $suffix = 2; 1716 1723 do { 1717 1724 $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));1725 $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID, $post_parent)); 1719 1726 $suffix++; 1720 1727 } while ($post_name_check);
Note: See TracChangeset
for help on using the changeset viewer.