W3cubDocs

/WordPress

apply_filters_ref_array( string $tag, array $args )

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

Description

See also

  • apply_filters(): This function is identical, but the arguments passed to the functions hooked to $tag are supplied using an array.

Parameters

$tag

(string) (Required) The name of the filter hook.

$args

(array) (Required) The arguments supplied to the functions hooked to $tag.

Return

(mixed) The filtered value after all hooked functions are applied to it.

Source

File: wp-includes/plugin.php

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

	// Do 'all' actions first
	if ( isset( $wp_filter['all'] ) ) {
		$wp_current_filter[] = $tag;
		$all_args            = func_get_args();
		_wp_call_all_hook( $all_args );
	}

	if ( ! isset( $wp_filter[ $tag ] ) ) {
		if ( isset( $wp_filter['all'] ) ) {
			array_pop( $wp_current_filter );
		}
		return $args[0];
	}

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

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

	array_pop( $wp_current_filter );

	return $filtered;
}

Changelog

Version Description
3.0.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/apply_filters_ref_array