wp-includes/ai-client/class-wp-ai-client-ability-function-resolver.php:25Resolves and executes WordPress Abilities API function calls from AI models.
$allowed_abilitiesarray<string,privateclass WP_AI_Client_Ability_Function_Resolver { /** * Prefix used to identify ability function calls. * * @since 7.0.0 * @var string */ private const ABILITY_PREFIX = 'wpab__'; /** * Map of allowed ability names for this instance. * * Keys are ability name strings, values are `true` for O(1) lookup. * * @since 7.0.0 * @var array<string, true> */ private array $allowed_abilities; /** * Constructor. * * @since 7.0.0 * * @param WP_Ability|string ...$abilities The abilities that this resolver is allowed to execute. */ public function __construct( ...$abilities ) { $this->allowed_abilities = array(); foreach ( $abilities as $ability ) { if ( $ability instanceof WP_Ability ) { $this->allowed_abilities[ $ability->get_name() ] = true; } elseif ( is_string( $ability ) ) { $this->allowed_abilities[ $ability ] = true; } } } /** * Checks if a function call is an ability call. * * @since 7.0.0 * * @param FunctionCall $call The function call to check. * @return bool True if the function call is an ability call, false otherwise. */ public function is_ability_call( FunctionCall $call ): bool { $name = $call->getName(); if ( null === $name ) { return false; } return str_starts_with( $name, self::ABILITY_PREFIX ); } /** * Executes a WordPress ability from a function call. * * Only abilities that were specified in the constructor are allowed to be * executed. If the ability is not in the allowed list, an error response * with code `ability_not_allowed` is returned. * * @since 7.0.0 * * @param FunctionCall $call The function call to execute. * @return FunctionResponse The response from executing the ability. */ public function execute_ability( FunctionCall $call ): FunctionResponse { $function_name = $call->getName() ?? 'unknown'; $function_id = $call->getId() ?? 'unknown'; if ( ! $this->is_ability_call( $call ) ) { return new FunctionResponse( $function_id, $function_name, array( 'error' => __( 'Not an ability function call' ), 'code' => 'invalid_ability_call', )Introduced in 7.0.0. Unchanged from 7.0.4 through 7.1.0.
Signature, return type and hooks compared across 2 parsed releases.
src/wp-includes/ai-client/class-wp-ai-client-ability-function-resolver.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.