diff --git a/src/wp-admin/customize.php b/src/wp-admin/customize.php index 7f9e5a9dc7..91c67d0016 100644 --- a/src/wp-admin/customize.php +++ b/src/wp-admin/customize.php @@ -42,10 +42,34 @@ if ( $wp_customize->changeset_post_id() ) { get_post_time( 'G', true, $changeset_post ) < time() ); if ( $missed_schedule ) { - wp_publish_post( $changeset_post->ID ); + /* + * Note that an Ajax request spawns here instead of just calling `wp_publish_post( $changeset_post->ID )`. + * + * Because WP_Customize_Manager is not instantiated for customize.php with the `settings_previewed=false` + * argument, settings cannot be reliably saved. Some logic short-circuits if the current value is the + * same as the value being saved. This is particularly true for options via `update_option()`. + * + * By opening an Ajax request, this is avoided and the changeset is published. See #39221. + */ + $nonces = $wp_customize->get_nonces(); + $request_args = array( + 'nonce' => $nonces['save'], + 'customize_changeset_uuid' => $wp_customize->changeset_uuid(), + 'wp_customize' => 'on', + 'customize_changeset_status' => 'publish', + ); + ob_start(); + ?> + + + ' . __( 'Your scheduled changes just published' ) . '' . - '

' . __( 'Customize New Changes' ) . '

', + '

' . __( 'Customize New Changes' ) . '

' . $script, 200 ); }