# wp-self-test: hooks and filters

Read from wp-self-test at v2.2.5.

## Browser layer

Example (mmwp_self_test_admin_menu_exclusions):

```php
add_filter( 'mmwp_self_test_admin_menu_exclusions', function ( $needles ) {
    // Change $needles here.
    return $needles;
} );
```

### mmwp_self_test_admin_menu_exclusions

Filter, since 2.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_admin_menu_exclusions

Filter the substrings that keep an admin URL out of the browser crawl (matched case-insensitively). Return the defaults plus your own, or remove defaults you accept to crawl.

| Name | Type | Description |
| --- | --- | --- |
| $needles | string[] | Default: DEFAULT_EXCLUSIONS. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Browser/Menu_Inventory.php#L125

### mmwp_self_test_browser_command

Filter, since 2.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_browser_command

Filter the command that starts the Node runner of the browser layer.

| Name | Type | Description |
| --- | --- | --- |
| $command | string[] | Default: `node <package>/e2e/bin/run.js`. |
| $package | string | Directory of the installed e2e package. |
| $definition | array | Case definition. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Browser/Browser_Runner.php#L118

## Gates and configuration

Example (mmwp_self_test_abilities_available):

```php
add_filter( 'mmwp_self_test_abilities_available', function ( $available ) {
    // Change $available here.
    return $available;
} );
```

### mmwp_self_test_abilities_available

Filter, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_abilities_available

Filter whether the Abilities API is usable for self-tests; a host plugin that gates its own abilities can report that here.

| Name | Type | Description |
| --- | --- | --- |
| $available | bool | Default: `function_exists('wp_get_ability')`. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Config.php#L143

### mmwp_self_test_asset_url

Filter, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_asset_url

Filter the URL of a package asset.

| Name | Type | Description |
| --- | --- | --- |
| $url | string | Resolved URL. |
| $relative | string | Path relative to the package root. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Config.php#L172

### mmwp_self_test_capability

Filter, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_capability

Filter the capability required to run the self-tests.

| Name | Type | Description |
| --- | --- | --- |
| $capability | string | Default 'manage_options'. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Config.php#L39

### mmwp_self_test_shim_enabled

Filter, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_shim_enabled

Filter whether the WP_CLI shim is defined on web requests.

| Name | Type | Description |
| --- | --- | --- |
| $enabled | bool | Default: the dashboard is enabled. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Config.php#L123

### mmwp_self_test_ui_enabled

Filter, since 0.6.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_ui_enabled

Filter whether the self-test dashboard (and its REST routes) are registered.

| Name | Type | Description |
| --- | --- | --- |
| $enabled | bool | Default: true unless the environment is `production`. |
| $environment | string | `WP_ENV` or `wp_get_environment_type()`. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Config.php#L103

## Lifecycle

Example (mmwp_self_test_enabled):

```php
add_filter( 'mmwp_self_test_enabled', function ( $enabled, $environment ) {
    // Change $enabled here.
    return $enabled;
}, 10, 2 );
```

### mmwp_self_test_booted

Action, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_booted

Fires once the self-test package has booted.

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

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Loader.php#L128

### mmwp_self_test_enabled

Filter, since 0.7.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_enabled

Filter whether the self-test package boots on this request (surfaces, manifests, dashboard, commands and abilities).

| Name | Type | Description |
| --- | --- | --- |
| $enabled | bool | Default: true unless the environment is `production`. |
| $environment | string | `WP_ENV` or `wp_get_environment_type()`. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Loader.php#L168

### mmwp_self_test_manifest

Filter, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_manifest

Filter one parsed manifest before its cases are built.

| Name | Type | Description |
| --- | --- | --- |
| $manifest | array | Parsed manifest (`version`, `cases`). |
| $path | string | Manifest file path. |
| $plugin | string | Owning plugin slug. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Manifest.php#L96

### mmwp_self_test_register

Action, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_register

Register self-test manifests.

| Name | Type | Description |
| --- | --- | --- |
| $registry | Registry | Call `$registry->register($slug, $manifest_path, $opts)`. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Self_Test.php#L125

## Surfaces and runs

Example (mmwp_self_test_ability_definitions):

```php
add_filter( 'mmwp_self_test_ability_definitions', function ( $definitions ) {
    // Change $definitions here.
    return $definitions;
} );
```

### mmwp_self_test_ability_definitions

Filter, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_ability_definitions

Filter the self-test ability definitions before registration.

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

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Surfaces/Abilities.php#L77

### mmwp_self_test_completed

Action, since 0.1.0. Anchor: https://mammothwp.com/docs/wp-self-test/hooks/#mmwp_self_test_completed

Fires after a self-test run completed.

| Name | Type | Description |
| --- | --- | --- |
| $report | array | The report that was stored. |

Source: https://github.com/mammothwp/wp-self-test/blob/v2.2.5/src/Runner.php#L194
