/var/www/html_uk/wp-content/plugins/automatewoo/includes/AdminNotices/UpdateNoticeManager.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?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 '6.0.19';

    
/**
     * Attach callbacks.
     *
     * @since 5.0.0
     */
    
public static function init() {
        
add_action'automatewoo_version_changed', [ __CLASS__'maybe_add_admin_notice' ], 10);
        
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_versionself::$version'<' ) && version_compare$current_versionself::$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 6.0.19!''automatewoo' );
        
$description sprintf(
            
__(
                
'In this release, we replaced the ActiveCampaign SDK with REST API calls. Check the changelog for more details.',
                
'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,
            ]
        );
    }
}