Skip to content

Commit

Permalink
Site Restore: Add is_deleted attribute to sites api response to fla…
Browse files Browse the repository at this point in the history
…g deleted sites (#37142)

* include a field on the site response to tell if a site is flagged as deleted

* changelog
  • Loading branch information
vykes-mac authored May 1, 2024
1 parent a9a6ead commit 38a5ee8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/add-site-is-deleted-field
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

WordPress.com REST API: exposed is_deleted attribute with sites API response
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);

/**
Expand Down Expand Up @@ -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',
);

/**
Expand Down Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);

/**
Expand Down
7 changes: 7 additions & 0 deletions projects/plugins/jetpack/sal/class.json-api-site-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
11 changes: 11 additions & 0 deletions projects/plugins/jetpack/sal/class.json-api-site-jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 38a5ee8

Please sign in to comment.