Adding nonce to <script> tag
问题 I'm wondering how to add nonce to my all <script> tags on page based on WordPress. For example please find some code below: $my_nonce = wp_create_nonce('nonce-'.rand()); $nonces = "Content-Security-Policy: script-src 'self nonce-".$my_nonce."'"; header( "{$nonces}"); wp_localize_script( 'my_loadmore', 'my_loadmore_params', array( 'ajaxurl' => site_url() . '\/wp-admin\/admin-ajax.php', 'posts' => json_encode( $wp_query->query_vars ), 'current_page' => get_query_var( 'paged' ) ? get_query_var(