跳到内容

Switcheroo

v1.0.2

John Thompson · 2025年2月4日 上架

Easily manage feature flags to control the availability of features on your WordPress site without deploying new code.

正在使用
10+
评分
暂无
累计下载
3,294
最近更新
2025年3月12日
需要 WordPress 5.0+已测试到 6.7.12PHP 8.0+

贡献者

Feature flags are a powerful tool for controlling the availability of features on your site. By enabling or disabling flags, you can control what is active on your site without needing to deploy new code.

Features are defined in the switcheroo.json file located in the root of your project.
Each feature has:

  • Unique ID: An identifier for the feature.
  • Title: A human-readable name.
  • Description: Explains the feature’s purpose.
  • Status: Indicates whether the feature is active, experimental, deprecated, etc.
  • Link: An optional link to further information.

You can toggle each feature within the Switcheroo Settings in the WP Admin (Settings -> Switcheroo).

Usage

Managing Feature Flags in Code

You can wrap your feature-specific code in a conditional statement to check if a flag is enabled.

For example, use the switcheroo_flag_status('my_feature') function to determine whether a feature is active and include its logic conditionally.

Suggested Feature Flag Statuses

Each feature flag can be assigned a status, allowing for better organisation and understanding of the feature’s state:

  • Draft: The feature is still in development and not ready for use.
  • Experimental: The feature is available for testing but may have known issues.
  • Active: The feature is live and functional on the site.
  • Deprecated: The feature is being phased out and may be removed in the future.
  • Breaking: The feature introduces significant changes; enabling or disabling it may cause issues.
  • Archived: The feature has been permanently removed or is no longer supported.
  • High-Risk: The feature introduces significant changes or is under scrutiny for potential issues.

Command Line Management

You can also manage your feature flags via the command line using WP-CLI. The wp switcheroo command allows you to view and modify feature flags.

Examples:
– wp switcheroo: List all flags and their statuses.
– wp switcheroo my_feature: Check the status of the my_feature flag.
– wp switcheroo my_feature on: Enable the my_feature flag.
– wp switcheroo my_feature off: Disable the my_feature flag.

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums