Action on post publish

If your aim is to trigger code when a post is published, as in, the post_status of the post is set to publish, then you can hook into save_post like this: function cc_publish_wpse_263985( $postid ) { // check if post status is ‘publish’ if ( get_post_status( $postid ) == ‘publish’) ) { // do something … Read more

Can the Akismet API key be pulled from the plugin?

After reading several articles, discussing with the community, diving through the Akismet documentation and reviewing their plugin I’ve found if you want test to see if the plugin is active or deactivate you can use: if (function_exists(‘akismet_verify_key’)) : echo “true”; else : echo “false”; endif; After activating the plugin and entering the API key in … Read more

Is using register_activation_hook required?

You don’t have to use the register_activation_hook or register_deactivation_hook hook, they are optional. As their name suggests, they are hooks planned to run a task on plugin’s activation/deactivation, such as updating the status of all users for some purpose. So, if your plugin doesn’t require such tasks, then simply don’t use them. If you want … Read more

Correct way to use register_activation_hook

This quotation from The Codex clearly states what does this function do: The register_activation_hook function registers a plugin function to be run when the plugin is activated. This means, this function works similar as a class’s __construct() method. You can use it to set initial options, update database, and more. It doesn’t run every time … Read more