Skip to content

Site: Add hosting_features to the WPCOM_JSON_API_GET_Site_Endpoint endpoint #43565

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Site: Add hosting_features to the WPCOM_JSON_API_GET_Site_Endpoint endpoint
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
'is_deleted' => '(bool) If the site flagged as deleted.',
'is_a4a_client' => '(bool) If the site is an A4A client site.',
'is_a4a_dev_site' => '(bool) If the site is an A4A dev site.',
'hosting_features' => '(array) Details of the hosting features for the current user on this site.',
);

/**
Expand Down Expand Up @@ -252,6 +253,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
'plan',
'products',
'zendesk_site_meta',
'hosting_features',
);

/**
Expand Down Expand Up @@ -626,6 +628,9 @@ protected function render_response_key( $key, &$response, $is_user_logged_in ) {
case 'is_a4a_dev_site':
$response[ $key ] = $this->site->is_a4a_dev_site();
break;
case 'hosting_features':
$response[ $key ] = $this->site->get_hosting_features();
break;
}

do_action( 'post_render_site_response_key', $key );
Expand Down Expand Up @@ -1002,6 +1007,7 @@ public function decorate_jetpack_response( &$response ) {
unset( $response->plan );
unset( $response->products );
unset( $response->zendesk_site_meta );
unset( $response->hosting_features );
}

// render additional options.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class WPCOM_JSON_API_GET_Site_V1_2_Endpoint extends WPCOM_JSON_API_GET_Site_Endp
'is_deleted' => '(bool) If the site flagged as deleted.',
'is_a4a_client' => '(bool) If the site is an A4A client site.',
'is_a4a_dev_site' => '(bool) If the site is an A4A dev site.',
'hosting_features' => '(array) Details of the hosting features for the current user on this site.',
);

/**
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 @@ -1684,4 +1684,11 @@ abstract public function get_zendesk_site_meta();
* @return bool
*/
abstract public function is_pending_plan();

/**
* Defaults to false instead of returning the hosting features for the current user on this site.
*
* @see class.json-api-site-jetpack-shadow.php on WordPress.com for implementation. Only applicable on WordPress.com.
*/
abstract public function get_hosting_features();
}
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 @@ -731,4 +731,15 @@ public function get_zendesk_site_meta() {
public function is_pending_plan() {
return false;
}

/**
* Defaults to false instead of returning the hosting features for the current user on this site.
*
* @see class.json-api-site-jetpack-shadow.php on WordPress.com for implementation. Only applicable on WordPress.com.
*
* @return bool
*/
public function get_hosting_features() {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this return null / empty array instead? The type is array.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the returned value of the get_plan function.

}
}
Loading