Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 3.01 KB

feature.md

File metadata and controls

60 lines (47 loc) · 3.01 KB

Feature interface

The Feature interface describes a project feature. Features can be large or small, although smaller features can take advantage of decorators more easily. Use the boot() method to add actions and filters.

Definition

interface Feature {
    public function boot(): void;
}

Bundled implementations

All Features implementations also implement Feature.

Feature library

The Library subnamespace includes concrete implementations of common features. These can be used on their own or as part of a set of features that make up a larger integration.

Basic usage

See the documentation for the Features interface for a more comprehensive example.

use Alley\WP\Features\Effect;
use Alley\WP\Features\Group;
use Alley\WP\Features\Lazy_Feature;
use Alley\WP\Features\Library;
use Alley\WP\Features\Ordered;
use Alley\WP\Features\Template_Feature;

$feature = new Effect(
  when: fn () => get_current_blog_id() !== 1,
  then: new Ordered(
    first: new Library\Plugin_Loader(
      plugins: [
        'block-visibility/block-visibility.php',
      ],
    ),
    then: new Group(
      new Features\Block_Visibility_Settings(),
      new Features\Block_Visibility_Custom_Conditions(),
    ),
  ),
);
$feature->boot();