PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
jetpack / json-endpoints / class.wpcom-json-api-get-site-v1-2-endpoint.php

class.wpcom-json-api-get-site-v1-2-endpoint.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.7, at json-endpoints/class.wpcom-json-api-get-site-v1-2-endpoint.php

131 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit( 0 );
5 }
6
7 new WPCOM_JSON_API_GET_Site_V1_2_Endpoint(
8 array(
9 'description' => 'Get information about a site.',
10 'group' => 'sites',
11 'stat' => 'sites:X',
12 'allowed_if_flagged' => true,
13 'method' => 'GET',
14 'min_version' => '1.2',
15 'path' => '/sites/%s',
16 'path_labels' => array(
17 '$site' => '(int|string) Site ID or domain',
18 ),
19 'rest_route' => '/site',
20 'rest_min_jp_version' => '15.9',
21
22 'allow_fallback_to_jetpack_blog_token' => true,
23
24 'query_parameters' => array(
25 'context' => false,
26 'filters' => '(string) Optional. Returns sites that satisfy the given filters only. Example: filters=jetpack,atomic,wpcom',
27 ),
28
29 'response_format' => WPCOM_JSON_API_GET_Site_V1_2_Endpoint::$site_format,
30
31 'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/en.blog.wordpress.com/',
32 )
33 );
34
35 /**
36 * GET Site v1_2 endpoint.
37 *
38 * @phan-constructor-used-for-side-effects
39 */
40 class WPCOM_JSON_API_GET_Site_V1_2_Endpoint extends WPCOM_JSON_API_GET_Site_Endpoint {
41
42 /**
43 * Site format array.
44 *
45 * @var array $site_format
46 */
47 public static $site_format = array(
48 'ID' => '(int) Site ID',
49 'name' => '(string) Title of site',
50 'description' => '(string) Tagline or description of site',
51 'URL' => '(string) Full URL to the site',
52 'capabilities' => '(array) Array of capabilities for the current user on this site.',
53 'jetpack' => '(bool) Whether the site is a Jetpack site or not',
54 'jetpack_connection' => '(bool) Whether the site is connected to WP.com via `jetpack-connection`',
55 'is_multisite' => '(bool) Whether the site is a Multisite site or not. Always true for WP.com sites.',
56 'site_owner' => '(int) User ID of the site owner',
57 'post_count' => '(int) The number of posts the site has',
58 'subscribers_count' => '(int) The number of subscribers the site has',
59 'locale' => '(string) Primary locale code of the site',
60 'icon' => '(array) An array of icon formats for the site',
61 'logo' => '(array) The site logo, set in the Customizer',
62 'visible' => '(bool) If this site is visible in the user\'s site list',
63 'is_private' => '(bool) If the site is a private site or not',
64 'is_coming_soon' => '(bool) If the site is a "coming soon" site or not',
65 '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.',
66 'is_vip' => '(bool) If the site is a VIP site or not.',
67 'is_following' => '(bool) If the current user is subscribed to this site in the reader',
68 'organization_id' => '(int) P2 Organization identifier.',
69 '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/',
70 'plan' => '(array) Details of the current plan for this site.',
71 'products' => '(array) Details of the current products for this site.',
72 'zendesk_site_meta' => '(array) Site meta data for Zendesk.',
73 'updates' => '(array) An array of available updates for plugins, themes, wordpress, and languages.',
74 'jetpack_modules' => '(array) A list of active Jetpack modules.',
75 'meta' => '(object) Meta data',
76 'quota' => '(array) An array describing how much space a user has left for uploads',
77 'launch_status' => '(string) A string describing the launch status of a site',
78 'site_migration' => '(array) Data about any migration into the site.',
79 'is_fse_active' => '(bool) If the site has Full Site Editing active or not.',
80 'is_fse_eligible' => '(bool) If the site is capable of Full Site Editing or not',
81 'is_core_site_editor_enabled' => '(bool) If the site has the core site editor enabled.',
82 'is_wpcom_atomic' => '(bool) If the site is a WP.com Atomic one.',
83 'is_wpcom_staging_site' => '(bool) If the site is a WP.com staging site.',
84 'was_ecommerce_trial' => '(bool) If the site ever used an eCommerce trial.',
85 'was_upgraded_from_trial' => '(bool) If the site ever upgraded to a paid plan from a trial.',
86 'was_migration_trial' => '(bool) If the site ever used a migration trial.',
87 'was_hosting_trial' => '(bool) If the site ever used a hosting trial.',
88 'is_deleted' => '(bool) If the site flagged as deleted.',
89 'is_a4a_client' => '(bool) If the site is an A4A client site.',
90 'is_a4a_dev_site' => '(bool) If the site is an A4A dev site.',
91 'is_garden' => '(bool) If the site is a Garden site.',
92 'hosting_provider_guess' => '(string) Guess of the hosting provider. WordPress.com platform only; only returned when explicitly requested via the fields parameter.',
93 'environment_type' => '(string) The WP_ENVIRONMENT_TYPE of the site as synced by Jetpack. WordPress.com platform only; only returned when explicitly requested via the fields parameter.',
94 );
95
96 /**
97 *
98 * API callback.
99 *
100 * @param string $path - the path.
101 * @param int $blog_id - the blog ID.
102 */
103 public function callback( $path = '', $blog_id = 0 ) {
104 add_filter( 'sites_site_format', array( $this, 'site_format' ) );
105
106 // Site filtering is a WPCOM concept, once a request gets anywhere else it should just be returned
107 if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
108 // Apply filter here, return same error as switch_to_blog_and_validate_user if blog is not found.
109 require_lib( 'site-filter' );
110 $filters = Site_Filter::process_query_arg( $this->query_args() );
111 if ( is_wp_error( $filters ) ) {
112 return $filters;
113 }
114 if ( ! empty( $filters ) && ! Site_Filter::filter_blog( $this->api->get_blog_id( $blog_id ), $filters ) ) {
115 return new WP_Error( 'unknown_blog', 'Unknown blog', 404 );
116 }
117 }
118
119 return parent::callback( $path, $blog_id );
120 }
121
122 /**
123 * Site format.
124 *
125 * @param string $format - the format.
126 */
127 public function site_format( $format ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
128 return self::$site_format;
129 }
130 }
131