antonioeatgoat/wp-dashboard-notice 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

antonioeatgoat/wp-dashboard-notice

Composer 安装命令:

composer require antonioeatgoat/wp-dashboard-notice

包简介

A small library to easily manage notice messages in the WordPress Dashboard

README 文档

README

A small library to easily manage notice messages in the WordPress dashboard

Installation

Use Composer to require the library.

composer require antonioeatgoat/wp-dashboard-notice

Then include the Composer autoload file in your project::

require_once 'vendor/autoload.php'

If that's not an option then clone or download the package and require the wp-dashboard-notice/autoload.php file in your code:

require_once 'path/to/wp-dashboard-notice/autoload.php';

Where path/to/wp-dashboard-notice/autoload.php is the absolute path to the autoload.php file.

Example

$notice = ( new NoticeFactory() )->create(
	'hello-world-notice',
	'<strong>Hello World</strong> - This is a sample notice',
	array(
		'title'          => 'This is a sample title',  
		'show_close_btn' => true,
		'cta_text'       => 'This is a custom CTA!',
		'cta_href'       => '#',
		'dismiss_text'   => "Don't show it again",
		'dismiss_mode'   => 'global',
		'status'         => 'success'
	));
NoticesManager::init()->register_notice($notice);

Parameters

The notice creations needs three parameters:

  • id: (string) An unique id to identificate it (it is also used as an id attribute in the HTML of the notice message printed).
  • message: (string) The actual notice message.
  • args: (array) Optional. An array of parameters containing more configurations.

Here's how the configurations can be used.

Custom CTA

You can print the custom CTA button using these arguments, both of them are required to display the CTA.

  • cta_text: The text of the button.
  • cta_href: The link where the CTA points to.

Permanent dismissing

The notice message can be dismissed permanently, clicking on a specific link. It supports three dismissing modes:

  • none: (default) Notice message cannot be dismissed and dismissing link isn't displayed.
  • global: Once dismissed, the notice message isn't shown again for nobody.
  • user: Once dismissed, the notice message is dismissed only for the current user. Other users will continue to see it.

You can print the dismissing link using these arguments, both of them are required to display the link.

  • dismiss_text: The text of the link.
  • dismiss_mode: The dismissing mode explained above.

Others

Other arguments of the parameters array are:

  • Title: (string) An eventual title, displayed above the message.
  • status: The status the notice message. Available values are "info" (default), "success", "warning", "error".
  • show_close_btn: (bool) Default false. If a button to close the notice message is displayed. Notce: This will only close the notice, not dismiss it. On the page refresh it will be displayed again if the code requires it. This is useful when you have a "single time" notice message. That haven't stands permanently on the page, such as the notice message "Plugin activated" when you active a plugin.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-08-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固