underpin/admin-notice-loader

Underpin 管理通知加载器

1.1.0 2021-11-23 16:24 UTC

This package is auto-updated.

Last update: 2024-08-25 03:34:27 UTC


README

一个辅助向 WordPress 网站添加管理通知的加载器。

安装

使用 Composer

composer require underpin/admin-notice-loader

手动安装

此插件使用内置的自动加载器,因此只要在 Underpin 之前要求它,它应该可以按预期工作。

require_once(__DIR__ . '/underpin-admin-notices/admin-notices.php');

设置

  1. 安装 Underpin。请参阅 Underpin 文档
  2. 根据需要注册新的管理通知。

示例

一个非常基本的示例可能看起来像这样。此示例将在设置页面上始终显示通知。

\Underpin\underpin()->admin_notices()->add( 'example-notice', [
	'name'                    => 'Example notice',
	'description'             => 'This notice displays all the time.',
	'type'                    => 'notice',
	'is_dismissible'          => false,
	'wrapper_classes'         => [ 'class-1', 'class-2' ],
	'id'                      => 'example-notice',
	'message'                 => 'This will display all the time.',
	'should_display_callback' => '__return_true',
] );

这将显示:image

或者,您可以扩展 Admin_Notice 并直接引用扩展类,如下所示

underpin()->admin_notices()->add('key','Namespace\To\Class');