This plugin is for developers. The aim is to simplify/speed up the process of working with feature flags.
- Adds an admin UI where users can enable/disable features for testing in a live environment.
- Can enforce flags once you are happy for them to be deployed (allows for staged removal in source).
- Google Analytics A/B testing support
- User roles support
- Add "Screen Options" tab to admin screen
- Allow users to enable features for all users
Due to the nature of this plugin requiring theme changes, it is a good idea to add the following to the your theme to catch any errors that may occur if the feature-flags plugin is disabled for any reason.
if ( ! function_exists( 'is_enabled' ) ) {
function is_enabled() {
return false;
}
}
register_feature_flag( $args );
When registering a flag it is a good idea to wrap them in a function exists block to avoid any errors if the plugin is disabled for any reason. In your templates you can then check the feature status using:
if ( function_exists( 'register_feature_flag' ) ) {
register_feature_flag([
'title' => 'My awesome new feature',
'key' => 'correct-horse-battery-staple',
'enforced' => false,
'description' => 'An example feature definition'
]);
}
is_enabled( 'feature-key' );
Replace feature-key
with the key used in the register function to check if it is enabled.
Example
if ( is_enabled( 'correct-horse-battery-staple' ) ) {
/* Flagged feature */
}
key - string
The unique key used in the template to check if a feature is enabled.
title - string
The human readable feature name.
enforced (optional) - boolean
- Default: false
Setting this to true will override any user specific settings and will enforce the flag to be true for every user. Useful for deploying a flag before removing it from the codebase.
description (optional) - string
- Default: ''
A description displayed in the admin screen. Use to tell users what they are enabling and other information.
This project uses the WordPress VIP coding standards.