File: //proc/thread-self/cwd/wp-content/plugins/automatewoo/includes/AdminNotices/UpdateNoticeManager.php
<?php
namespace AutomateWoo\AdminNotices;
use AutomateWoo\Admin;
use AutomateWoo\AdminNotices;
/**
* Display an admin notice on plugin update
*
* @since 5.0.0
* @package AutomateWoo
*/
class UpdateNoticeManager {
const NOTICE_ID = 'update';
/**
* The version this notice relates to.
*
* @var string
*
* @see output_admin_notice method to update the version number displayed in the notice
*/
protected static $version = '5.2';
/**
* Attach callbacks.
*
* @since 5.0.0
*/
public static function init() {
add_action( 'automatewoo_version_changed', [ __CLASS__, 'maybe_add_admin_notice' ], 10, 2 );
add_action( 'automatewoo/admin_notice/update', [ __CLASS__, 'output_admin_notice' ] );
}
/**
* Add an admin notice when the plugin is updated.
*
* @param string $previous_version The version of AutomateWoo the store was running prior to updating.
* @param string $current_version The new version the site has been updated to.
*
* @since 5.0.0
*/
public static function maybe_add_admin_notice( $previous_version, $current_version ) {
if ( '' !== $previous_version && version_compare( $previous_version, self::$version, '<' ) && version_compare( $current_version, self::$version, '>=' ) ) {
AdminNotices::add_notice( 'update' );
AdminNotices::remove_notice( 'welcome' );
}
}
/**
* Outputs the update notice including details about the update.
*/
public static function output_admin_notice() {
$title = __( 'Thanks for updating to AutomateWoo 5.2!', 'automatewoo' );
$description = sprintf(
__(
'In this release we have introduced some minor new features, added support for PHP 8 and finished converting all background processing to the <%1$s>Action Scheduler<%2$s> library which is used in WooCommerce core.',
'automatewoo'
),
'a href="https://actionscheduler.org/" target="_blank"',
'/a'
);
$links = [
[
'text' => __( 'View changelog', 'automatewoo' ),
'href' => 'https://dzv365zjfbd8v.cloudfront.net/changelogs/automatewoo/changelog.txt',
'class' => 'button-primary',
'data_link_type' => 'changelog',
'target' => '_blank',
],
];
Admin::get_view(
'welcome-notice',
[
'notice_identifier' => self::NOTICE_ID,
'title' => $title,
'description' => $description,
'links' => $links,
]
);
}
}