diff --git src/wp-admin/customize.php src/wp-admin/customize.php
index 7f9e5a9dc7..de236dbcb2 100644
|
|
|
if ( $wp_customize->changeset_post_id() ) { |
| 42 | 42 | get_post_time( 'G', true, $changeset_post ) < time() |
| 43 | 43 | ); |
| 44 | 44 | if ( $missed_schedule ) { |
| 45 | | wp_publish_post( $changeset_post->ID ); |
| | 45 | /* |
| | 46 | * Note that an Ajax request spawned here instead of just calling `wp_publish_post( $changeset_post->ID )`. |
| | 47 | * The reason for this is that WP_Customize_Manager is not instantiated for customize.php with |
| | 48 | * the `settings_previewed=false` argument. Because of this, settings cannot by reliably saved just |
| | 49 | * since some settings will short-circuit if they detect that the current value is the same as |
| | 50 | * the value to be saved. This is particularly true for options due to logic in the update_option() |
| | 51 | * function. For more, See #39221. So by opening an Ajax request, then the changeset will get published |
| | 52 | * where WP_Customize_Manager will not have been instantiated with `settings_previewed=false`. |
| | 53 | */ |
| | 54 | $nonces = $wp_customize->get_nonces(); |
| | 55 | $request_args = array( |
| | 56 | 'nonce' => $nonces['save'], |
| | 57 | 'customize_changeset_uuid' => $wp_customize->changeset_uuid(), |
| | 58 | 'wp_customize' => 'on', |
| | 59 | 'customize_changeset_status' => 'publish', |
| | 60 | ); |
| | 61 | ob_start(); |
| | 62 | ?> |
| | 63 | <?php wp_print_scripts( array( 'wp-util' ) ); ?> |
| | 64 | <script> |
| | 65 | wp.ajax.post( 'customize_save', <?php echo wp_json_encode( $request_args ); ?> ); |
| | 66 | </script> |
| | 67 | <?php |
| | 68 | $script = ob_get_clean(); |
| | 69 | |
| 46 | 70 | wp_die( |
| 47 | 71 | '<h1>' . __( 'Your scheduled changes just published' ) . '</h1>' . |
| 48 | | '<p><a href="' . esc_url( remove_query_arg( 'changeset_uuid' ) ) . '">' . __( 'Customize New Changes' ) . '</a></p>', |
| | 72 | '<p><a href="' . esc_url( remove_query_arg( 'changeset_uuid' ) ) . '">' . __( 'Customize New Changes' ) . '</a></p>' . $script, |
| 49 | 73 | 200 |
| 50 | 74 | ); |
| 51 | 75 | } |