Skip to content

Commit

Permalink
Add P2 organization identifier to site SAL (#18007)
Browse files Browse the repository at this point in the history
* Add P2 organization identifier to site SAL

Summary: Fixes 1542-gh-p2 by adding P2 `organization_id` to sites' details.

Test Plan:
Sites' info should contain P2 organization_id if requested

```
## cURL
curl "https://[private link].2/me/sites?http_envelope=1&site_visibility=all&include_domain_only=true&site_activity=active&fields=ID,name,organization_id" \
     -H 'Authority: [private link]' \
     -H 'Accept: */*'
```

Reviewers: aerych, #lighthouse_team, migueluy

Reviewed By: #lighthouse_team, migueluy

Subscribers: migueluy

Tags: #touches_jetpack_files

Differential Revision: D53881-code

This commit syncs r217904-wpcom.

* SAL: Add P2 organization identifier (#18011)

* SAL: One more PHPCS update (#18018)

Co-authored-by: Brandon Kraft <[email protected]>
  • Loading branch information
unDemian and kraftbj authored Dec 9, 2020
1 parent 0ff35dd commit c733efd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions json-endpoints/class.wpcom-json-api-get-site-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
'single_user_site' => '(bool) Whether the site is single user. Only returned for WP.com sites and for Jetpack sites with version 3.4 or higher.',
'is_vip' => '(bool) If the site is a VIP site or not.',
'is_following' => '(bool) If the current user is subscribed to this site in the reader',
'organization_id' => '(int) P2 Organization identifier.',
'options' => '(array) An array of options/settings for the blog. Only viewable by users with post editing rights to the site. Note: Post formats is deprecated, please see /sites/$id/post-formats/',
'plan' => '(array) Details of the current plan for this site.',
'updates' => '(array) An array of available updates for plugins, themes, wordpress, and languages.',
Expand Down Expand Up @@ -393,6 +394,11 @@ protected function render_response_key( $key, &$response, $is_user_logged_in ) {
case 'is_multisite' :
$response[ $key ] = $this->site->is_multisite();
break;

case 'organization_id':
$response[ $key ] = $this->site->get_p2_organization_id();
break;

case 'capabilities' :
$response[ $key ] = $this->site->get_capabilities();
break;
Expand Down
9 changes: 9 additions & 0 deletions sal/class.json-api-site-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ public function is_automated_transfer() {

abstract protected function is_wpforteams_site();

/**
* Getter for the p2 organization ID.
*
* @return int
*/
public function get_p2_organization_id() {
return 0; // WPForTeams\Constants\NO_ORG_ID not loaded.
}

public function is_wpcom_atomic() {
return false;
}
Expand Down

0 comments on commit c733efd

Please sign in to comment.