PluginProbe ʕ •ᴥ•ʔ
Hostinger Tools / 3.0.72
Hostinger Tools v3.0.72
3.0.72 3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.4 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 3.0.0 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.24 3.0.25 3.0.26 3.0.27 3.0.28 3.0.29 3.0.3 3.0.30 3.0.31 3.0.32 3.0.33 3.0.34 3.0.35 3.0.36 3.0.37 3.0.38 3.0.39 3.0.4 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.0.46 3.0.47 3.0.48 3.0.49 3.0.5 3.0.50 3.0.51 3.0.52 3.0.53 3.0.54 3.0.55 3.0.56 3.0.57 3.0.58 3.0.59 3.0.6 3.0.60 3.0.61 3.0.62 3.0.65 3.0.7 3.0.8 3.0.9 trunk 1.8.0
hostinger / vendor / jetpack-autoloader / class-plugin-locator.php
hostinger / vendor / jetpack-autoloader Last commit date
class-autoloader-handler.php 1 week ago class-autoloader-locator.php 1 week ago class-autoloader.php 1 week ago class-container.php 1 week ago class-hook-manager.php 1 week ago class-latest-autoloader-guard.php 1 week ago class-manifest-reader.php 1 week ago class-path-processor.php 1 week ago class-php-autoloader.php 1 week ago class-plugin-locator.php 1 week ago class-plugins-handler.php 1 week ago class-shutdown-handler.php 1 week ago class-version-loader.php 1 week ago class-version-selector.php 1 week ago
class-plugin-locator.php
154 lines
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\jpdbd67c2d973de5f4c78a03e582c78768\al5_0_20;
9
10 // phpcs:ignore
11
12 /**
13 * This class scans the WordPress installation to find active plugins.
14 */
15 class Plugin_Locator {
16
17 /**
18 * The path processor for finding plugin paths.
19 *
20 * @var Path_Processor
21 */
22 private $path_processor;
23
24 /**
25 * The constructor.
26 *
27 * @param Path_Processor $path_processor The Path_Processor instance.
28 */
29 public function __construct( $path_processor ) {
30 $this->path_processor = $path_processor;
31 }
32
33 /**
34 * Finds the path to the current plugin.
35 *
36 * @return string $path The path to the current plugin.
37 *
38 * @throws \RuntimeException If the current plugin does not have an autoloader.
39 */
40 public function find_current_plugin() {
41 // Escape from `vendor/__DIR__` to root plugin directory.
42 $plugin_directory = dirname( __DIR__, 2 );
43
44 // Use the path processor to ensure that this is an autoloader we're referencing.
45 $path = $this->path_processor->find_directory_with_autoloader( $plugin_directory, array() );
46 if ( false === $path ) {
47 throw new \RuntimeException( 'Failed to locate plugin ' . $plugin_directory );
48 }
49
50 return $path;
51 }
52
53 /**
54 * Checks a given option for plugin paths.
55 *
56 * @param string $option_name The option that we want to check for plugin information.
57 * @param bool $site_option Indicates whether or not we want to check the site option.
58 *
59 * @return array $plugin_paths The list of absolute paths we've found.
60 */
61 public function find_using_option( $option_name, $site_option = false ) {
62 $raw = $site_option ? get_site_option( $option_name ) : get_option( $option_name );
63 if ( false === $raw ) {
64 return array();
65 }
66
67 return $this->convert_plugins_to_paths( $raw );
68 }
69
70 /**
71 * Checks for plugins in the `action` request parameter.
72 *
73 * @param string[] $allowed_actions The actions that we're allowed to return plugins for.
74 *
75 * @return array $plugin_paths The list of absolute paths we've found.
76 */
77 public function find_using_request_action( $allowed_actions ) {
78 /**
79 * Note: we're not actually checking the nonce here because it's too early
80 * in the execution. The pluggable functions are not yet loaded to give
81 * plugins a chance to plug their versions. Therefore we're doing the bare
82 * minimum: checking whether the nonce exists and it's in the right place.
83 * The request will fail later if the nonce doesn't pass the check.
84 */
85 if ( empty( $_REQUEST['_wpnonce'] ) ) {
86 return array();
87 }
88
89 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated just below.
90 $action = isset( $_REQUEST['action'] ) ? wp_unslash( $_REQUEST['action'] ) : false;
91 if ( ! in_array( $action, $allowed_actions, true ) ) {
92 return array();
93 }
94
95 $plugin_slugs = array();
96 switch ( $action ) {
97 case 'activate':
98 case 'deactivate':
99 if ( empty( $_REQUEST['plugin'] ) ) {
100 break;
101 }
102
103 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated by convert_plugins_to_paths.
104 $plugin_slugs[] = wp_unslash( $_REQUEST['plugin'] );
105 break;
106
107 case 'activate-selected':
108 case 'deactivate-selected':
109 if ( empty( $_REQUEST['checked'] ) ) {
110 break;
111 }
112
113 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated by convert_plugins_to_paths.
114 $plugin_slugs = wp_unslash( $_REQUEST['checked'] );
115 break;
116 }
117
118 return $this->convert_plugins_to_paths( $plugin_slugs );
119 }
120
121 /**
122 * Given an array of plugin slugs or paths, this will convert them to absolute paths and filter
123 * out the plugins that are not directory plugins. Note that array keys will also be included
124 * if they are plugin paths!
125 *
126 * @param string[] $plugins Plugin paths or slugs to filter.
127 *
128 * @return string[]
129 */
130 private function convert_plugins_to_paths( $plugins ) {
131 if ( ! is_array( $plugins ) || empty( $plugins ) ) {
132 return array();
133 }
134
135 // We're going to look for plugins in the standard directories.
136 $path_constants = array( WP_PLUGIN_DIR, WPMU_PLUGIN_DIR );
137
138 $plugin_paths = array();
139 foreach ( $plugins as $key => $value ) {
140 $path = $this->path_processor->find_directory_with_autoloader( $key, $path_constants );
141 if ( $path ) {
142 $plugin_paths[] = $path;
143 }
144
145 $path = $this->path_processor->find_directory_with_autoloader( $value, $path_constants );
146 if ( $path ) {
147 $plugin_paths[] = $path;
148 }
149 }
150
151 return $plugin_paths;
152 }
153 }
154