wp_block_theme_activate_nonce()WP 6.3.0

Set a JavaScript constant for theme activation.

Sets the JavaScript global WP_BLOCK_THEME_ACTIVATE_NONCE containing the nonce required to activate a theme. For use within the site editor.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Returns

null. Nothing (null).

Usage

wp_block_theme_activate_nonce();

Notes

Changelog

Since 6.3.0 Introduced.

wp_block_theme_activate_nonce() code WP 6.9

<?php
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_json_encode( wp_create_nonce( $nonce_handle ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>;
	</script>
	<?php
}