1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file `autoload_packages.php`was generated by automattic/jetpack-autoloader. |
4
|
|
|
* |
5
|
|
|
* From your plugin include this file with: |
6
|
|
|
* require_once . plugin_dir_path( __FILE__ ) . '/vendor/autoload_packages.php'; |
7
|
|
|
* |
8
|
|
|
* @package Automattic\Jetpack\Autoloader |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
// phpcs:disable PHPCompatibility.Keywords.NewKeywords.t_ns_cFound |
12
|
|
|
// phpcs:disable PHPCompatibility.LanguageConstructs.NewLanguageConstructs.t_ns_separatorFound |
13
|
|
|
// phpcs:disable PHPCompatibility.Keywords.NewKeywords.t_namespaceFound |
14
|
|
|
|
15
|
|
|
namespace Automattic\Jetpack\Autoloader; |
16
|
|
|
|
17
|
|
|
if ( ! function_exists( __NAMESPACE__ . '\enqueue_package' ) ) { |
18
|
|
|
global $jetpack_packages_classes; |
19
|
|
|
|
20
|
|
|
if ( ! is_array( $jetpack_packages_classes ) ) { |
21
|
|
|
$jetpack_packages_classes = array(); |
22
|
|
|
} |
23
|
|
|
/** |
24
|
|
|
* Adds the version of a package to the $jetpack_packages global array so that |
25
|
|
|
* the autoloader is able to find it. |
26
|
|
|
* |
27
|
|
|
* @param string $class_name Name of the class that you want to autoload. |
28
|
|
|
* @param string $version Version of the class. |
29
|
|
|
* @param string $path Absolute path to the class so that we can load it. |
30
|
|
|
*/ |
31
|
|
|
function enqueue_package( $class_name, $version, $path ) { |
32
|
|
|
global $jetpack_packages_classes; |
33
|
|
|
|
34
|
|
|
if ( ! isset( $jetpack_packages_classes[ $class_name ] ) ) { |
35
|
|
|
$jetpack_packages_classes[ $class_name ] = array( |
36
|
|
|
'version' => $version, |
37
|
|
|
'path' => $path, |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
// If we have a @dev version set always use that one! |
41
|
|
|
if ( 'dev-' === substr( $jetpack_packages_classes[ $class_name ]['version'], 0, 4 ) ) { |
42
|
|
|
return; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
// Always favour the @dev version. Since that version is the same as bleeding edge. |
46
|
|
|
// We need to make sure that we don't do this in production! |
47
|
|
|
if ( 'dev-' === substr( $version, 0, 4 ) ) { |
48
|
|
|
$jetpack_packages_classes[ $class_name ] = array( |
49
|
|
|
'version' => $version, |
50
|
|
|
'path' => $path, |
51
|
|
|
); |
52
|
|
|
|
53
|
|
|
return; |
54
|
|
|
} |
55
|
|
|
// Set the latest version! |
56
|
|
|
if ( version_compare( $jetpack_packages_classes[ $class_name ]['version'], $version, '<' ) ) { |
57
|
|
|
$jetpack_packages_classes[ $class_name ] = array( |
58
|
|
|
'version' => $version, |
59
|
|
|
'path' => $path, |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if ( ! function_exists( __NAMESPACE__ . '\autoloader' ) ) { |
66
|
|
|
/** |
67
|
|
|
* Used for autoloading jetpack packages. |
68
|
|
|
* |
69
|
|
|
* @param string $class_name Class Name to load. |
70
|
|
|
*/ |
71
|
|
|
function autoloader( $class_name ) { |
72
|
|
|
global $jetpack_packages_classes; |
73
|
|
|
|
74
|
|
|
if ( isset( $jetpack_packages_classes[ $class_name ] ) ) { |
75
|
|
|
/** |
76
|
|
|
* A way to prevent loading of a package from a particular location or version. |
77
|
|
|
* |
78
|
|
|
* @since 7.4.0 |
79
|
|
|
* |
80
|
|
|
* @param bool false whether to load a particular class package. |
81
|
|
|
* @param string $class_name Name of a particular class to autoload. |
82
|
|
|
* @param array $package Array containing the package path and version. |
83
|
|
|
*/ |
84
|
|
|
if ( apply_filters( 'jetpack_autoload_package_block', false, $class_name, $jetpack_packages_classes[ $class_name ] ) ) { |
85
|
|
|
return; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
if ( function_exists( 'did_action' ) && ! did_action( 'plugins_loaded' ) ) { |
89
|
|
|
_doing_it_wrong( |
90
|
|
|
esc_html( $class_name ), |
91
|
|
|
sprintf( |
92
|
|
|
/* translators: %s Name of a PHP Class */ |
93
|
|
|
esc_html__( 'Not all plugins have loaded yet but we requested the class %s', 'jetpack' ), |
94
|
|
|
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
95
|
|
|
$class_name |
96
|
|
|
), |
97
|
|
|
esc_html( $jetpack_packages_classes[ $class_name ]['version'] ) |
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
if ( file_exists( $jetpack_packages_classes[ $class_name ]['path'] ) ) { |
102
|
|
|
require_once $jetpack_packages_classes[ $class_name ]['path']; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
// Add the jetpack autoloader. |
108
|
|
|
spl_autoload_register( __NAMESPACE__ . '\autoloader' ); |
109
|
|
|
} |
110
|
|
|
|