Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
Last active September 15, 2022 21:52
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save damiencarbery/cbd402dbb469728e95306f239ff505e5 to your computer and use it in GitHub Desktop.
Save damiencarbery/cbd402dbb469728e95306f239ff505e5 to your computer and use it in GitHub Desktop.
Use $wp_filter global to view functions attached to actions and filters
<?php
/*
Plugin Name: wp_filter functions
Plugin URI: http://www.damiencarbery.com/2017/06/list-functions-attached-to-an-action/
Description: List functions attached to all actions and filters. DON'T DO IT!
Author: Damien Carbery
Version: 0.1
*/
add_action( 'wp_head', 'wp_filter_the_wrong_way' );
function wp_filter_the_wrong_way() {
global $wp_filter;
// Do NOT do this - it will render many MB of content.
echo '<!-- ', var_export( $wp_filter, true ), ' -->';
}
<?php
/*
Plugin Name: genesis_entry_content functions
Plugin URI: http://www.damiencarbery.com/2017/06/list-functions-attached-to-an-action/
Description: List functions attached to genesis_entry_content.
Author: Damien Carbery
Version: 0.1
*/
add_action( 'wp_head', 'wp_filter_for_one_action' );
function wp_filter_for_one_action() {
global $wp_filter;
echo '<!-- ', var_export( $wp_filter[ 'genesis_entry_content' ], true ), ' -->';
}
<!-- WP_Hook::__set_state(array(
'callbacks' =>
array (
8 =>
array (
'genesis_do_post_image' =>
array (
'function' => 'genesis_do_post_image',
'accepted_args' => 1,
),
),
10 =>
array (
'genesis_do_post_content' =>
array (
'function' => 'genesis_do_post_content',
'accepted_args' => 1,
),
),
12 =>
array (
'genesis_do_post_content_nav' =>
array (
'function' => 'genesis_do_post_content_nav',
'accepted_args' => 1,
),
),
14 =>
array (
'genesis_do_post_permalink' =>
array (
'function' => 'genesis_do_post_permalink',
'accepted_args' => 1,
),
),
20 =>
array (
'bch_add_store_custom_field_info' =>
array (
'function' => 'bch_add_store_custom_field_info',
'accepted_args' => 1,
),
),
),
'iterations' =>
array (
),
'current_priority' =>
array (
),
'nesting_level' => 0,
'doing_action' => false,
)) -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment