Download the PHP package yahnis-elsts/admin-notices without Composer

On this page you can find all versions of the php package yahnis-elsts/admin-notices. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package admin-notices

Easy Admin Notices

A PHP utility library for WordPress plugins that helps create admin notices.

Build Status

Highlights

Requirements

Installation

Install with Composer:

Alternatively, you can install it manually:

  1. Download the latest release.
  2. Move the admin-notices directory to your plugin.
  3. Load the library:

A note on load order: To ensure that persistently dismissible notices will work correctly, you should require the library before the admin_init action. For example, you can put the require in a plugins_loaded hook, or simply at the top of your plugin.

Usage

Basic example:

Result:

Basic admin notice

You don't have to put this code in a hook. The show() method is smart. It checks if the admin_notices action was already executed and either displays the notice immediately or adds a new admin_notices hook that will display the notice when appropriate. It also checks any capability requirements and page filters before actually showing the notice (see Preconditions).

Type shortcuts

WordPress comes with several built-in CSS classes for different types of admin notices. You can use the following shortcut methods to simultaneously set the notice type and the contents of the notice.

success([$message])

Success notice

error([$message])

Error notice

warning([$message])

Warning notice

info([$message])

Informational notice

Content

Instead of passing a string to one of the type-specific methods, you can set the contents of the notice by calling one of the following methods.

text($message)

Set the contents of the notice to a text string. text() will escape HTML special characters like <, >, & and so on.

Example:

Text escaping

html($arbitraryHtml)

Set the contents of the notice to a HTML string. Unlike text(), this method does not perform any escaping or encoding.

HTML content

rawHtml($arbitraryHtml)

Usually, the contents of a notice are wrapped in a single paragraph (<p>) tag. To prevent this wrapping, use rawHtml() to set the notice content. This is useful if you want to use complex HTML or to display a long message where one paragraph is not enough.

Raw HTML content

Dismissible notices

dismissible()

Add an "(x)" icon to the notice. Clicking the icon will hide the notice. However, this doesn't prevent the notice from reappearing in the future. Use persistentlyDismissible() for that.

Dismissible notice (not persistent)

persistentlyDismissible([$scope, $duration])

Make the notice persistently dismissible. When the user dismisses the notice, the library stores a flag in the database that prevents the notice from showing up again. Persistently dismissible notices must have a unique ID.

The $scope parameter controls whether clicking "(x)" will hide the notice for everyone or just for the current user. The supported values are:

Example:

Persistently dismissible notice

The $duration parameter controls how long (in seconds) the notice will be considered dismissed for. By default, notices will be dismissed permanently.

Example:

Notes:

dismiss([$duration])

Persistently dismiss the notice. Only works on notices that have been flagged as persistentlyDismissible().

The $duration parameter controls how long (in seconds) the notice will be considered dismissed for. By default, the duration is the same as the duration passed to persistentlyDismissible(). You can also pass AdminNotice::DISMISS_PERMANENTLY to dismiss the notice permanently.

undismiss()

Restore a previously dismissed notice.

isDismissed() : boolean

Check if the notice has been dismissed.

AdminNotice::cleanUpDatabase($prefix)

Delete all "this notice is dismissed" flags that have the specified ID prefix from the database. If you're using persistently dismissible notices, it's a good idea to call this function when your plugin is uninstalled.

For example, if your notice IDs start with myplugin-, you can remove the database entries like this:

Preconditions

These methods control where notices will appear and who will be able to see them.

onPage($screenId)

Show the notice only on the specified admin page(s). $screenId can be either the screen ID of a page (i.e. a string), or an array of screen IDs.

See Admin Screen Reference for a list of screens and their IDs. In the case of plugin and theme admin pages, the screen ID is usually the same as the value returned by the add_*_page() function.

Example:

requiredCap($capability)

Show the notice only to users who have the specified $capability.

Show now or later

After creating a notice, call one of these methods to display it.

show()

Automagically show the notice on the current page when all preconditions are met.

showOnNextPage()

Show the notice on the next admin page that's visited by the current user. The notice will be shown only once.

This method is useful for plugin activation hooks, redirects, and other situations where you can't display a notice immediately for whatever reason. The library will store the notice in the database. It will display the notice the next time that the admin_notices action is called in the context of the current user, whether happens during this page load or the next one, or a week later.

outputNotice()

Immediately display the notice. This method bypasses any checks and preconditions and just outputs the notice directly. It's mainly intended for debugging.


All versions of admin-notices with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yahnis-elsts/admin-notices contains the following files

Loading the files please wait ....