1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file was automatically generated by automattic/jetpack-autoloader. |
4
|
|
|
* |
5
|
|
|
* @package automattic/jetpack-autoloader |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Automattic\Jetpack\Autoloader\jp02f167abb8e9ed34472e5bd963af3d06; |
9
|
|
|
|
10
|
|
|
// phpcs:ignore |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* This class selects the package versions for the package files. |
14
|
|
|
*/ |
15
|
|
|
class Files_Handler { |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The Plugins_Handler object. |
19
|
|
|
* |
20
|
|
|
* @var Plugins_Handler |
21
|
|
|
*/ |
22
|
|
|
private $plugins_handler = null; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The Version_Selector object. |
26
|
|
|
* |
27
|
|
|
* @var Version_Selector |
28
|
|
|
*/ |
29
|
|
|
private $version_selector = null; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The constructor. |
33
|
|
|
* |
34
|
|
|
* @param Plugins_Handler $plugins_handler The Plugins_Handler object. |
35
|
|
|
* @param Version_Selector $version_selector The Version_Selector object. |
36
|
|
|
*/ |
37
|
|
|
public function __construct( $plugins_handler, $version_selector ) { |
38
|
|
|
$this->plugins_handler = $plugins_handler; |
39
|
|
|
$this->version_selector = $version_selector; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Adds the version of a package file to the $jetpack_packages_filemap global |
44
|
|
|
* array so that we can load the most recent version. |
45
|
|
|
* |
46
|
|
|
* @param string $file_identifier Unique id to file assigned by composer based on package name and filename. |
47
|
|
|
* @param string $version Version of the file. |
48
|
|
|
* @param string $path Absolute path to the file so that we can load it. |
49
|
|
|
*/ |
50
|
|
View Code Duplication |
public function enqueue_package_file( $file_identifier, $version, $path ) { |
51
|
|
|
global $jetpack_packages_filemap; |
52
|
|
|
|
53
|
|
|
if ( isset( $jetpack_packages_filemap[ $file_identifier ]['version'] ) ) { |
54
|
|
|
$selected_version = $jetpack_packages_filemap[ $file_identifier ]['version']; |
55
|
|
|
} else { |
56
|
|
|
$selected_version = null; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
if ( $this->version_selector->is_version_update_required( $selected_version, $version ) ) { |
60
|
|
|
$jetpack_packages_filemap[ $file_identifier ] = array( |
61
|
|
|
'version' => $version, |
62
|
|
|
'path' => $path, |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Creates a path to the plugin's filemap. The filemap filename is the filename |
69
|
|
|
* generated by Jetpack Autoloader version >= 2.0. |
70
|
|
|
* |
71
|
|
|
* @param String $plugin_path The plugin path. |
72
|
|
|
* |
73
|
|
|
* @return String The filemap path |
74
|
|
|
*/ |
75
|
|
|
public function create_filemap_path( $plugin_path ) { |
76
|
|
|
return trailingslashit( $plugin_path ) . 'vendor/composer/jetpack_autoload_filemap.php'; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Initializes the filemap. |
81
|
|
|
*/ |
82
|
|
View Code Duplication |
public function set_file_paths() { |
83
|
|
|
$active_plugin_paths = $this->plugins_handler->get_all_active_plugins_paths(); |
84
|
|
|
$filemap_paths = array_map( array( $this, 'create_filemap_path' ), $active_plugin_paths ); |
85
|
|
|
|
86
|
|
|
foreach ( $filemap_paths as $path ) { |
87
|
|
|
if ( is_readable( $path ) ) { |
88
|
|
|
$file_map = require $path; |
89
|
|
|
|
90
|
|
|
if ( is_array( $file_map ) ) { |
91
|
|
|
foreach ( $file_map as $file_identifier => $file_data ) { |
92
|
|
|
$this->enqueue_package_file( $file_identifier, $file_data['version'], $file_data['path'] ); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Include latest version of all enqueued files. |
101
|
|
|
*/ |
102
|
|
|
public function file_loader() { |
103
|
|
|
global $jetpack_packages_filemap; |
104
|
|
View Code Duplication |
foreach ( $jetpack_packages_filemap as $file_identifier => $file_data ) { |
105
|
|
|
if ( empty( $GLOBALS['__composer_autoload_files'][ $file_identifier ] ) ) { |
106
|
|
|
require_once $file_data['path']; |
107
|
|
|
|
108
|
|
|
$GLOBALS['__composer_autoload_files'][ $file_identifier ] = true; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|