Prepare auto updates
This commit is contained in:
@@ -115,13 +115,16 @@ function update( WP_REST_Request $request ) {
|
||||
|
||||
// Create preview post link.
|
||||
// Equivalent of this on WordPress block editor can be seen at WP_REST_Autosaves_Controller->prepare_item_for_response().
|
||||
$preview_url = get_preview_post_link(
|
||||
$post_id,
|
||||
[
|
||||
'preview_id' => $post_id,
|
||||
'preview_nonce' => wp_create_nonce( 'post_preview_' . $post_id ),
|
||||
]
|
||||
);
|
||||
$preview_query_args = [
|
||||
'preview_id' => $post_id,
|
||||
'preview_nonce' => wp_create_nonce( 'post_preview_' . $post_id ),
|
||||
];
|
||||
|
||||
if ( ET_BUILDER_LAYOUT_POST_TYPE === get_post_type( $post_id ) ) {
|
||||
$preview_query_args['p'] = $post_id;
|
||||
}
|
||||
|
||||
$preview_url = get_preview_post_link( $post_id, $preview_query_args );
|
||||
|
||||
return self::response_success(
|
||||
[
|
||||
@@ -192,11 +195,13 @@ function update( WP_REST_Request $request ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Persist main post content/meta only for singular VB saves.
|
||||
// On non-singular pages (home/archive), request post_id may be the first
|
||||
// main-query loop post and must not be converted to Divi (#49679).
|
||||
// Persist main post content/meta only for singular VB saves, plus builder-enabled WooCommerce shop pages
|
||||
// that hydrate post content while keeping `mainLoopType` as `post_type_archive` (#52168).
|
||||
// On other non-singular pages (home/archive), request post_id may be the first main-query loop post
|
||||
// and must not be converted to Divi (#49679).
|
||||
$main_post = get_post( $post_id );
|
||||
$should_persist_main_post = $main_post instanceof \WP_Post && 'singular' === $main_loop_type;
|
||||
$should_persist_main_post = $main_post instanceof \WP_Post
|
||||
&& self::_should_persist_main_post_content( $post_id, $main_loop_type );
|
||||
|
||||
if (
|
||||
$should_persist_main_post
|
||||
|
||||
Reference in New Issue
Block a user