PHP code example of stellarwp / core-update-notice
1. Go to this page and download the library: Download stellarwp/core-update-notice 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/ */
stellarwp / core-update-notice example snippets
use StraussGeneratedNamespace\StellarWP\CoreUpdateNotice\CoreUpdateNotice;
use StraussGeneratedNamespace\StellarWP\CoreUpdateNotice\Register;
$isPluginPage = static function (): bool {
$screen = get_current_screen();
return $screen !== null && in_array(
$screen->id,
[
'toplevel_page_my-plugin',
'my-plugin_page_my-plugin-settings',
],
true
);
};
add_action(
'init',
static fn() => Register::notice( new CoreUpdateNotice(), $isPluginPage )
);
add_action(
'init',
static function (): void {
Register::notice(
new CoreUpdateNotice( [
'heading' => __( 'Keep your site protected. Update to the latest version of WordPress.', 'my-plugin' ),
'body' => __( 'Your site is running on an outdated version of WordPress, …', 'my-plugin' ),
'dismiss' => __( 'Dismiss this notice.', 'my-plugin' ),
] ),
static fn(): bool => my_plugin_is_admin_page()
);
}
);