alessandrotesoro / wp-notices
此包已被弃用且不再维护。未建议替代包。
一个用于创建持久和可关闭的WordPress管理通知的辅助库。
1.0.3
2019-05-29 11:24 UTC
Requires
- php: >=5.3.2
- composer/installers: ~1.0
This package is auto-updated.
Last update: 2020-09-29 14:09:12 UTC
README
一个用于创建持久和可关闭的WordPress管理通知的辅助库。
安装
需要Composer。
composer require alessandrotesoro/wp-notices
使用方法
导入库并分配你自己的命名空间
use TDP\WP_Notice as MYNOTICES;
创建包装函数
function mynotices() { return MYNOTICES::instance(); }
为所有用户创建全局通知
mynotices()->register_notice( 'my_notice', 'warning', 'This is the message' ) );
或只为当前登录用户创建通知
mynotices()->register_notice( 'my_notice', 'warning', 'This is the message', array( 'scope' => 'user' ) ) );
可用参数
参数 | 类型 | 选项 | 默认值 | 描述 |
---|---|---|---|---|
id | string | 用于识别通知的必需ID | ||
type | string | success, warning, error, info | 确定通知的类型 | |
message | string | 你希望在WordPress中显示的消息 | ||
args | array | 作用域(global, user),可关闭(true/false),权限,class | 作用域 = global, 可关闭 = true | 通知可用的其他设置 |