# wp-kit: hooks and filters

Read from wp-kit at v2.0.3.

## Execution path (Operation::run())

Example (mmwp_kit_operation_capability):

```php
add_filter( 'mmwp_kit_operation_capability', function ( $resolved, $op, $input, $ctx ) {
    // Change $resolved here.
    return $resolved;
}, 10, 4 );
```

### mmwp_kit_operation_before_run

Action, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-kit/hooks/#mmwp_kit_operation_before_run

Fires before an operation's service method runs.

| Name | Type | Description |
| --- | --- | --- |
| $op | Operation | Operation. |
| $input | array | Normalised input. |
| $ctx | Context | Invocation context. |

Source: https://github.com/mammothwp/wp-kit/blob/v2.0.3/src/Operation.php#L529

### mmwp_kit_operation_capability

Filter, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-kit/hooks/#mmwp_kit_operation_capability

Filter the capability required by an operation.

| 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. |

Source: https://github.com/mammothwp/wp-kit/blob/v2.0.3/src/Capability.php#L51

### mmwp_kit_operation_result

Filter, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-kit/hooks/#mmwp_kit_operation_result

Filter an operation's result before it reaches the surface adapter.

| Name | Type | Description |
| --- | --- | --- |
| $result | mixed | Result or WP_Error. |
| $op | Operation | Operation. |
| $input | array | Normalised input. |
| $ctx | Context | Invocation context. |

Source: https://github.com/mammothwp/wp-kit/blob/v2.0.3/src/Operation.php#L549

## Lifecycle

Example (mmwp_kit_booted):

```php
add_action( 'mmwp_kit_booted', function ( $path, $version ) {
    // Your code.
}, 10, 2 );
```

### mmwp_kit_booted

Action, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-kit/hooks/#mmwp_kit_booted

Fires once the kit has chosen a copy and installed its autoloader.

| Name | Type | Description |
| --- | --- | --- |
| $path | string | Directory of the booted copy. |
| $version | string | Version of the booted copy. |

Source: https://github.com/mammothwp/wp-kit/blob/v2.0.3/src/Kit.php#L141

### mmwp_kit_registry_ready

Action, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-kit/hooks/#mmwp_kit_registry_ready

Fires once every resource has been declared.

| Name | Type | Description |
| --- | --- | --- |
| $registry | Registry | The registry. |

Source: https://github.com/mammothwp/wp-kit/blob/v2.0.3/src/Registry.php#L92

## Surfaces

Example (mmwp_kit_ability_definitions):

```php
add_filter( 'mmwp_kit_ability_definitions', function ( $definitions, $resource ) {
    // Change $definitions here.
    return $definitions;
}, 10, 2 );
```

### mmwp_kit_ability_definitions

Filter, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-kit/hooks/#mmwp_kit_ability_definitions

Filter the ability definitions of one resource before registration.

| Name | Type | Description |
| --- | --- | --- |
| $definitions | array<string,array> | Definitions keyed by ability name. |
| $resource | Resource | Owning resource. |

Source: https://github.com/mammothwp/wp-kit/blob/v2.0.3/src/Adapters/Ability_Adapter.php#L105
