Logout button in menu without “wp” in links

You can use wp_logout_url() function for logout link. It will automatically add nonce to the url. Try this code: add_action(‘template_redirect’, function() { if (empty($_SERVER[‘REQUEST_URI’])) return; $uri = $_SERVER[‘REQUEST_URI’]; if (preg_match(‘#^/log-out/?$#’, $uri, $matches) === 1) { $logout_url = str_replace(‘&’, ‘&’, wp_logout_url()); wp_safe_redirect($logout_url); die; } }); If you do not want to use wp_logout_url(), then try to … Read more

Nonce check causing issues when creating new post

I know that this is not the only tutorial that has code that check nonce for meta boxes but this is truly idiotic. Nonce should be checked per the whole action not per parts of it and if your save_post hook was called it means that the save nonce was already checked and found valid, … Read more

How to insert wp_nonce field within echoed string

You use wp_nonce_field with the fourth parameter set to false. This way you can get the nonce field instead of echoing it: $end_data .= wp_nonce_field( “name-of-action”, “name-for-the-form-field”, true, false ); $end_data .= ‘<input type=”text” class=”ss_title_form_ajax_’ . $this->id . ‘” limit=”133″ value=”‘ . $this->native_title . ‘” size = “60” placeholder=””/>’; $end_data .= ‘<span class=”ss_title_form_ajax_’ . $this->id … Read more

CSP nonces with Cloudflare Workers

Thank you for your answer, you are absolutely right. I also corrected my mistake. I’ll post the code if it helps. Code for Cloudflare Workers: https://gist.github.com/richie5um/b2999177b27095af13ec619e44742116 Code for WordPress : add_filter( ‘script_loader_tag’, ‘add_nonce_to_script’, 10, 3 ); function add_nonce_to_script( $tag, $handle, $source ) { $search = “type=”text/javascript””; $replace = “type=”text/javascript” nonce=”””; $subject = $tag; $output = … Read more

WordPress “nonce” message

I did a quick search in WordPress core files, for patterns like __(.*nonce and _e(.*nonce and didn’t really find any. I also went ahead and did a search on core translation files for the word nonce and didn’t find anything at all, so my guess is that you’re looking at some error message, generated by … Read more