WordPress at a glance

doing_filter() WP 1.0

Retrieve the name of a filter currently being processed.

The function current_filter() only returns the most recent filter or action being executed. did_action() returns true once the action is initially processed.

This function allows detection for any filter currently being executed (despite not being the most recent filter to fire, in the case of hooks called from hook callbacks) to be verified.

Возвращает

true/false. Whether the filter is currently in the stack.

Использование

doing_filter( $filter );
$filter(null/string)
Filter to check.
Default: null, which checks if any filter is currently being run

Заметки

  • See: current_filter()
  • See: did_action()
  • Global. Array. $wp_current_filter Current filter.

Changelog

Since 3.9.0 Introduced.

Код doing_filter() WP 5.5.1

<?php
function doing_filter( $filter = null ) {
	global $wp_current_filter;

	if ( null === $filter ) {
		return ! empty( $wp_current_filter );
	}

	return in_array( $filter, $wp_current_filter, true );
}

From tag: Filters (hooks)

More from category: Hooks (actions, filters)

No comments
    Log In . Register