From 38a5ee82442b3a684a7cffca940de57f3db2c8d0 Mon Sep 17 00:00:00 2001 From: vykes-mac <47489215+vykes-mac@users.noreply.github.com> Date: Wed, 1 May 2024 17:28:53 -0500 Subject: [PATCH] Site Restore: Add `is_deleted` attribute to sites api response to flag deleted sites (#37142) * include a field on the site response to tell if a site is flagged as deleted * changelog --- .../jetpack/changelog/add-site-is-deleted-field | 4 ++++ .../class.wpcom-json-api-get-site-endpoint.php | 5 +++++ .../class.wpcom-json-api-get-site-v1-2-endpoint.php | 1 + .../plugins/jetpack/sal/class.json-api-site-base.php | 7 +++++++ .../jetpack/sal/class.json-api-site-jetpack.php | 11 +++++++++++ 5 files changed, 28 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/add-site-is-deleted-field diff --git a/projects/plugins/jetpack/changelog/add-site-is-deleted-field b/projects/plugins/jetpack/changelog/add-site-is-deleted-field new file mode 100644 index 0000000000000..109bb3967fa0a --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-site-is-deleted-field @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +WordPress.com REST API: exposed is_deleted attribute with sites API response diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php index 9e9664b0c509e..d080b27f7a7c3 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php @@ -83,6 +83,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint { 'was_migration_trial' => '(bool) If the site ever used a migration trial.', 'was_hosting_trial' => '(bool) If the site ever used a hosting trial.', 'wpcom_site_setup' => '(string) The WP.com site setup identifier.', + 'is_deleted' => '(bool) If the site flagged as deleted.', ); /** @@ -116,6 +117,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint { 'is_core_site_editor_enabled', 'is_wpcom_atomic', 'is_wpcom_staging_site', + 'is_deleted', ); /** @@ -615,6 +617,9 @@ protected function render_response_key( $key, &$response, $is_user_logged_in ) { case 'was_upgraded_from_trial': $response[ $key ] = $this->site->was_upgraded_from_trial(); break; + case 'is_deleted': + $response[ $key ] = $this->site->is_deleted(); + break; } do_action( 'post_render_site_response_key', $key ); diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-v1-2-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-v1-2-endpoint.php index ab3040ff43a34..c730c8e5f13c8 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-v1-2-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-v1-2-endpoint.php @@ -77,6 +77,7 @@ class WPCOM_JSON_API_GET_Site_V1_2_Endpoint extends WPCOM_JSON_API_GET_Site_Endp 'was_upgraded_from_trial' => '(bool) If the site ever upgraded to a paid plan from a trial.', 'was_migration_trial' => '(bool) If the site ever used a migration trial.', 'was_hosting_trial' => '(bool) If the site ever used a hosting trial.', + 'is_deleted' => '(bool) If the site flagged as deleted.', ); /** diff --git a/projects/plugins/jetpack/sal/class.json-api-site-base.php b/projects/plugins/jetpack/sal/class.json-api-site-base.php index f60bf13c9fb36..47fa4676f49c9 100644 --- a/projects/plugins/jetpack/sal/class.json-api-site-base.php +++ b/projects/plugins/jetpack/sal/class.json-api-site-base.php @@ -409,6 +409,13 @@ abstract protected function is_a8c_publication( $post_id ); */ abstract public function get_user_interactions(); + /** + * Flag a site as deleted. Not used in Jetpack. + * + * @see class.json-api-site-jetpack.php for implementation. + */ + abstract public function is_deleted(); + /** * Return the user interactions with a site. Not used in Jetpack. * diff --git a/projects/plugins/jetpack/sal/class.json-api-site-jetpack.php b/projects/plugins/jetpack/sal/class.json-api-site-jetpack.php index f7faf48d5b75b..503096efb48ae 100644 --- a/projects/plugins/jetpack/sal/class.json-api-site-jetpack.php +++ b/projects/plugins/jetpack/sal/class.json-api-site-jetpack.php @@ -644,6 +644,17 @@ public function get_user_interactions() { return null; } + /** + * Get site deleted status. Not used in Jetpack. + * + * @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php. + * + * @return bool + */ + public function is_deleted() { + return false; + } + /** * Detect whether a site is WordPress.com Staging Site. Not used in Jetpack. *