| | 323 | * Retrieve the name of a filter currently being processed. |
| | 324 | * |
| | 325 | * The function current_filter() only returns the most recent filter |
| | 326 | * or action being executed. did_action() returns true once the action |
| | 327 | * is initially processed. This function allows detection for any filter |
| | 328 | * currently being executed (despite not being the most recent filter to |
| | 329 | * fire, in the case of hooks called from hook callbacks) to be verified. |
| | 330 | * |
| | 331 | * @since 3.2.0 |
| | 332 | * @see current_filter() |
| | 333 | * @see did_action() |
| | 334 | * |
| | 335 | * @param $filter string Optional. Filter to check. Defaults to null, |
| | 336 | * which checks if any filter is currently being run. |
| | 337 | * @return bool Whether the filter is currently in the stack |
| | 338 | */ |
| | 339 | function doing_filter( $filter = null ) { |
| | 340 | global $wp_current_filter; |
| | 341 | if ( null === $filter ) |
| | 342 | return empty( $wp_current_filter ); |
| | 343 | return in_array( $filter, $wp_current_filter ); |
| | 344 | } |
| | 345 | |
| | 346 | /** |
| | 347 | * Retrieve the name of an action currently being processed. |
| | 348 | * |
| | 349 | * @since 3.2.0 |
| | 350 | * @uses doing_filter() |
| | 351 | * |
| | 352 | * @param $action string Optional. Action to check. Defaults to null, |
| | 353 | * which checks if any action is currently being run. |
| | 354 | * @return bool Whether the action is currently in the stack |
| | 355 | */ |
| | 356 | function doing_action( $action = null ) { |
| | 357 | return doing_filter( $action ); |
| | 358 | } |
| | 359 | |
| | 360 | /** |