Download the PHP package alleyinteractive/wp-experimental-features without Composer
On this page you can find all versions of the php package alleyinteractive/wp-experimental-features. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alleyinteractive/wp-experimental-features
More information about alleyinteractive/wp-experimental-features
Files in alleyinteractive/wp-experimental-features
Package wp-experimental-features
Short Description WP Experimental Features
License GPL-2.0-or-later
Homepage https://github.com/alleyinteractive/wp-experimental-features
Informations about the package wp-experimental-features
Experimental Features
A WordPress plugin that creates a feature flags system for beta testing experimental features in your themes or plugins.
Usage
Defining Feature Flags
Feature flags are defined using a filter:
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.
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:
Toggling Feature Flags in the Admin
If you navigate to Settings > 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
By default the admin bar will include links to toggle all available feature flags individually. This can be turned off using a filter:
Listening for Flag Changes
WordPress actions are fired when flags are enabled/disabled.
On Any Flag Update
When a Specific Flag is Enabled
When a Specific Flag is Disabled
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.
By default, this is disabled. To enable it, use the following filter:
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:
All feature flags will appear on the endpoint by default. This can be filtered
using the experimental_features_rest_api_flags
filter:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
This project is actively maintained by Alley Interactive.
- All Contributors
License
The GNU General Public License (GPL) license. Please see License File for more information.