Plugin index page code executes multiple times

The code in the file itself can be executed multiple times. If you want to do something when the plugin is activated use register_activation_hook and wrap your email sending codes in it. function my_plugin_activation() { //Setting up the credential … } register_activation_hook( __FILE__, ‘my_plugin_activation’ );

Where to use nonce

Well actually, you just need to learn and understand what nonce is and is for, and then you would know when/where/whether you should use it. Excerpt from https://codex.wordpress.org/WordPress_Nonces: WordPress’s security tokens are called “nonces” (despite the above-noted differences from true nonces) because they serve much the same purpose as nonces do. They help protect against … Read more

How to create ShortCode

You need to use hooks to create custom columns and data for a custom post type are manage_{$post_type}posts_columns and manage{$post_type}_posts_custom_column respectively. {$post_type} is the name of the custom post type. I have created common function to add column and and their data. You can use below function to add column and it’s data. function cv_add_column_to_admin_dashboard($column_title, … Read more

How to use nonce

most likely you should not. (ok, “don’t have to” is a better phrasing) nonce in meta box do not add any security as the whole submittion of the form happens only after the form’s nonce is verified. You might need some hidden input to be able to detect when the save filter is called from … Read more