Ensure that draft posts cannot be given a non-unique post slug when using Quick Edit.

fixes #22902. props SergeyBiryukov.

git-svn-id: http://core.svn.wordpress.org/trunk@24206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Mark Jaquith 2013-05-08 21:26:17 +00:00
parent cbec9880a7
commit 5ee1a961a4
2 changed files with 8 additions and 3 deletions

View File

@ -1352,6 +1352,12 @@ function wp_ajax_inline_save() {
if ( empty($data['ping_status']) ) if ( empty($data['ping_status']) )
$data['ping_status'] = 'closed'; $data['ping_status'] = 'closed';
// Hack: wp_unique_post_slug() doesn't work for drafts, so we will fake that our post is published.
if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ) ) ) {
$post['post_status'] = 'publish';
$data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] );
}
// update the post // update the post
edit_post(); edit_post();

View File

@ -995,8 +995,7 @@ function get_sample_permalink($id, $title = null, $name = null) {
$original_date = $post->post_date; $original_date = $post->post_date;
$original_name = $post->post_name; $original_name = $post->post_name;
// Hack: get_permalink would return ugly permalink for // Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published.
// drafts, so we will fake, that our post is published
if ( in_array( $post->post_status, array( 'draft', 'pending' ) ) ) { if ( in_array( $post->post_status, array( 'draft', 'pending' ) ) ) {
$post->post_status = 'publish'; $post->post_status = 'publish';
$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);