Download the PHP package jamesrwilliams/wp-feature-flags without Composer

On this page you can find all versions of the php package jamesrwilliams/wp-feature-flags. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-feature-flags

Flagpole

Maintainability GitHub release PRs Welcome Packagist Downloads Known Vulnerabilities

This plugin is for WordPress theme developers who wish to add simple feature flags to their themes. These flags can be enabled via an admin interface, previewed on a per-user, or group basis, and even enabled via a query string for those without accounts. For planned development work please see the roadmap or issues labeled with enhancement.

Contents

  1. Installation
  2. Adding flags to themes
  3. Enabling flags
  4. Flag Groups
  5. Shortcodes
  6. Contributing

Installation

Add this project's source code to your wp-content/plugins directory and enable it like you would any other plugin. It is also available via Packagist to use with composer.

This plugin is currently not available via the WordPress Plugin directory however we are working towards that for v1.0.0.

Required theme changes

As this plugin is closely coupled with your theme code it is a good idea to add the following block to your theme to catch any errors if the Flagpole plugin is disabled for any reason.

Register a flag

To register a flag, simply add the following to your theme's functions.php file using the flagpole_register_flag function:

Wrapping the registration function call in a function_exists helps avoid errors if the plugin is disabled for any reason. You can also pass an array of flags to flagpole_register_flag to easily instantiate multiple flags at once.

Checking the status of a flag

In your templates you can then check the feature status using the flagpole_flag_enabled function in your PHP theme code to toggle features based on the status of your flags:

Replace flag_key with the key used in the flagpole_register_flag function to check if it is enabled.

Flag options/arguments

Parameter Type Default Description
key string - The unique key used in the template to check if a feature is enabled.
title string "" The human readable feature name.
description (optional) string "" A description displayed in the admin screen.
stable (optional) boolean false If true, allows users to publish features from the admin area.
enforced (optional) boolean false Setting this to true will override any user specific settings and will enforce the flag to be enabled for every user. Useful for deploying a flag before removing it from the codebase.
label string All Using labels lets you group together flags that are similar. Adding a label will separate the flag out in the admin UI.

Enabling flags

There are three ways to have a flag enabled with Flagpole. These are:

Previewing

A flag can be previewed for the current logged-in user by enabling the preview in the Flagpole admin screen.

Navigate to the Flagpole screen in the WP admin dashboard, located under Tools > Flagpole. Find a flag you wish to enable, and click the "enable preview" button.

This flag will now be enabled for this user until it is toggled again. Users can preview any number of flags at any one time. For previewing multiple flags at the same time check out Flag Groups.

Publishing

Publishing a flag enables it for every user that visits your site, this includes logged-out users. Any user can publish a feature as long as it has been marked as stable by setting the stable property to true in the flag registration block. This acts as a safety net allowing theme developers to mark features ready for publication.

E.g.

Enforcing

Enforcing a flag is where a developer can force a flag to be in a published state. This allows them to enable a flag via their source code by setting the 'enforced' option to true in the flag options. The idea behind enforced flags are a stepping stone before removing the flag logic from the theme. Enforced flags are displayed in a separate list in the admin area and are not interactive to users in the admin area.

Flag Groups

Flag Groups are a way to manage multiple flags at a time. You can preview Flag Groups like you can a single flag and by using the group URL parameter, and the group key you wish to enable. A private group will require users to login to the site prior to activating the flags for them.

You can either preview a Flag Group by enabling it in the WP Admin as you would for a single flag, or you can use the query string method to enable a group of flags using the following query string format: ?group={groupKey}

Example:

Shortcodes

This plugin adds a number of utility shortcodes to help debug the use of Flagpole flags.

debugFlagpole_flags

The shortcode by default shows all flags that are not enforced found in your theme. You can also specify which flags you're looking to debug specifically using the flag parameter like so with either a single key or a comma separated list:

Basic Usage:

This will display a table of all the non-enforced flags currently found in the active theme, including a status and, if they are enabled, a reason why.

You can specify single or multiple flag for this to output if you don't want to show everything.

Passing the enforced value will display all enforced flags instead of the other flags. E.g:

debugFlagpole_groups

Use the following shortcode to get a debug output for Flag Groups.

debugFlagpole_db

Use the following shortcode to get a debug output for everything!

Contributing

Any PRs and suggestions are very welcome, along with ideas and discussions on issues.


All versions of wp-feature-flags with dependencies

PHP Build Version
Package Version
Requires composer/installers Version ~1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jamesrwilliams/wp-feature-flags contains the following files

Loading the files please wait ....