PHP code example of szepeviktor / persistent-admin-notices
1. Go to this page and download the library: Download szepeviktor/persistent-admin-notices library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
szepeviktor / persistent-admin-notices example snippets
// Use Composer instead: composer eviktor/persistent-admin-notices/src/PersistentNotices.php';
use WordPress\Admin\PersistentNotices;
// Fire it up!
\add_action('init', function () {
new PersistentNotices();
});
// Or HookConstructorTo::init(PersistentNotices::class, 0);
// New notice.
PersistentNotices::add('slug', 'Something needs your attention!');
// New error notice.
PersistentNotices::error('slug', 'An error needs to be resolved!');
// Check whether a notice is showing.
if (PersistentNotices::isActive('slug')) {}
// Delete notice.
PersistentNotices::remove('slug');
// Customize notice.
PersistentNotices::add(
'slug',
'Something very special needs your attention!',
[
'expiration' => PersistentNotices::PERSISTENT, // Expiration in seconds or PersistentNotices::ONCE
'type' => 'info', // Notice type: info, succes, warning, error.
'capability' => 'manage_options', // WordPress capability to receive notifications.
'priority' => 10, // Used to order notices.
'classes' => '', // Override CSS classes.
'noticeHtml' => '', // Override full notice HTML.
]
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.