mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Customize: Reuse existing non-auto-draft posts and existing auto-draft posts in the customized state with matching slugs when applying starter content.
* Updates `wp_unique_post_slug()` to ignore `auto-draft` posts. Prevents publishing multiple posts that have the same slugs from starter content. * Fixes fatal error when attempting to save an header_image setting from a non-admin context. * Fixes substituting attachment symbols in options and theme mods. * Fixes applying starter content for header images and background images. See #38114. Fixes #38928. git-svn-id: https://develop.svn.wordpress.org/trunk@39411 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3673,7 +3673,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
||||
|
||||
if ( 'attachment' == $post_type ) {
|
||||
// Attachment slugs must be unique across all types.
|
||||
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
|
||||
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_status != 'auto-draft' AND post_name = %s AND ID != %d LIMIT 1";
|
||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
|
||||
|
||||
/**
|
||||
@@ -3701,7 +3701,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
||||
* 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 ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1";
|
||||
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_status != 'auto-draft' AND post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1";
|
||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
|
||||
|
||||
/**
|
||||
@@ -3725,7 +3725,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
||||
}
|
||||
} else {
|
||||
// Post slugs must be unique across all posts.
|
||||
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
|
||||
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_status != 'auto-draft' AND post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
|
||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
|
||||
|
||||
// Prevent new post slugs that could result in URLs that conflict with date archives.
|
||||
|
||||
Reference in New Issue
Block a user