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

Public posts – preventing duplicate form submissions

Don’t know if it’s best practice but i had a similar issue and I ended up checking by custom sql query to check if the title already exists in my post type and filtered duplicate posts and i hooked that to wp_insert_post_data filter hook. add_filter(‘wp_insert_post_data’,’prevente_duplicates’); function prevente_duplicates($data,$postarr){ $count = $wpdb->get_results($wpdb->prepare(“SELECT count(id) FROM $wpdb->posts WHERE post_type=”MY_POST_TYPE_NAME” … Read more

Nonce keeps failing

Why are you using the edit.php page for this export link? The edit.php code appears to be checking on the “bulk-posts” nonce, which is probably where your failure is, since you’re not using that nonce. You should probably be using post.php instead, or a more general hook with your action.

Several nonces?

No, there isn’t any point in that. All docs relating to metaboxes are probably inspired from the wrong code at the codex which use a nonce. The problem which nonces in metabox inadvertently solve is avoiding data corruption when the quick edit feature of the posts list page is used (or thinking about it any … Read more

Stop WordPress nonces expiring

A nonce is a “number used once” to help protect URLs and forms from certain types of misuse, malicious or otherwise. WordPress nonces aren’t numbers, but are a hash made up of numbers and letters. Nor are they used only once, but have a limited “lifetime” after which they expire. During that time period the … Read more

phpcs error in WordPress

Yes it is correct. Escaping should be done based on context, and since wp_nonce_url() is used in an hrefas proper url, you should use esc_url.

Verify a nonce in Form submission

Problem is, you are submitting data as POST data, but verifying nonce from GET data. Here is how you can create a nonce field in a form easily: wp_nonce_field( ‘add_new_addres’ ); Actually, I personally don’t use more than 1 parameter when calling the wp_nonce_field function. Then when verify use the following code: if ( ! … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)