foo
This commit is contained in:
12
code-snippets/client_webapp/generate_nonce.php
Normal file
12
code-snippets/client_webapp/generate_nonce.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' );
|
||||
function my_enqueue_scripts() {
|
||||
if (!is_user_logged_in()) {
|
||||
return;
|
||||
}
|
||||
// Register custom variables for the AJAX script.
|
||||
wp_localize_script( 'script', 'myScriptVars', [
|
||||
'root' => esc_url_raw( rest_url() ),
|
||||
'nonce' => wp_create_nonce( 'wp_rest' ),
|
||||
] );
|
||||
}
|
||||
Reference in New Issue
Block a user