WordPress at Your Fingertips

apply_filters_ref_array() WP 1.0

Execute functions hooked on a specific filter hook, specifying arguments in an array.

No Hooks.


Mixed. The filtered value after all hooked functions are applied to it.


apply_filters_ref_array( $hook_name, $args );
$hook_name(string) (required)
The name of the filter hook.
$args(array) (required)
The arguments supplied to the functions hooked to (hook_name).


  • See: apply_filters() This function is identical, but the arguments passed to the
    functions hooked to (hook_name) supplied using an array.
  • Global. WP_Hook[]. $wp_filter Stores all of the filters and actions.
  • Global. String[]. $wp_current_filter Stores the list of current filters with the current one last.


Since 3.0.0 Introduced.

Code of apply_filters_ref_array() WP 5.8

function apply_filters_ref_array( $hook_name, $args ) {
	global $wp_filter, $wp_current_filter;

	// Do 'all' actions first.
	if ( isset( $wp_filter['all'] ) ) {
		$wp_current_filter[] = $hook_name;
		$all_args            = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
		_wp_call_all_hook( $all_args );

	if ( ! isset( $wp_filter[ $hook_name ] ) ) {
		if ( isset( $wp_filter['all'] ) ) {
			array_pop( $wp_current_filter );

		return $args[0];

	if ( ! isset( $wp_filter['all'] ) ) {
		$wp_current_filter[] = $hook_name;

	$filtered = $wp_filter[ $hook_name ]->apply_filters( $args[0], $args );

	array_pop( $wp_current_filter );

	return $filtered;

From tag: array list help functions (sorting arrays objects)

More from category: Hooks (actions, filters)

No comments
    Log In