Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 38a5ee8

Browse files
authoredMay 1, 2024··
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
1 parent a9a6ead commit 38a5ee8

5 files changed

+28
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: other
3+
4+
WordPress.com REST API: exposed is_deleted attribute with sites API response

‎projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
8383
'was_migration_trial' => '(bool) If the site ever used a migration trial.',
8484
'was_hosting_trial' => '(bool) If the site ever used a hosting trial.',
8585
'wpcom_site_setup' => '(string) The WP.com site setup identifier.',
86+
'is_deleted' => '(bool) If the site flagged as deleted.',
8687
);
8788

8889
/**
@@ -116,6 +117,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
116117
'is_core_site_editor_enabled',
117118
'is_wpcom_atomic',
118119
'is_wpcom_staging_site',
120+
'is_deleted',
119121
);
120122

121123
/**
@@ -615,6 +617,9 @@ protected function render_response_key( $key, &$response, $is_user_logged_in ) {
615617
case 'was_upgraded_from_trial':
616618
$response[ $key ] = $this->site->was_upgraded_from_trial();
617619
break;
620+
case 'is_deleted':
621+
$response[ $key ] = $this->site->is_deleted();
622+
break;
618623
}
619624

620625
do_action( 'post_render_site_response_key', $key );

‎projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-v1-2-endpoint.php

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class WPCOM_JSON_API_GET_Site_V1_2_Endpoint extends WPCOM_JSON_API_GET_Site_Endp
7777
'was_upgraded_from_trial' => '(bool) If the site ever upgraded to a paid plan from a trial.',
7878
'was_migration_trial' => '(bool) If the site ever used a migration trial.',
7979
'was_hosting_trial' => '(bool) If the site ever used a hosting trial.',
80+
'is_deleted' => '(bool) If the site flagged as deleted.',
8081
);
8182

8283
/**

‎projects/plugins/jetpack/sal/class.json-api-site-base.php

+7
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,13 @@ abstract protected function is_a8c_publication( $post_id );
409409
*/
410410
abstract public function get_user_interactions();
411411

412+
/**
413+
* Flag a site as deleted. Not used in Jetpack.
414+
*
415+
* @see class.json-api-site-jetpack.php for implementation.
416+
*/
417+
abstract public function is_deleted();
418+
412419
/**
413420
* Return the user interactions with a site. Not used in Jetpack.
414421
*

‎projects/plugins/jetpack/sal/class.json-api-site-jetpack.php

+11
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,17 @@ public function get_user_interactions() {
644644
return null;
645645
}
646646

647+
/**
648+
* Get site deleted status. Not used in Jetpack.
649+
*
650+
* @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php.
651+
*
652+
* @return bool
653+
*/
654+
public function is_deleted() {
655+
return false;
656+
}
657+
647658
/**
648659
* Detect whether a site is WordPress.com Staging Site. Not used in Jetpack.
649660
*

0 commit comments

Comments
 (0)
Please sign in to comment.