codeb / wp-feature-flags
允许开发者根据标志启用/禁用功能。
v0.4.0
2024-09-21 11:01 UTC
Requires
- php: >=8.1
Requires (Dev)
- brain/monkey: ^2.6
- newsuk/nuk-wp-phpcs-config: ^0.2.0
- newsuk/nuk-wp-phpmd-config: ^0.1.0
- newsuk/nuk-wp-phpstan-config: ^0.1.0
- phpunit/phpunit: ^9.4
- yoast/wp-test-utils: ^1.2
- dev-main
- v0.4.0
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.0
- v0.1.0
- dev-dependabot/npm_and_yarn/wordpress/eslint-plugin-21.1.2
- dev-dependabot/npm_and_yarn/wordpress/components-28.8.0
- dev-dependabot/npm_and_yarn/eslint-plugin-cypress-3.5.0
- dev-dependabot/npm_and_yarn/playwright/test-1.47.2
- dev-dependabot/npm_and_yarn/types/jest-29.5.13
- dev-main-built
- dev-chore/wp-6.6-compatibility
- dev-chore/plugin-improv
- dev-chore/components-perf
- dev-feat/perf-tests
This package is auto-updated.
Last update: 2024-09-23 13:44:21 UTC
README
稳定标签:0.3.2 需要:至少 6.2 测试到:6.6 需要 PHP:8.1
WordPress 功能标志插件允许开发者在服务器(PHP)和客户端(JS/TS)上配置功能标志背后的插件/主题中的功能。
安装
composer require codeb/wp-feature-flags
Packagist: https://packagist.org.cn/packages/codeb/wp-feature-flags
钩子
PHP 过滤器
codeb_feature_flags_max_allowed
过滤器用于定义允许的标志的最大数量。建议保留默认值,即 20。
示例用法
add_filter( 'codeb_feature_flags_max_allowed', static function () { return 10; } );
JS 过滤器
codebFeatureFlags.newFlag.defaultStatus
该过滤器控制新标志是否默认启用。默认 true
示例用法
addFilter( 'codebFeatureFlags.newFlag.defaultStatus', 'codeb-feature-flags', () => { return false; } );
开发设置
构建插件
PHP 设置
composer install
JS 设置
yarn install
yarn build
创建构建yarn start
启动监视模式
wp-env
此插件使用 wp-env
设置用于本地环境。
wp-env start
启动容器wp-env stop
停止容器
有关如何访问本地环境的更多详细信息,请参阅 此处。
代码检查和格式化
PHP
composer lint
composer lint:fix
自动修复 PHP 代码检查错误。
JS
yarn lint:js
yarn lint:js:fix
自动修复 JS 代码检查错误。
CSS
yarn lint:css
yarn lint:css:fix
自动修复 CSS 代码检查错误。
测试
PHP
WordPress 单元和集成测试依赖于 wp-env
设置。确保在运行测试之前运行 yarn wp-env:coverage
。
- 运行单元测试
yarn php:unit
- 运行集成测试
yarn php:integration
- 作为多站运行集成测试
yarn php:multisite
JS
- 运行所有 Jest 和 React Testing Library 测试
yarn test:js
E2E
E2E 测试依赖于 wp-env
设置。确保在运行测试之前运行 wp-env start
。
- 运行所有 Playwright e2e 测试
yarn test:e2e
贡献
欢迎代码贡献、反馈、问题报告和功能建议。有关详细信息,请参阅 CONTRIBUTING.md。