PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 8.9.4
Jetpack – WP Security, Backup, Speed, & Growth v8.9.4
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / vendor / class-classes-handler.php
class-classes-handler.php
99 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\jp051524c91c016472c86188026f52475a;
9
10 // phpcs:ignore
11
12 /**
13 * This class selects the package versions for the package classes.
14 */
15 class Classes_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 to the $jetpack_packages_classmap global
44 * array so that the autoloader is able to find it.
45 *
46 * @param string $class_name Name of the class that you want to autoload.
47 * @param string $version Version of the class.
48 * @param string $path Absolute path to the class so that we can load it.
49 */
50 public function enqueue_package_class( $class_name, $version, $path ) {
51 global $jetpack_packages_classmap;
52
53 if ( isset( $jetpack_packages_classmap[ $class_name ]['version'] ) ) {
54 $selected_version = $jetpack_packages_classmap[ $class_name ]['version'];
55 } else {
56 $selected_version = null;
57 }
58
59 if ( $this->version_selector->is_version_update_required( $selected_version, $version ) ) {
60 $jetpack_packages_classmap[ $class_name ] = array(
61 'version' => $version,
62 'path' => $path,
63 );
64 }
65 }
66
67 /**
68 * Creates the path to the plugin's classmap file. The classmap 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 classmap path.
74 */
75 public function create_classmap_path( $plugin_path ) {
76 return trailingslashit( $plugin_path ) . 'vendor/composer/jetpack_autoload_classmap.php';
77 }
78
79 /**
80 * Initializes the classmap.
81 */
82 public function set_class_paths() {
83 $active_plugins_paths = $this->plugins_handler->get_all_active_plugins_paths();
84 $classmap_paths = array_map( array( $this, 'create_classmap_path' ), $active_plugins_paths );
85
86 foreach ( $classmap_paths as $path ) {
87 if ( is_readable( $path ) ) {
88 $class_map = require $path;
89
90 if ( is_array( $class_map ) ) {
91 foreach ( $class_map as $class_name => $class_info ) {
92 $this->enqueue_package_class( $class_name, $class_info['version'], $class_info['path'] );
93 }
94 }
95 }
96 }
97 }
98 }
99