x-wp/admin-notice-manager
最新稳定版本:v1.0.2
Composer 安装命令:
composer require x-wp/admin-notice-manager
包简介
Simplifies the process of working with admin notices in WordPress.
README 文档
README
Admin Notice Manager 🔔
Simplifies the process of creating, displaying and saving notices in WordPress admin.
Displaying notices in WordPress admin is a common task for plugin and theme developers. This package provides an easy to use API for notice management.
How to use
Installation
You can install the package via composer:
composer require x-wp/admin-notice-manager
Tip
We recommend using the automattic/jetpack-autoloader with this package to prevent autoloading issues.
Configuration and initialization
Package will automatically initialize itself on admin_init hook. Manager comes with batteries included - you will use the Notice class to create and display notices.
Examples
Creating a notice
If you are certain that no invoice has the same id as the one you are creating, you can use the xwp_create_notice function to create a notice.
<?php xwp_create_notice( array( 'id' => 'my-plugin-notice', 'type' => 'info', 'message' => 'This is an informational notice.', 'persistent' => true, 'dismissible' => true, ) );
Alternatively you can use the xwp_get_notice function to try retrieving a notice by its id - and create it if it doesn't exist.
<?php xwp_get_notice('my-plugin-notice') ->set_props( array( 'id' => 'my-plugin-notice', 'type' => 'info', 'message' => 'This is an informational notice.', 'persistent' => true, 'dismissible' => true, ) ) ->save();
统计信息
- 总下载量: 298
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-only
- 更新时间: 2024-10-29