shazzad/wp-admin-notice
Composer 安装命令:
composer require shazzad/wp-admin-notice
包简介
Library to add & display admin notices in WordPress
README 文档
README
Helper class to display admin notices.
Installation
composer require shazzad/wp-admin-notice
Initialization
Initialize the service provider.
\Shazzad\WpAdminNotice\Provider::setup();
Adding notice.
Call the function do_action with appropriate parameter to add a notice.
This code must be placed before wp admin area start rendering content on screen.
Use admin_notices, all_admin_notices or network_admin_notices action hook to add notice.
do_action( 'swpan_notice', array( 'success' => __('You setting is stored successfully.'), 'id' => 'plugin-setting', ) ); do_action( 'swpan_notice', array( 'error' => __('Sorry, we could not save your settings.'), ) );
Adding user notice.
Use user notice when you perform some action and redirect the user to a page. The notice will be stored for until it is displayed to the user. Add a third parameter to the action hook to add a user notice.
do_action( 'swpan_notice', array( 'message' => __('You setting is stored successfully.'), 'type' => 'success', 'id' => 'my-notice-id', ), 'user' ); do_action( 'swpan_notice', array( 'message' => __('Sorry, we could not save your settings.'), 'type' => 'error', 'id' => 'my-notice-id', ), 'user' );
Requirements
- WordPress: 6.0.1
- PHP: 7.4
- Tested: 6.2.2
统计信息
- 总下载量: 762
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2023-07-30