humanmade/wp-flags
Composer 安装命令:
composer require humanmade/wp-flags
包简介
Lightweight WordPress plugin to enable exposing feature flags to end-users, based on code-based ( or admin UI in the future ) criteria.
README 文档
README
|
Flags Lightweight WordPress plugin to enable exposing feature flags to end-users, based on code-based ( or admin UI in the future ) criteria. |
|
| A Human Made project. |
|
NOTE: This is a work-in-progress plugin.
Installation
Using Composer
- Require the package in your project
composer require humanmade/wp-flags
Using submodules
- Add the plugin as a submodule ( adjust the path as necessary )
git submodule add git@github.com:humanmade/wp-flags.git content/plugins/wp-flags
Usage
use HumanMade\Flags\Flags;
add_action( 'init', function() {
Flags::add( 'new-flag', 'New Flag', [
// Is the flag exposed to users ?
'available' => function() {
return current_user_can( 'manage_options' );
},
// At what level the flag can be set. One of `user` or `site`
'scope' => 'user',
// Default flag status
'active' => true,
// Is the flag controllable by users ?
'optin' => true,
// Custom icon ? ( dashicon-compatible )
'icon' => 'dashboard',
// Custom attribute ?
'some_custom_meta_key' => 'some_value',
] );
// OR just..
$flag = Flags::add( 'another-flag', 'Another flag' );
$flag->on( 'active', function( $active, $flag ) {
// do something based on active status change
} );
// Execute logic based on flag status
if ( Flags::get( 'new-flag' )->active ) {
show_the_new_sidebar();
} );
} );
Scope of Setting a Flag
A flag can be set at either the user or site scope, which determines how a flag is controlled. A user-scoped flag can be turned on or off by each user for that user only on a site, whereas a site-scoped flag is turned on or off for every user and is controlled in the site settings.
Credits
Written and maintained by Shady Sharaf. Thanks to all our contributors.
Interested in joining in on the fun? Join us, and become human!
humanmade/wp-flags 适用场景与选型建议
humanmade/wp-flags 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 56.28k 次下载、GitHub Stars 达 36, 最近一次更新时间为 2019 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 humanmade/wp-flags 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 humanmade/wp-flags 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 56.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 36
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-15