PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
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
← All changes | json-endpoints/jetpack/class-jetpack-json-api-delete-backup-helper-script-endpoint.php +21 -9 12.9.5 → 16.3-a.5 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/delete-backup-helper-script
13 17 * This API endpoint deletes a Jetpack Backup Helper Script
18 + *
19 + * @phan-constructor-used-for-side-effects
14 20 */
15 21 class Jetpack_JSON_API_Delete_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();
@@ -34,13 +42,13 @@
34 42 */
35 43 protected $script_path = null;
36 44
37 45 /**
38 - * True if the specified file has been successfully deleted.
46 + * An array with 'success' => true if the specified file has been successfully deleted, or an instance of WP_Error.
39 47 *
40 - * @var boolean
48 + * @var array|WP_Error
41 49 */
42 - protected $result = false;
50 + protected $result;
43 51
44 52 /**
45 53 * Checks that the input args look like a valid Helper Script path.
46 54 *
@@ -61,10 +69,16 @@
61 69 /**
62 70 * Deletes the specified Helper Script.
63 71 */
64 72 protected function delete() {
65 - $this->result = Helper_Script_Manager::delete_helper_script( $this->script_path );
73 + $delete_result = Helper_Script_Manager::delete_helper_script( $this->script_path );
66 74 Helper_Script_Manager::cleanup_expired_helper_scripts();
75 +
76 + if ( is_wp_error( $delete_result ) ) {
77 + $this->result = $delete_result;
78 + } else {
79 + $this->result = array( 'success' => true );
80 + }
67 81 }
68 82
69 83 /**
70 84 * Returns the success or failure of the deletion operation
@@ -71,9 +85,7 @@
71 85 *
72 86 * @return array An array containing one key; 'success', which specifies whether the operation was successful.
73 87 */
74 88 protected function result() {
75 - return array(
76 - 'success' => $this->result,
77 - );
89 + return $this->result;
78 90 }
79 91 }