← All changes
|
json-endpoints/jetpack/class-jetpack-json-api-install-backup-helper-script-endpoint.php
+18
-12
12.2.3
→
16.3-a.7
View file →
| @@ -5,17 +5,25 @@ | ||
| 5 | 5 | * |
| 6 | 6 | * @package automattic/jetpack |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -use Automattic\Jetpack\Backup\Helper_Script_Manager; | |
| 9 | +use Automattic\Jetpack\Backup\V0005\Helper_Script_Manager; | |
| 10 | 10 | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit( 0 ); | |
| 13 | +} | |
| 14 | + | |
| 11 | 15 | /** |
| 12 | 16 | * API endpoint /sites/%s/install-backup-helper-script |
| 13 | 17 | * This API endpoint installs a Helper Script to assist Jetpack Backup fetch data |
| 18 | + * | |
| 19 | + * @phan-constructor-used-for-side-effects | |
| 14 | 20 | */ |
| 15 | 21 | class Jetpack_JSON_API_Install_Backup_Helper_Script_Endpoint extends Jetpack_JSON_API_Endpoint { |
| 16 | 22 | /** |
| 17 | - * This endpoint is only accessible from Jetpack Backup; it requires no further capabilities. | |
| 23 | + * An empty capability set means this endpoint is only accessible using a site token: it is | |
| 24 | + * reachable with a Jetpack site (blog) token and denied for every user token, however | |
| 25 | + * privileged. See Jetpack_JSON_API_Endpoint::check_capability(). | |
| 18 | 26 | * |
| 19 | 27 | * @var array |
| 20 | 28 | */ |
| 21 | 29 | protected $needed_capabilities = array(); |
| @@ -71,20 +79,18 @@ | ||
| 71 | 79 | Helper_Script_Manager::cleanup_expired_helper_scripts(); |
| 72 | 80 | } |
| 73 | 81 | |
| 74 | 82 | /** |
| 75 | - * Returns the result of Helper Script installation. Returns one of: | |
| 76 | - * - WP_Error on failure, or | |
| 77 | - * - An array containing the access url ('url') and installation path ('path') on success. | |
| 83 | + * Return the success or failure of the backup helper script installation operation. | |
| 78 | 84 | * |
| 79 | - * @return array|WP_Error Success or failure information. | |
| 85 | + * @return array|WP_Error An array with installation info on success: | |
| 86 | + * | |
| 87 | + * 'path' (string) Helper script installation path on the filesystem. | |
| 88 | + * 'url' (string) URL to the helper script. | |
| 89 | + * 'abspath' (string) WordPress root. | |
| 90 | + * | |
| 91 | + * or an instance of WP_Error on failure. | |
| 80 | 92 | */ |
| 81 | 93 | protected function result() { |
| 82 | - // Include ABSPATH with successful result. | |
| 83 | - if ( ! is_wp_error( $this->result ) ) { | |
| 84 | - $this->result['abspath'] = ABSPATH; | |
| 85 | - } | |
| 86 | - | |
| 87 | 94 | return $this->result; |
| 88 | 95 | } |
| 89 | - | |
| 90 | 96 | } |