How to check if a hook is hooked or not?

Sure, that’s called has_action, which is an alias of has_filter. Usage: if ( has_action(‘hook_name’) ) { throw new \Exception(‘You cannot hook to a protected action.’); } else { do_action(‘hook_name’); } These two functions access the global array $wp_filter that stores all of the filters / actions

Hooking a function onto the sidebar?

Load at the sidebar bottom In most of the sidebars, you’ll find the call to the wp_meta() action hook, where you can hook into the (mostly bottom) of a sidebar. Load on top of your sidebar The function get_sidebar( $name ) calls the sidebar you want in your template (this allows to have different sidebars). … Read more

How to hook into unregistering a widget instance?

Yes, this can be done. Ultimately, adding and removing a widget to/from a sidebar means updating an option in the database with a call like this: update_option( ‘sidebars_widgets’, array( … ) ) If you look at the code of update_option you see that there is a filter called just before the actual update. So if … Read more

The hook for the AJAX Add to Cart button?

Digging through the code, it’s pretty straight-forward to find. First, look at the template used for product archives – /templates/archive-product.php. Among other things, it sets up the regular queries and begins building the markup of the page. But when it actually starts looping through each product, it delegates the work to /templates/loop-shop.php. This template is … Read more

Is there a WordPress core & plugins update action hook?

Hooks The hooks you’re searching for are ‘pre_set_site_transient_update_plugins’ and ‘upgrader_post_install’ The later takes three arguments. Example: function upgrader_post_install_cb( $true, $hook_extra, $result ) and should be used for: Move & activate the plugin, echo the update message. Moving plugins Moving works like this: $wp_filesystem->move( $result[‘destination’] ,’your_destination_path’ ); Then use activate_plugin( ‘path/file’ ); after moving.

How to Debug the ‘save_post’ Action?

Your code works just fine on my end. So, I’d say your problem is elsewhere. Troubleshooting guide. You can use standard debugging or FirePHP. I also use the following for cases where FirePHP doesn’t display information, i.e., save_post. function my_log( $msg, $title=”” ) { $error_dir=”/Applications/MAMP/logs/php_error.log”; $date = date( ‘d.m.Y h:i:s’ ); $msg = print_r( $msg, … Read more

Hooks for trashing, deleting, saving, restoring custom post type

Two action hooks run when a post is trashed wp_trash_post before the post is trashed and trashed_post afterwards. These run for any post type including attachments. See wp-includes/post.php If you want to limit your function to a specific post type you need to run a check in you callback function. function my_trash_action( $post_id ) { … Read more