wppaste
WordPress

apply_filters( 'wp_pre_execute_ability', mixed $pre, string $ability_name, mixed $input, WP_Ability $ability )

Since
7.1.0
Filters whether to short-circuit ability execution.

Description

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.

Compatibility

WordPress
since 7.1.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 1 of the 5 tracked releases, added in 7.1.0.

Parameters

$premixed
The pre-computed result. Return this value unchanged to continue execution.
Default WP_Filter_Sentinel instance unique to this invocation.
$ability_namestring
The name of the ability.
$inputmixed
The raw input passed to execute().
$abilityWP_Ability
The ability instance.

Where this hook fires · 1

  • wp-includes/abilities-api/class-wp-ability.php:809WP_Ability::execute()

Source code

		 * @param mixed      $pre          The pre-computed result. Return this value unchanged to continue execution.		 *                                 Default `WP_Filter_Sentinel` instance unique to this invocation.		 * @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.		 */		$pre = apply_filters( 'wp_pre_execute_ability', $pre_execute_sentinel, $this->name, $input, $this );		if ( $pre !== $pre_execute_sentinel ) {			return $pre;		} 		$input = $this->normalize_input( $input );		if ( is_wp_error( $input ) ) {

Changelog

Introduced in 7.1.0.

Signature, return type and hooks compared across 1 parsed release.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.