wp_pre_execute_ability
Filters whether to short-circuit ability execution.
Returning a value other than the received default bypasses the rest of execute() — input normalization, input validation, permission checks, the registered execute callback, output validation, and the surrounding actions — and the value is returned to the caller as-is. Useful for cached responses, rate limiting, maintenance mode, and test mocking.
To continue with normal execution, return $pre unchanged. This preserves any value (including null, false, or arbitrary objects) as a valid short-circuit result.
Because validation is bypassed, callers that short-circuit are responsible for the integrity of any value they consume from $input.
Использование
add_filter( 'wp_pre_execute_ability', 'wp_kama_pre_execute_ability_filter', 10, 4 );
/**
* Function for `wp_pre_execute_ability` filter-hook.
*
* @param mixed $pre The pre-computed result. Return this value unchanged to continue execution.
* @param string $ability_name The name of the ability.
* @param mixed $input The raw input passed to `execute()`.
* @param WP_Ability $ability The ability instance.
*
* @return mixed
*/
function wp_kama_pre_execute_ability_filter( $pre, $ability_name, $input, $ability ){
// filter...
return $pre;
}
- $pre(разное)
- The pre-computed result. Return this value unchanged to continue execution.
По умолчанию:WP_Filter_Sentinelinstance unique to this invocation - $ability_name(строка)
- The name of the ability.
- $input(разное)
- The raw input passed to
execute(). - $ability(WP_Ability)
- The ability instance.
Список изменений
| С версии 7.1.0 | Введена. |
Где вызывается хук
wp-includes/abilities-api/class-wp-ability.php 809
$pre = apply_filters( 'wp_pre_execute_ability', $pre_execute_sentinel, $this->name, $input, $this );