Wordpress: Troubleshooting a hook not loading on an action

154 Views Asked by At

I am extending an existing plugin. The author of said plugin provided an action hook in the main class of their plugin:

public static function instance() {

            if ( ! isset( self::$instance ) && ! (self::$instance instanceof self) ) {
                self::$instance = new self();
                self::$instance->setup_constants();
                self::$instance->actions = array();
                self::$instance->filters = array();

                add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );

                add_action( 'bp_loaded', array( self::$instance, 'bp_include' ) );

                global $ap_classes;
                $ap_classes = array();

                self::$instance->includes();

                self::$instance->ajax_hooks();
                self::$instance->site_include();

                self::$instance->anspress_forms         = new AnsPress_Process_Form();
                self::$instance->anspress_query_filter  = new AnsPress_Query_Filter();
                self::$instance->anspress_cpt           = new AnsPress_PostTypes();
                self::$instance->anspress_reputation    = new AP_Reputation();

                /*
                 * ACTION: anspress_loaded
                 * Hooks for extension to load their codes after AnsPress is leaded
                 */
                do_action( 'anspress_loaded' );

                self::$instance->setup_hooks();
            }

            return self::$instance;
        }

I am trying to use this hook to run my code, but it isn't working. I'm using has_action() to try and see if it is running of this action hook, but it's not.

if(has_action('anspress_loaded', 'find_do_for_anspress')){
    echo 'fd is hooked';
} else {
    echo 'NOT WORKING CORRECTLY';
}

The code above is at the bottom of the main plugin's php file, outside of any classes. Any idea how to troubleshoot this??

0

There are 0 best solutions below