1. Home
  2. EdminBoost
  3. Developers
  4. Hooks and filters

Hooks and filters

When to use a “feature module”

Add a feature module when you want a toggle under Productivity, Security, or Performance that runs only when enabled.

Do not use the feature registry for:

  • Top bar / drawer (Command Center bar)
  • Menu Studio sidebar
  • Theme skins
  • White label

Those have their own classes (see architecture overview).

Checklist (8 steps)

  1. Create the class file

Path: includes/features/class-edminboost-{your-name}.php

Extend EDMINBOOST_Feature_Base.

Set:

  • protected $id = ‘snake_case_id’;
  • protected $name and $description (translatable strings)

Implement register_hooks() and add WordPress actions/filters there. No hook registration in the constructor.

  1. Register the class

In includes/class-edminboost-features.php:

  • require_once your file
  • Add your class name to the $feature_classes array

Or append via edminboost_feature_classes filter from a small companion plugin.

  1. Add defaults

In EDMINBOOST_Feature_Settings::get_defaults(), add a key matching your feature ID (boolean or structured array).

  1. Add enable logic

In EDMINBOOST_Feature_Settings::is_enabled() if your feature is not a simple on/off flag.

Most features only need a truthy enabled key; EDMINBOOST_Settings::is_feature_enabled() delegates here.

  1. Add sanitization

In EDMINBOOST_Feature_Settings::sanitize() so saves through Settings API / AJAX stay safe.

  1. Add admin UI

In admin/partials/edminboost-feature-fields.php under the right section:

  • productivity
  • security
  • performance

Use labels, fieldsets, and EDMINBOOST_Setting_Help::echo_icon() where other fields do.

  1. Respect global and screen scope
  • If EDMINBOOST_Settings::is_enabled() is false, features should not run (registry only calls register_hooks for enabled features, but global kill switch is checked inside is_feature_enabled path).
  • Skip EdminBoost’s own admin pages when your feature would break the UI (compare against EDMINBOOST_Admin::PAGE_SLUG).
  1. Test

Add or extend PHPUnit in tests/phpunit/FeaturesTest.php if you add sanitization or enable rules.

Minimal class sketch

class EDMINBOOST_My_Feature extends EDMINBOOST_Feature_Base {

protected $id          = 'my_feature';
protected $name        = 'My Feature';
protected $description = 'Short description for the settings UI.';

public function register_hooks() {
    add_action( 'admin_init', array( $this, 'do_something' ) );
}

public function do_something() {
    if ( ! $this->is_enabled() ) {
        return;
    }
    // Your logic.
}

}

Reading feature settings

Use:

EDMINBOOST_Settings::get_feature_settings( $this->get_id() );

Not get_option( ‘edminboost_settings’ ) directly in feature code.

Naming rules

  • Feature ID: snake_case, unique, matches settings key under features
  • Class: EDMINBOOST_{Name}
  • File: class-edminboost-{name}.php

How can we help?