wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



apply_filters_ref_array › WordPress Function

Seit3.0.0
Veraltetn/v
apply_filters_ref_array ( $hook_name, $args )
Parameter: (2)
  • (string) $hook_name The name of the filter hook.
    Erforderlich: Ja
  • (array) $args The arguments supplied to the functions hooked to `$hook_name`.
    Erforderlich: Ja
Siehe:
Gibt zurück:
  • (mixed) The filtered value after all hooked functions are applied to it.
Definiert in:
Codex:

Calls the callback functions that have been added to a filter hook, specifying arguments in an array.



Quellcode

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

	if ( ! isset( $wp_filters[ $hook_name ] ) ) {
		$wp_filters[ $hook_name ] = 1;
	} else {
		++$wp_filters[ $hook_name ];
	}

	// 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;
}