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.LanguageConstructs.NewLanguageConstructs.t_ns_separatorFound |
12
|
|
|
// phpcs:disable PHPCompatibility.Keywords.NewKeywords.t_namespaceFound |
13
|
|
|
// phpcs:disable PHPCompatibility.Keywords.NewKeywords.t_ns_cFound |
14
|
|
|
|
15
|
|
|
namespace Automattic\Jetpack\Autoloader; |
16
|
|
|
|
17
|
|
|
if ( ! function_exists( __NAMESPACE__ . '\enqueue_package_class' ) ) { |
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( $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
|
|
|
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
76
|
|
|
// TODO ideally we shouldn't skip any of these, see: https://github.com/Automattic/jetpack/pull/12646. |
77
|
|
|
$ignore = in_array( |
78
|
|
|
$class_name, |
79
|
|
|
array( |
80
|
|
|
'Automattic\Jetpack\JITM', |
81
|
|
|
'Automattic\Jetpack\Connection\Manager', |
82
|
|
|
'Automattic\Jetpack\Connection\Manager_Interface', |
83
|
|
|
'Automattic\Jetpack\Connection\XMLRPC_Connector', |
84
|
|
|
'Jetpack_IXR_Client', |
85
|
|
|
'Jetpack_Options', |
86
|
|
|
'Jetpack_Signature', |
87
|
|
|
'Jetpack_XMLRPC_Server', |
88
|
|
|
'Automattic\Jetpack\Sync\Main', |
89
|
|
|
'Automattic\Jetpack\Constants', |
90
|
|
|
'Automattic\Jetpack\Tracking', |
91
|
|
|
'Automattic\Jetpack\Plugin\Tracking', |
92
|
|
|
), |
93
|
|
|
true |
94
|
|
|
); |
95
|
|
|
if ( ! $ignore && function_exists( 'did_action' ) && ! did_action( 'plugins_loaded' ) ) { |
96
|
|
|
_doing_it_wrong( |
97
|
|
|
esc_html( $class_name ), |
98
|
|
|
sprintf( |
99
|
|
|
/* translators: %s Name of a PHP Class */ |
100
|
|
|
esc_html__( 'Not all plugins have loaded yet but we requested the class %s', 'jetpack' ), |
101
|
|
|
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
102
|
|
|
$class_name |
103
|
|
|
), |
104
|
|
|
esc_html( $jetpack_packages_classes[ $class_name ]['version'] ) |
105
|
|
|
); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
if ( file_exists( $jetpack_packages_classes[ $class_name ]['path'] ) ) { |
110
|
|
|
require_once $jetpack_packages_classes[ $class_name ]['path']; |
111
|
|
|
|
112
|
|
|
return true; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
return false; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
// Add the jetpack autoloader. |
120
|
|
|
spl_autoload_register( __NAMESPACE__ . '\autoloader' ); |
121
|
|
|
} |
122
|
|
|
/** |
123
|
|
|
* Prepare all the classes for autoloading. |
124
|
|
|
*/ |
125
|
|
|
function enqueue_packages_fd6ab2d6fa565f35155c5ce7df68b9f9() { |
126
|
|
|
$class_map = require_once dirname( __FILE__ ) . '/composer/autoload_classmap_package.php'; |
127
|
|
|
foreach ( $class_map as $class_name => $class_info ) { |
128
|
|
|
enqueue_package_class( $class_name, $class_info['version'], $class_info['path'] ); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
$autoload_file = __DIR__ . '/composer/autoload_files.php'; |
132
|
|
|
$includeFiles = file_exists( $autoload_file ) |
133
|
|
|
? require $autoload_file |
134
|
|
|
: []; |
135
|
|
|
|
136
|
|
|
foreach ( $includeFiles as $fileIdentifier => $file ) { |
137
|
|
|
if ( empty( $GLOBALS['__composer_autoload_files'][ $fileIdentifier ] ) ) { |
138
|
|
|
require $file; |
139
|
|
|
|
140
|
|
|
$GLOBALS['__composer_autoload_files'][ $fileIdentifier ] = true; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
enqueue_packages_fd6ab2d6fa565f35155c5ce7df68b9f9(); |
145
|
|
|
|