What SQL / WordPress queries would need a nonce?

You might be a little confused as to the purpose and function of nonces in WordPress. Recommended reading: WordPress Nonces An Introduction to WordPress Nonces with Examples Protect_Queries_Against_SQL_Injection_Attacks A nonce is a “number used once” to help protect URLs and forms from certain types of misuse, malicious or otherwise. Nonces help you ensure, somewhat, the … Read more

Why am I getting a 403 from check_admin_referer()?

In the JS script, include the nonce in data, as in the following example: jQuery(document).ready(function($){ data = { action: ‘hello’, token: $( ‘#token’ ).val() } $(‘#stupid_form’).submit(function(){ $.post(ajaxurl, data, function(response){ $(‘#response’).html(response); }); return false; }); }); Additional Note <?php wp_nonce_field(‘hello’, ‘token’); ?> generates a hidden input with a markup similar to: <input type=”hidden” id=”token” name=”token” value=”d9e3867a0e” … Read more

my theme breaks WP export

The basic idea for debug here is that theme apparently influences something it totally should not. Either something is done in a wrong way or in a wrong place. Check that theme is not running any functionality directly in functions.php. Check that all of theme’s functionality runs on appropriate hooks. For hooks that are used … Read more

Why save_post_$(custom_post_type) is fired even if I am not already saving a post?

When you choose “Your CPT > Add New”, WP calls get_default_post_to_edit(), which actually creates an “empty” post (with ‘post_status’ => ‘auto-draft’) and then calls wp_insert_post(). This is what is causing your save_datasheet_meta() function to be called before you think it should. Hence, generally you should add some additional sanity checks to the beginning of any … Read more

When must I use and verify nonce?

Nonces should be used to verify intent of the user, especially on destructive actions. Imagine there is a link user can click to delete a post. User can do it, so when they click is a post gets deleted. Now imagine someone else tricks user into clicking this link (look at this cat pic!). User … Read more

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