Avoid queries in wp_unique_post_slug() for nav menu items. see #22189.

git-svn-id: http://core.svn.wordpress.org/trunk@22232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-10-15 14:13:57 +00:00
parent cd250fa7df
commit 2cc408d09c
1 changed files with 2 additions and 0 deletions

View File

@ -2951,6 +2951,8 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
$slug = $alt_post_name;
}
} elseif ( in_array( $post_type, $hierarchical_post_types ) ) {
if ( 'nav_menu_item' == $post_type )
return $slug;
// Page slugs must be unique within their own trees. Pages are in a separate
// namespace than posts so page slugs are allowed to overlap post slugs.
$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";