I have a question regarding WordPress, specifically version 3.0 and newer.
Does anyone know how to get an array or list of all the functions that will be applied or are ‘registered’ to the_content filter?
The idea is to generate a checkbox list of possible functions to remove from the filter, such as wpautop. I know how to remove functions from the filter with hard coded labels, but I am hoping to create a more dynamic solution.
If anyone has any ideas if this is possible and how it could be done I would be very interested. Thanks.
Simple function to print from the filter array?
Call it where you need it.
This is a bit more advanced example, that will, in addition to data from
$wp_filter
array, show the path of the file where the hook is attached, as well as the line in code where the function is defined.To get a basic list of functions hooked on a specific action ( or filter ) it is enough to fetch the items from the filter array, but since the functions can be attached in various ways ( as a class method or closure ) that list will contain a ton of irelevant data that includes objects presented as string. This example will display only the relevant data, in order of priority:
'function_name'
array( $object, 'function_name' )
array( 'class_name', 'function_name' )
and'class_name::function_name'
function() {}
array( 'class_name', 'parent::function_name' )
Since hooks can be added and removed throughout the entire runtime, the output depends on at what point the function is called (
wp_footer
action is a good place to get the complete list )print_r
example forthe_content
filter:Edit: 2017-05-05
WP_Hook
classBased on the same idea of
print_filters_for
, an extended function for those who need not only print but return as well:Output:
Get and output: