2017 © Pedro Peláez
 

wordpress amarkal-admin-notification

Add static/dismissible admin notifications to WordPress

image

askupa-software/amarkal-admin-notification

Add static/dismissible admin notifications to WordPress

  • Sunday, December 24, 2017
  • by askupasoftware
  • Repository
  • 1 Watchers
  • 10 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

amarkal-admin-notification Build Status Scrutinizer Code Quality License

amarkal-admin-notification lets you add static/dismissible notifications to the WordPress administration. Dismissible notifications are permanently dismissed and will not show when the page reloads. For an in-depth tutorial, see Adding Static/Dismissible Admin Notifications to WordPress, (*1)

amarkal-admin-notification - , (*2)

Overview

amarkal-admin-notification lets you easily add notifications to the WordPress administration with different options to choose from. In WordPress 4.2 dismissible notifications became supported. However, a dismissed notification becomes visible again when the user refreshes the page or navigates away. amarkal-admin-notification handles that by storing an option in the database once a notification is dismissed.
amarkal-admin-notification is lightweight and trace free - it will only initiate if there is at least one registered notification, and will only store a database option if a user dismisses a notification. amarkal_reset_admin_notification() will remove the option from the database if there are no more dismissed notifications., (*3)

Installation

Via Composer

If you are using the command line:, (*4)

$ composer require askupa-software/amarkal-admin-notification:dev-master

Or simply add the following to your composer.json file:, (*5)

"require": {
    "askupa-software/amarkal-admin-notification": "dev-master"
}

And run the command, (*6)

$ composer install

This will install the package in the directory vendors/askupa-software/amarkal-admin-notification. Now all you need to do is include the composer autoloader., (*7)

require_once 'path/to/vendor/autoload.php';

Manually

Download the package from github and include bootstrap.php in your project:, (*8)

require_once 'path/to/amarkal-admin-notification/bootstrap.php';

Usage

amarkal_admin_notification

Register a notification to be printed in the administration., (*9)

amarkal_admin_notification( $handle, $html, $type = 'success', $dismissible = false, $class = '', $network = false )

This function is used to register a notification for a given handle. The handle is used as the notification's ID. If the notification is dismissible, the handle is used to permanently dismiss the notification. When a dismissible notification is dismissed, the amarkal_dismissed_notices option is updated with the handle added to it., (*10)

Parameters
* $handle (String) The notification's ID. Also used to permanently dismiss a dismissible notification. If a given handle has previously been registered, a PHP notice will be triggered. * $html (String) The text/HTML content of the notification. * $type (String) The notification's type. One of error, warning, info, success. * $dismissible (Boolean) Whether to add a "dismiss" button to allow the user to permanently dismiss the notification. * $class (String) An additional CSS class to be added to the notification for styling purposes. * $network (Boolean) Whether to show this notification in the network administration as well. Uses the network_admin_notices hook internally., (*11)

amarkal_reset_admin_notification

Reset a dismissible notification., (*12)

amarkal_reset_admin_notification( $handle )

This function can be used to make a previously dismissed notification visible again. It does that by removing the given $handle from the list of dismissed notifications stored in the option amarkal_dismissed_notices. If the list of dismissed notification is empty, the option will be removed from the database., (*13)

Parameters
* $handle (String) The handle of the notification to be reset., (*14)

The Versions

24/12 2017

dev-master

9999999-dev https://github.com/amarkal/amarkal-admin-notification

Add static/dismissible admin notifications to WordPress

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0

 

by Askupa Software

wordpress framework notices