Merged in feature/81-dev-dev01 (pull request #5)
auto-patch 81-dev-dev01-2023-12-05T22_45_26 * auto-patch 81-dev-dev01-2023-12-05T22_45_26
This commit is contained in:
@@ -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.' ) );
|
||||
}
|
||||
|
||||
$post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_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'] ) ) {
|
||||
@@ -1957,11 +1965,12 @@ function wp_create_post_autosave( $post_data ) {
|
||||
* Fires before an autosave is stored.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @since 6.4.0 The `$is_update` parameter was added to indicate if the autosave is being updated or was newly created.
|
||||
*
|
||||
* @param array $new_autosave Post array - the autosave that is about to be saved.
|
||||
* @param bool $is_update Whether this is an existing autosave.
|
||||
*/
|
||||
do_action( 'wp_creating_autosave', $new_autosave );
|
||||
|
||||
do_action( 'wp_creating_autosave', $new_autosave, true );
|
||||
return wp_update_post( $new_autosave );
|
||||
}
|
||||
|
||||
@@ -1969,7 +1978,68 @@ function wp_create_post_autosave( $post_data ) {
|
||||
$post_data = wp_unslash( $post_data );
|
||||
|
||||
// Otherwise create the new autosave as a special post revision.
|
||||
return _wp_put_post_revision( $post_data, true );
|
||||
$revision = _wp_put_post_revision( $post_data, true );
|
||||
|
||||
if ( ! is_wp_error( $revision ) && 0 !== $revision ) {
|
||||
|
||||
/** This action is documented in wp-admin/includes/post.php */
|
||||
do_action( 'wp_creating_autosave', get_post( $revision, ARRAY_A ), false );
|
||||
}
|
||||
|
||||
return $revision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Autosave the revisioned meta fields.
|
||||
*
|
||||
* Iterates through the revisioned meta fields and checks each to see if they are set,
|
||||
* and have a changed value. If so, the meta value is saved and attached to the autosave.
|
||||
*
|
||||
* @since 6.4.0
|
||||
*
|
||||
* @param array $new_autosave The new post data being autosaved.
|
||||
*/
|
||||
function wp_autosave_post_revisioned_meta_fields( $new_autosave ) {
|
||||
/*
|
||||
* The post data arrives as either $_POST['data']['wp_autosave'] or the $_POST
|
||||
* itself. This sets $posted_data to the correct variable.
|
||||
*
|
||||
* Ignoring sanitization to avoid altering meta. Ignoring the nonce check because
|
||||
* this is hooked on inner core hooks where a valid nonce was already checked.
|
||||
*/
|
||||
$posted_data = isset( $_POST['data']['wp_autosave'] ) ? $_POST['data']['wp_autosave'] : $_POST;
|
||||
|
||||
$post_type = get_post_type( $new_autosave['post_parent'] );
|
||||
|
||||
/*
|
||||
* Go thru the revisioned meta keys and save them as part of the autosave, if
|
||||
* the meta key is part of the posted data, the meta value is not blank and
|
||||
* the the meta value has changes from the last autosaved value.
|
||||
*/
|
||||
foreach ( wp_post_revision_meta_keys( $post_type ) as $meta_key ) {
|
||||
|
||||
if (
|
||||
isset( $posted_data[ $meta_key ] ) &&
|
||||
get_post_meta( $new_autosave['ID'], $meta_key, true ) !== wp_unslash( $posted_data[ $meta_key ] )
|
||||
) {
|
||||
/*
|
||||
* Use the underlying delete_metadata() and add_metadata() functions
|
||||
* vs delete_post_meta() and add_post_meta() to make sure we're working
|
||||
* with the actual revision meta.
|
||||
*/
|
||||
delete_metadata( 'post', $new_autosave['ID'], $meta_key );
|
||||
|
||||
/*
|
||||
* One last check to ensure meta value not empty().
|
||||
*/
|
||||
if ( ! empty( $posted_data[ $meta_key ] ) ) {
|
||||
/*
|
||||
* Add the revisions meta data to the autosave.
|
||||
*/
|
||||
add_metadata( 'post', $new_autosave['ID'], $meta_key, $posted_data[ $meta_key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2207,6 +2277,7 @@ function taxonomy_meta_box_sanitize_cb_input( $taxonomy, $terms ) {
|
||||
*
|
||||
* @since 5.0.0
|
||||
* @since 6.3.0 Added `selectors` field.
|
||||
* @since 6.4.0 Added `block_hooks` field.
|
||||
*
|
||||
* @return array An associative array of registered block data.
|
||||
*/
|
||||
@@ -2221,6 +2292,7 @@ function get_block_editor_server_block_settings() {
|
||||
'attributes' => 'attributes',
|
||||
'provides_context' => 'providesContext',
|
||||
'uses_context' => 'usesContext',
|
||||
'block_hooks' => 'blockHooks',
|
||||
'selectors' => 'selectors',
|
||||
'supports' => 'supports',
|
||||
'category' => 'category',
|
||||
|
||||
Reference in New Issue
Block a user