1. Go to this page and download the library: Download wptrt/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/ */
wptrt / admin-notices example snippets
$my_theme_notices = new \WPTRT\AdminNotices\Notices();
// Add a notice.
$my_theme_notices->add( (string) $id, (string) $title, (string) $content, (array) $options );
// Boot things up.
$my_theme_notices->boot();
use WPTRT\AdminNotices\Notices;
$my_theme_notices = new Notices();
$my_theme_notices->add(
'my_theme_notice', // Unique ID.
esc_html__( 'Notice Title', 'textdomain' ), // The title for this notice.
esc_html__( 'Notice content', 'textdomain' ) // The content for this notice.
);
$my_theme_notices->add(
'my_notice', // Unique ID.
esc_html__( 'Notice Title', 'textdomain' ), // The title for this notice.
esc_html__( 'Notice content', 'textdomain' ), // The content for this notice.
[
'scope' => 'user', // Dismiss is per-user instead of global.
'screens' => [ 'themes' ], // Only show notice in the "themes" screen.
'type' => 'warning', // Make this a warning (orange color).
'alt_style' => true, // Use alt styles.
'option_prefix' => 'my_theme', // Change the user-meta prefix.
]
);