Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Restore: Add is_deleted attribute to sites api response to flag deleted sites #37142

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading