45 | | wp_publish_post( $changeset_post->ID ); |
| 45 | /* |
| 46 | * Note that an Ajax request spawns here instead of just calling `wp_publish_post( $changeset_post->ID )`. |
| 47 | * |
| 48 | * Because WP_Customize_Manager is not instantiated for customize.php with the `settings_previewed=false` |
| 49 | * argument, settings cannot be reliably saved. Some logic short-circuits if the current value is the |
| 50 | * same as the value being saved. This is particularly true for options via `update_option()`. |
| 51 | * |
| 52 | * By opening an Ajax request, this is avoided and the changeset is published. See #39221. |
| 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 | |