PHPackages                             alleyinteractive/wp-experimental-features - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alleyinteractive/wp-experimental-features

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

alleyinteractive/wp-experimental-features
=========================================

WP Experimental Features

v1.3.2(1y ago)1024.2k↑21.1%[1 PRs](https://github.com/alleyinteractive/wp-experimental-features/pulls)GPL-2.0-or-laterPHPCI passing

Since Oct 23Pushed 5mo ago30 watchersCompare

[ Source](https://github.com/alleyinteractive/wp-experimental-features)[ Packagist](https://packagist.org/packages/alleyinteractive/wp-experimental-features)[ Docs](https://github.com/alleyinteractive/wp-experimental-features)[ RSS](/packages/alleyinteractive-wp-experimental-features/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (8)Used By (0)

Experimental Features
=====================

[](#experimental-features)

A WordPress plugin that creates a feature flags system for beta testing experimental features in your themes or plugins.

Usage
-----

[](#usage)

### Defining Feature Flags

[](#defining-feature-flags)

Feature flags are defined using a filter:

```
/**
 * Define available feature flags.
 *
 * @param array $flags Feature flags that have been defined for the Experimental Features plugin.
 *
 * @return array The modified list of feature flags.
 */
function filter_experimental_features_flags( $flags ): array {
	$flags['my-cool-feature'] = __( 'My Cool Feature', 'my-textdomain' );

	return $flags;
}
add_filter(
	'experimental_features_flags',
	__NAMESPACE__ . '\filter_experimental_features_flags'
);
```

### Checking the Value of Feature Flags

[](#checking-the-value-of-feature-flags)

The value of a feature flag can be checked by running the feature flag slug through the `experimental_features_flag` filter. This allows for plugins and themes to not break if the Experimental Features plugin is deactivated, because the filter will simply return the default value.

```
$is_enabled = apply_filters(
	'experimental_features_flag',
	false,
	'my-cool-feature'
);
```

If the flag is not enabled, or if the Experimental Features plugin is not active, then the default value (first parameter, `false` in the example above) will be returned.

If you like, you could create a helper function for this in your plugin or theme:

```
/**
 * A helper function for determining if a feature flag is enabled.
 *
 * @param string $slug The feature flag slug to check.
 *
 * @return bool True if enabled, false if not.
 */
function my_theme_flag_enabled( string $slug ): bool {
	return (bool) apply_filters(
		'experimental_features_flag',
		false,
		$slug
	);
}
```

### Toggling Feature Flags in the Admin

[](#toggling-feature-flags-in-the-admin)

If you navigate to Settings &gt; Experimental Features while logged in to the WordPress admin as an administrator (or a user with the `manage_options`capability) you can turn feature flags on and off via a simple checkbox interface.

### Toggling Feature Flags in the Admin Bar

[](#toggling-feature-flags-in-the-admin-bar)

By default the admin bar will include links to toggle all available feature flags individually. This can be turned off using a filter:

```
add_action( 'experimental_features_show_admin_bar', '__return_false' )
```

[![Screen Shot 2021-07-08 at 4 55 08 PM](https://user-images.githubusercontent.com/346399/124989614-4b73a980-e00d-11eb-9e67-e1d4e46f4778.png)](https://user-images.githubusercontent.com/346399/124989614-4b73a980-e00d-11eb-9e67-e1d4e46f4778.png)

### Listening for Flag Changes

[](#listening-for-flag-changes)

WordPress actions are fired when flags are enabled/disabled.

#### On Any Flag Update

[](#on-any-flag-update)

```
add_action(
	'experimental_features_flags_updated',
	function( $enabled, $disabled ) {
		// ...
	},
	10,
	2,
);
```

#### When a Specific Flag is Enabled

[](#when-a-specific-flag-is-enabled)

```
add_action( 'experimental_features_flag_enabled_{feature-flag}', function() { ... } );
```

#### When a Specific Flag is Disabled

[](#when-a-specific-flag-is-disabled)

```
add_action( 'experimental_features_flag_disabled_{feature-flag}', function() { ... } );
```

### Retrieving Feature Flag Status in the REST API.

[](#retrieving-feature-flag-status-in-the-rest-api)

The status of feature flags can be retrieved via the REST API. The endpoint `/wp-json/experimental-features/v1/features` will return a JSON object with the status of all feature flags on the site.

```
{
	"my-cool-feature": {
		"label": "My Cool Feature",
		"status": false
	}
}
```

**By default, this is disabled.** To enable it, use the following filter:

```
add_filter( 'experimental_features_rest_api_enabled', '__return_true' );
```

The default permissions for accessing the REST API endpoint would be for all users. To restrict access you can filter the permissions callback to retrieve it to your needs:

```
add_filter(
	'experimental_features_rest_permission_callback',
	function () {
		return current_user_can( 'manage_options' );
	},
);
```

All feature flags will appear on the endpoint by default. This can be filtered using the `experimental_features_rest_api_flags` filter:

```
add_filter(
	'experimental_features_rest_api_flags',
	function ( $flags ) {
		return array_filter(
			$flags,
			 function ( $flag ) {
				// Only return the 'my-cool-feature' flag.
				return 'my-cool-feature' === $flag;
			},
			ARRAY_FILTER_USE_KEY
		);
	}
);
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

This project is actively maintained by [Alley Interactive](https://github.com/alleyinteractive).

- [All Contributors](../../contributors)

License
-------

[](#license)

The GNU General Public License (GPL) license. Please see [License File](LICENSE) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance55

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~272 days

Total

5

Last Release

579d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/338d27065b1074f2d66d049d742f22996dd137eef6f91bc8f75350ceee1e8ef2?d=identicon)[srtfisher](/maintainers/srtfisher)

![](https://www.gravatar.com/avatar/d2679da8ee30c4d7eae16ffd2271484027b3b27be6d7fb8202d5e4c6d210881d?d=identicon)[alleyinteractive](/maintainers/alleyinteractive)

---

Top Contributors

[![srtfisher](https://avatars.githubusercontent.com/u/346399?v=4)](https://github.com/srtfisher "srtfisher (49 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![kevinfodness](https://avatars.githubusercontent.com/u/2650828?v=4)](https://github.com/kevinfodness "kevinfodness (16 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![anubisthejackle](https://avatars.githubusercontent.com/u/1724534?v=4)](https://github.com/anubisthejackle "anubisthejackle (3 commits)")[![jomurgel](https://avatars.githubusercontent.com/u/5230729?v=4)](https://github.com/jomurgel "jomurgel (2 commits)")[![alleyinteractive-ops](https://avatars.githubusercontent.com/u/2197915?v=4)](https://github.com/alleyinteractive-ops "alleyinteractive-ops (1 commits)")

---

Tags

wordpresswordpress-plugin

### Embed Badge

![Health badge](/badges/alleyinteractive-wp-experimental-features/health.svg)

```
[![Health](https://phpackages.com/badges/alleyinteractive-wp-experimental-features/health.svg)](https://phpackages.com/packages/alleyinteractive-wp-experimental-features)
```

###  Alternatives

[atakde/discord-webhook-php

discord webhook php

186.5k](/packages/atakde-discord-webhook-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
