← All changes
|
json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php
+8
-0
13.6.2
→
16.3-a.7
View file →
| @@ -1,8 +1,12 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | |
| 3 | 3 | use Automattic\Jetpack\Plugins_Installer; |
| 4 | 4 | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | + exit( 0 ); | |
| 7 | +} | |
| 8 | + | |
| 5 | 9 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 6 | 10 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 7 | 11 | // POST /sites/%s/plugins/%s/install |
| 8 | 12 | new Jetpack_JSON_API_Plugins_Install_Endpoint( |
| @@ -55,8 +59,10 @@ | ||
| 55 | 59 | /** |
| 56 | 60 | * Plugins install enedpoint class. |
| 57 | 61 | * |
| 58 | 62 | * POST /sites/%s/plugins/%s/install |
| 63 | + * | |
| 64 | + * @phan-constructor-used-for-side-effects | |
| 59 | 65 | */ |
| 60 | 66 | class Jetpack_JSON_API_Plugins_Install_Endpoint extends Jetpack_JSON_API_Plugins_Endpoint { |
| 61 | 67 | |
| 62 | 68 | /** |
| @@ -98,8 +104,10 @@ | ||
| 98 | 104 | return $result; |
| 99 | 105 | } |
| 100 | 106 | |
| 101 | 107 | // No errors, install worked. Now replace the slug with the actual plugin id |
| 108 | + // @todo This code looks a bit suspect; why do we loop through plugins and only look at the last one? | |
| 109 | + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- we return early if there is an issue; otherwise $index and $slug are set in the foreach loop | |
| 102 | 110 | $this->plugins[ $index ] = Plugins_Installer::get_plugin_id_by_slug( $slug ); |
| 103 | 111 | |
| 104 | 112 | return true; |
| 105 | 113 | } |