From 69692d50cb6a0a49ed4b68a3f466c393d90eb225 Mon Sep 17 00:00:00 2001 From: joedolson Date: Sun, 25 Jun 2023 15:20:22 +0000 Subject: [PATCH] Quick/Bulk Edit: Don't set publish date when editing drafts. Ensure that quick edit does not define a publish date if the post status is one of 'draft', 'pending', or 'auto-draft'. Props uxtremist, SergeyBiryukov, Denis-de-Bernardy, jane, rfischmann, mista-flo, rutviksavsani, oglekler, joedolson. Fixes #19907. Built from https://develop.svn.wordpress.org/trunk@56022 git-svn-id: http://core.svn.wordpress.org/trunk@55534 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/post.php | 4 ++++ wp-admin/js/inline-edit-post.js | 7 +++++++ wp-admin/js/inline-edit-post.min.js | 2 +- wp-includes/version.php | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 70f792f5f1..4036b2bbce 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -169,6 +169,10 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { } } + if ( isset( $post_data['edit_date'] ) && 'false' === $post_data['edit_date'] ) { + $post_data['edit_date'] = false; + } + if ( ! empty( $post_data['edit_date'] ) ) { $aa = $post_data['aa']; $mm = $post_data['mm']; diff --git a/wp-admin/js/inline-edit-post.js b/wp-admin/js/inline-edit-post.js index e7d4496b88..db06072c4a 100644 --- a/wp-admin/js/inline-edit-post.js +++ b/wp-admin/js/inline-edit-post.js @@ -449,6 +449,13 @@ window.wp = window.wp || {}; }; fields = $('#edit-'+id).find(':input').serialize(); + + var status = $(':input[name="_status"]').val(); + + if ( [ 'draft', 'pending', 'auto-draft' ].includes( status ) ) { + params.edit_date = 'false'; + } + params = fields + '&' + $.param(params); // Make Ajax request. diff --git a/wp-admin/js/inline-edit-post.min.js b/wp-admin/js/inline-edit-post.min.js index 6956f57cd8..173d601e44 100644 --- a/wp-admin/js/inline-edit-post.min.js +++ b/wp-admin/js/inline-edit-post.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -window.wp=window.wp||{},function(u,h){window.inlineEditPost={init:function(){var i=this,t=u("#inline-edit"),e=u("#bulk-edit");i.type=u("table.widefat").hasClass("pages")?"page":"post",i.what="#post-",t.on("keyup",function(t){if(27===t.which)return inlineEditPost.revert()}),e.on("keyup",function(t){if(27===t.which)return inlineEditPost.revert()}),u(".cancel",t).on("click",function(){return inlineEditPost.revert()}),u(".save",t).on("click",function(){return inlineEditPost.save(this)}),u("td",t).on("keydown",function(t){if(13===t.which&&!u(t.target).hasClass("cancel"))return inlineEditPost.save(this)}),u(".cancel",e).on("click",function(){return inlineEditPost.revert()}),u('#inline-edit .inline-edit-private input[value="private"]').on("click",function(){var t=u("input.inline-edit-password-input");u(this).prop("checked")?t.val("").prop("disabled",!0):t.prop("disabled",!1)}),u("#the-list").on("click",".editinline",function(){u(this).attr("aria-expanded","true"),inlineEditPost.edit(this)}),u("#bulk-edit").find("fieldset:first").after(u("#inline-edit fieldset.inline-edit-categories").clone()).siblings("fieldset:last").prepend(u("#inline-edit .inline-edit-tags-wrap").clone()),u('select[name="_status"] option[value="future"]',e).remove(),u("#doaction").on("click",function(t){var e;i.whichBulkButtonId=u(this).attr("id"),e=i.whichBulkButtonId.substr(2),"edit"===u('select[name="'+e+'"]').val()?(t.preventDefault(),i.setBulk()):0