Quick/Bulk Edit: Fix inability to quick edit draft post date.

Follow up to [56022] to fix inability to set a date/time in quick editing. Allow a user to set a quick/edit date while preventing accidental date assignments per the original intent.

Props tristanleboss, ivanzhuck, tibbsa, sabernhardt, sergeybiryukov, oandregal, khokansardar, joedolson, shailu25.
Fixes #59125. See #19907.
Built from https://develop.svn.wordpress.org/trunk@56802


git-svn-id: http://core.svn.wordpress.org/trunk@56314 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2023-10-08 20:10:25 +00:00
parent f99b282ca2
commit 074d2adb95
4 changed files with 15 additions and 14 deletions

View File

@ -171,10 +171,6 @@ 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'];
@ -197,7 +193,19 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
}
/*
* Only assign a post date if the user has explicitly set a new value.
* See #59125 and #19907.
*/
$previous_date = $post_id ? get_post_field( 'post_date', $post_id ) : false;
if ( $previous_date && $previous_date !== $post_data['post_date'] ) {
$post_data['edit_date'] = true;
$post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
} else {
$post_data['edit_date'] = false;
unset( $post_data['post_date'] );
unset( $post_data['post_date_gmt'] );
}
}
if ( isset( $post_data['post_category'] ) ) {

View File

@ -491,13 +491,6 @@ 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.

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.4-beta2-56801';
$wp_version = '6.4-beta2-56802';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.