I don’t think there is, but I was wondering whether anyone ran into this issue before.

Is there a function (or variable) call to get all registered WP Actions and all registered WP Filters?

My current way of doing so would be to have something like this:

static private $wp_actions = array(
    'muplugins_loaded',
    'registered_taxonomy',
    'registered_post_type',
    'plugins_loaded',
    'setup_theme',
    'load_textdomain',
    'after_theme_setup',
    'init',
    'widgets_init',
    'register_sidebar',
    'wp_register_sidebar_widget',
    'wp_default_scripts',
    'wp_default_styles',
    'admin_bar_init',
    'add_admin_bar_menus',
    'wp_loaded',
    'parse_request',
    'send_headers',
    'parse_query',
    'pre_get_posts',
    'wp',
    'template_redirect',
    'get_header',
    'wp_head',
    'wp_enqueue_scripts',
    'wp_print_styles',
    'wp_print_scripts',
    'loop_start',
    'the_post',
    'loop_end',
    'get_sidebar',
    'wp_footer',
    'wp_print_footer_scripts',
    'admin_bar_menu',
    'shutdown'
);

Except that’s undesirable because, what if…WP adds more actions, or deprecates some? I’d feel safer getting an already in-memory solution.

The above list was translated by hand from this link.

EDIT: I’m trying to write a somewhat decent plugin system using classes. Here’s implementation I’m looking for:

abstract class AtlantisPlugin {
    static private $atlantis_actions = array( );
    static private $atlantis_filters = array( 'atlantis_plugin_init' );

    // http://codex.wordpress.org/Plugin_API/Action_Reference
    static private $wp_actions = /* see above */;
    static private $wp_filters = array();

    protected $atlantis;
    private $class;

    public function __construct(Atlantis $atlantis) {
        $this->class = strtolower(get_class($this));

        $this->atlantis =& $atlantis;
        $this->atlantis->registerPlugin($this->class, $this);

        $actions = array_intersect(self::$wp_actions, get_class_methods($this->class));
        foreach($actions as $action) {
            add_action($action, array(&$this, $action), 2);
        }

        $filters = array_intersect(self::$wp_filters, get_class_methods($this->class));
        foreach($filters as $filter) {
            add_filter($filter, array(&$this, $filter), 2);
        }
    }
}

Thanks.

🙂

3 Answers
3

I’d just like to point out that that is, by no means, anywhere NEAR a complete list. According to adambrown.info, there are 595 actions and 970 filters in wordpress 3.3…and that’s just by default, not including hooks added by your plugins.

You might be able to do something with global $wp_actions or global $wp_filters, depending on what you’re trying to do, but those are dynamically generated and only contain the actions done for the page that was loaded (as best I can tell).

Short answer: probably not.

Leave a Reply

Your email address will not be published. Required fields are marked *