General: Escape nonce used for block theme activation.

Add `wp_json_encode()` as an escaping function when setting the `WP_BLOCK_THEME_ACTIVATE_NONCE` global on the block theme preview screen.

This account for custom nonce implementations making use of special characters that require escaping in JavaScript strings.

Props antonvlasenko, ramonopoly.
Fixes #58712.


Built from https://develop.svn.wordpress.org/trunk@56218


git-svn-id: http://core.svn.wordpress.org/trunk@55730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2023-07-12 05:21:23 +00:00
parent 4e70f57a0b
commit fd1dfbc113
2 changed files with 2 additions and 2 deletions

View File

@ -70,7 +70,7 @@ function wp_block_theme_activate_nonce() {
$nonce_handle = 'switch-theme_' . wp_get_theme_preview_path();
?>
<script type="text/javascript">
window.WP_BLOCK_THEME_ACTIVATE_NONCE = '<?php echo wp_create_nonce( $nonce_handle ); ?>';
window.WP_BLOCK_THEME_ACTIVATE_NONCE = <?php echo wp_json_encode( wp_create_nonce( $nonce_handle ) ); ?>;
</script>
<?php
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-beta4-56217';
$wp_version = '6.3-beta4-56218';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.