/var/www/html_us/wp-content/plugins/woocommerce/src/Admin/Composer/Package.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
 * Returns information about the package and handles init.
 */

/**
 * This namespace isn't compatible with the PSR-4
 * which ensures that the copy in the standalone plugin will not be autoloaded.
 */
namespace Automattic\WooCommerce\Admin\Composer;

defined'ABSPATH' ) || exit;

use 
Automattic\WooCommerce\Admin\Notes\Notes;
use 
Automattic\WooCommerce\Admin\Notes\NotesUnavailableException;
use 
Automattic\WooCommerce\Internal\Admin\FeaturePlugin;

/**
 * Main package class.
 */
class Package {

    
/**
     * Version.
     *
     * @var string
     */
    
const VERSION '3.3.0';

    
/**
     * Package active.
     *
     * @var bool
     */
    
private static $package_active false;

    
/**
     * Active version
     *
     * @var bool
     */
    
private static $active_version null;

    
/**
     * Init the package.
     *
     * Only initialize for WP 5.3 or greater.
     */
    
public static function init() {
        
// Avoid double initialization when the feature plugin is in use.
        
if (defined'WC_ADMIN_VERSION_NUMBER' ) ) {
            
self::$active_version WC_ADMIN_VERSION_NUMBER;
            return;
        }

        
$feature_plugin_instance FeaturePlugin::instance();

        
// Indicate to the feature plugin that the core package exists.
        
if ( ! defined'WC_ADMIN_PACKAGE_EXISTS' ) ) {
            
define'WC_ADMIN_PACKAGE_EXISTS'true );
        }

        
self::$package_active true;
        
self::$active_version self::VERSION;
        
$feature_plugin_instance->init();

        
// Unhook the custom Action Scheduler data store class in active older versions of WC Admin.
        
remove_filter'action_scheduler_store_class', array( $feature_plugin_instance'replace_actionscheduler_store_class' ) );
    }

    
/**
     * Return the version of the package.
     *
     * @return string
     */
    
public static function get_version() {
        return 
self::VERSION;
    }

    
/**
     * Return the active version of WC Admin.
     *
     * @return string
     */
    
public static function get_active_version() {
        return 
self::$active_version;
    }

    
/**
     * Return whether the package is active.
     *
     * @return bool
     */
    
public static function is_package_active() {
        return 
self::$package_active;
    }

    
/**
     * Return the path to the package.
     *
     * @return string
     */
    
public static function get_path() {
        return 
dirname__DIR__ );
    }

    
/**
     * Checks if notes have been initialized.
     */
    
private static function is_notes_initialized() {
        try {
            
Notes::load_data_store();
        } catch ( 
NotesUnavailableException $e ) {
            return 
false;
        }
        return 
true;
    }
}