diff options
author | Weston Ruter <westonruter@git.wordpress.org> | 2016-10-30 20:20:54 +0000 |
---|---|---|
committer | Weston Ruter <westonruter@git.wordpress.org> | 2016-10-30 20:20:54 +0000 |
commit | 4de2e30bb4527ff29d4b55e39eaa2ba5dd4f64e5 (patch) | |
tree | 659c3589148041c597d834121f0affd0d710373b /src/wp-includes/class-wp-customize-manager.php | |
parent | 32c7696700acc740b28d8b91d8711f6a37345ecd (diff) | |
download | wordpress-4de2e30bb4527ff29d4b55e39eaa2ba5dd4f64e5.tar.gz wordpress-4de2e30bb4527ff29d4b55e39eaa2ba5dd4f64e5.zip |
Customize: Prevent auto-draft post/page stubs from being saved with empty slugs or published with non-unique slugs.
* Allow `WP_Customize_Nav_Menus::insert_auto_draft_post()` to take full post array to pass to `wp_insert_post()`, except for `post_status`. Require `post_title`.
* Ensure empty `post_name` gets explicitly set to slugified `post_title`.
* Explicitly allow only `post_type` and `post_title` params in `WP_Customize_Nav_Menus::ajax_insert_auto_draft_post()`.
* Use `wp_update_post()` instead of `wp_publish_post()` to ensure unique slugs are assigned to published auto-draft posts.
* Re-use `WP_Customize_Nav_Menus::insert_auto_draft_post()` when inserting stubs from starter content.
See #38114, #38013, #34923.
Fixes #38539.
git-svn-id: https://develop.svn.wordpress.org/trunk@39038 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src/wp-includes/class-wp-customize-manager.php')
-rw-r--r-- | src/wp-includes/class-wp-customize-manager.php | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 4862de4525..f96a220349 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -959,10 +959,10 @@ final class WP_Customize_Manager { // Posts & pages. if ( ! empty( $posts ) ) { foreach ( array_keys( $posts ) as $post_symbol ) { - $posts[ $post_symbol ]['ID'] = wp_insert_post( wp_slash( array_merge( - $posts[ $post_symbol ], - array( 'post_status' => 'auto-draft' ) - ) ) ); + $r = $this->nav_menus->insert_auto_draft_post( $posts[ $post_symbol ] ); + if ( $r instanceof WP_Post ) { + $posts[ $post_symbol ]['ID'] = $r->ID; + } } $this->set_post_value( 'nav_menus_created_posts', wp_list_pluck( $posts, 'ID' ) ); // This is why nav_menus component is dependency for adding posts. } |