wp_block_theme_activate_nonce()

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness. Use https://github.com/WordPress/gutenberg/pull/41836 instead.

Set a JavaScript constant for theme activation.

Description

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

See also

Source

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 ) ); ?>;
	</script>
	<?php
}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.