Skip to content

Proposal: Provide extensibility for individual abilities #39

@gziolo

Description

@gziolo

Filters

It should be possible to allow extenders to modify the behavior of registered abilities. I propose we make the following extensible:

  • input schema – allow modifying the schema of the input passed to the action
  • output schema – allow modifying the schema of the produced output
  • permissions check – allow changing the condition for executing the ability
  • execution result – allow modifying the output result

Example for how to revoke access to the ability:

$filter_cb = static function ( $permission, $ability_name ) {
	if ( 'test/filter-ability' !== $ability_name ) {
		return $permission;
	}

	return false;
};

add_filter( 'ability_permission_result', $filter_cb, 10, 2 );

Actions

It should also be possible to fire action before and after ability execution to allow developers to hook into the ability lifecycle for monitoring, logging, or extending functionality.

Example for how to log the succesful ability execution:

$action_cb = static function ( $ability_name, $input, $result ) {
	if ( 'test/action-ability' !== $ability_name ) {
		return;
	}

	my_plugin_log_ability_result( $ability, $input, $result );
		
};

add_action( 'executed_ability', $action_cb, 10, 3 );

Metadata

Metadata

Assignees

Labels

Projects

Status

In progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions