current_filter() – Function | Developer.WordPress.org (original) (raw)

Retrieves the name of the current filter hook.

Return

string Hook name of the current filter.

Source

function current_filter() {
    global $wp_current_filter;

    return end( $wp_current_filter );
}

View all references View on Trac View on GitHub

Used by Description
wp_get_theme_preview_path()wp-includes/theme-previews.php Filters the blog option to return the path for the previewed theme.
_make_clickable_rel_attr()wp-includes/formatting.php Helper function used to build the “rel” attribute for a URL when creating an anchor using make_clickable() .
Language_Pack_Upgrader::bulk_upgrade()wp-admin/includes/class-language-pack-upgrader.php Upgrades several language packs at once.
display_plugins_table()wp-admin/includes/plugin-install.php Displays plugin content based on plugin list.
capital_P_dangit()wp-includes/formatting.php Forever eliminate “Wordpress” from the planet (or at least the little bit we can influence).
get_the_generator()wp-includes/general-template.php Creates the generator XML or Comment for RSS, ATOM, etc.
wp_kses_data()wp-includes/kses.php Sanitize content with allowed HTML KSES rules.
wp_filter_kses()wp-includes/kses.php Sanitize content with allowed HTML KSES rules.
is_main_query()wp-includes/query.php Determines whether the query is the main query.
wp_deregister_script()wp-includes/functions.wp-scripts.php Removes a registered script.
wp_update_plugins()wp-includes/update.php Checks for available updates to plugins based on the latest versions hosted on WordPress.org.
wp_update_themes()wp-includes/update.php Checks for available updates to themes based on the latest versions hosted on WordPress.org.
current_action()wp-includes/plugin.php Retrieves the name of the current action hook.
WP_Customize_Widgets::capture_filter_pre_get_option()wp-includes/class-wp-customize-widgets.php Pre-filters captured option values before retrieving.

Show 9 moreShow less

Changelog

Version Description
2.5.0 Introduced.

User Contributed Notes

  1. Skip to note 3 content
    Get the current filter
function wpdocs_my_filter() {  
    echo current_filter(); // 'the_content'  
}  
add_filter( 'the_content', 'wpdocs_my_filter' );  
  1. Skip to note 4 content
    Get the current action
function wpdocs_my_init_function() {  
    echo current_filter(); // 'init'  
}  
add_action( 'init', 'wpdocs_my_init_function' );