Finding hooks WordPress

I know there are lists of hooks for WordPress like –> http://adambrown.info/p/wp_hooks/hook

But if I want to find hooks for a plugin like WC Vendors there is a much shorter list of hooks on their website.

Read More

Are ‘do_action’ and ‘apply filter’ functions the only thing we can modify?
If given a class like –> https://github.com/wcvendors/wcvendors/blob/master/classes/admin/class-product-meta.php#L10, is there any way to modify it?

Are we limited to the do_action hooks or is there a way to modify other areas as well? Can we use the WordPress hooks to hook into the WC Vendors plugin as well?

Related posts

1 comment

  1. Mostly you should try to accomplish any task with hooks, but some tasks are just not possible without actually modifying the actual code. But we all know its not good to modify core code, as all changes disappear after an update. So instead of modifying a class, you can extend it. You can override the current features and also add new ones. Extending a class is as easy as using a relavant hook in functions.php and then extending it in the same file or requiring it from another file. Here is an official tutorial on how to add a new shipping method to the woocommerce shipping class.

    Sometimes you dont even need all the hooks, you just need to find the ones that are running on a specific page. For this you can use the code below to list all the current hooks.

    $debug_tags = array();
    add_action( 'all', function ( $tag ) {
        global $debug_tags;
        if ( in_array( $tag, $debug_tags ) ) {
            return;
        }
        echo "<pre>" . $tag . "</pre>";
        $debug_tags[] = $tag;
    } );
    

    Or you can use this plugin “simply show hooks“which is really helpful while development as it gives you an idea of where each hook is being triggered on the page.

Comments are closed.