wp-kit: hooks and filters
3 actions and 3 filters, read from the source of wp-kit at v2.0.3. Each hook links to the line that fires it.
Execution path (Operation::run())
Example: mmwp_kit_operation_capability
add_filter( 'mmwp_kit_operation_capability', function ( $resolved, $op, $input, $ctx ) {
// Change $resolved here.
return $resolved;
}, 10, 4 );
Action
Since 0.1.0
Fires before an operation's service method runs.
Parameters of mmwp_kit_operation_before_run | Name | Type | Description |
$op | Operation | Operation. |
$input | array | Normalised input. |
$ctx | Context | Invocation context. |
Fired in src/Operation.php#L529↗(opens in a new tab) (Operation::run()).
Filter
Since 0.1.0
Filter the capability required by an operation.
Parameters of mmwp_kit_operation_capability | Name | Type | Description |
$resolved | bool|string | Capability string, true (public) or false (denied). |
$op | Operation | Operation being authorised. |
$input | array | Normalised input. |
$ctx | Context | Invocation context. |
Fired in src/Capability.php#L51↗(opens in a new tab) (Capability::resolve()).
Filter
Since 0.1.0
Filter an operation's result before it reaches the surface adapter.
Parameters of mmwp_kit_operation_result | Name | Type | Description |
$result | mixed | Result or WP_Error. |
$op | Operation | Operation. |
$input | array | Normalised input. |
$ctx | Context | Invocation context. |
Fired in src/Operation.php#L549↗(opens in a new tab) (Operation::run()).
Lifecycle
Example: mmwp_kit_booted
add_action( 'mmwp_kit_booted', function ( $path, $version ) {
// Your code.
}, 10, 2 );
Action
Since 0.1.0
Fires once the kit has chosen a copy and installed its autoloader.
Parameters of mmwp_kit_booted | Name | Type | Description |
$path | string | Directory of the booted copy. |
$version | string | Version of the booted copy. |
Fired in src/Kit.php#L141↗(opens in a new tab) (Kit::boot()).
Action
Since 0.1.0
Fires once every resource has been declared.
Parameters of mmwp_kit_registry_ready | Name | Type | Description |
$registry | Registry | The registry. |
Fired in src/Registry.php#L92↗(opens in a new tab) (Registry::ready()).
Surfaces
Example: mmwp_kit_ability_definitions
add_filter( 'mmwp_kit_ability_definitions', function ( $definitions, $resource ) {
// Change $definitions here.
return $definitions;
}, 10, 2 );
Filter
Since 0.1.0
Filter the ability definitions of one resource before registration.
Parameters of mmwp_kit_ability_definitions | Name | Type | Description |
$definitions | array<string,array> | Definitions keyed by ability name. |
$resource | Resource | Owning resource. |
Fired in src/Adapters/Ability_Adapter.php#L105↗(opens in a new tab) (Ability_Adapter::register_abilities()).