PHP code example of jamesrwilliams / wp-feature-flags

1. Go to this page and download the library: Download jamesrwilliams/wp-feature-flags library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jamesrwilliams / wp-feature-flags example snippets


if ( ! function_exists( 'flagpole_flag_enabled' ) ) {
	function flagpole_flag_enabled() {
		return false;
	}
}

if ( function_exists( 'flagpole_register_flag' ) ) {
	flagpole_register_flag([
		'title'       => 'My awesome new feature',
		'key'         => 'correct-horse-battery-staple',
		'enforced'    => false,
		'label'       => 'All',
		'description' => 'An example feature definition',
		'stable'      => false,
	]);
}

if ( flagpole_flag_enabled( 'flag_key' ) ) {
	/* flag_key is enabled! */
}

flagpole_register_flag([
	'title'       => 'Feature ready for publication',
	'key'         => 'super-awesome-navigation-change',
	'stable'      => true,
]);

flagpole_register_flag([
	'title'       => 'An enforced flag',
	'key'         => 'enforced-flag',
	'enforced'    => true,
]);

// Single Key
echo do_shortcode('[debugFlagpole_flags]');

// Multiple keys
echo do_shortcode('[debugFlagpole_flags flag="key-1,key-2,key-3"]');

echo do_shortcode('[debugFlagpole_flags enforced="true"]');

echo do_shortcode('[debugFlagpole_groups]');

echo do_shortcode('[debugFlagpole_db]');