PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 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 All 506 releases
jetpack / vendor / jetpack-autoloader / class-manifest-reader.php

class-manifest-reader.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.7, at vendor/jetpack-autoloader/class-manifest-reader.php

100 lines 2.6 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\jpf11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ16_3_a_7\al6_0_1;
9
10 // phpcs:ignore
11
12 /**
13 * This class reads autoloader manifest files.
14 */
15 class Manifest_Reader {
16
17 /**
18 * The Version_Selector object.
19 *
20 * @var Version_Selector
21 */
22 private $version_selector;
23
24 /**
25 * The constructor.
26 *
27 * @param Version_Selector $version_selector The Version_Selector object.
28 */
29 public function __construct( $version_selector ) {
30 $this->version_selector = $version_selector;
31 }
32
33 /**
34 * Reads all of the manifests in the given plugin paths.
35 *
36 * @param array $plugin_paths The paths to the plugins we're loading the manifest in.
37 * @param string $manifest_path The path that we're loading the manifest from in each plugin.
38 * @param array $path_map The path map to add the contents of the manifests to.
39 *
40 * @return array $path_map The path map we've built using the manifests in each plugin.
41 */
42 public function read_manifests( $plugin_paths, $manifest_path, &$path_map ) {
43 $file_paths = array_map(
44 function ( $path ) use ( $manifest_path ) {
45 return trailingslashit( $path ) . $manifest_path;
46 },
47 $plugin_paths
48 );
49
50 foreach ( $file_paths as $path ) {
51 $this->register_manifest( $path, $path_map );
52 }
53
54 return $path_map;
55 }
56
57 /**
58 * Registers a plugin's manifest file with the path map.
59 *
60 * @param string $manifest_path The absolute path to the manifest that we're loading.
61 * @param array $path_map The path map to add the contents of the manifest to.
62 */
63 protected function register_manifest( $manifest_path, &$path_map ) {
64 if ( ! is_readable( $manifest_path ) ) {
65 return;
66 }
67
68 $manifest = require $manifest_path;
69 if ( ! is_array( $manifest ) ) {
70 return;
71 }
72
73 foreach ( $manifest as $key => $data ) {
74 $this->register_record( $key, $data, $path_map );
75 }
76 }
77
78 /**
79 * Registers an entry from the manifest in the path map.
80 *
81 * @param string $key The identifier for the entry we're registering.
82 * @param array $data The data for the entry we're registering.
83 * @param array $path_map The path map to add the contents of the manifest to.
84 */
85 protected function register_record( $key, $data, &$path_map ) {
86 if ( isset( $path_map[ $key ]['version'] ) ) {
87 $selected_version = $path_map[ $key ]['version'];
88 } else {
89 $selected_version = null;
90 }
91
92 if ( $this->version_selector->is_version_update_required( $selected_version, $data['version'] ) ) {
93 $path_map[ $key ] = array(
94 'version' => $data['version'],
95 'path' => $data['path'],
96 );
97 }
98 }
99 }
100