PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
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
← All changes | json-endpoints/class.wpcom-json-api-get-site-endpoint.php +239 -44 12.6.4 → 16.3-a.5 View file →
@@ -1,6 +1,10 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit( 0 );
5 +}
6 +
3 7 new WPCOM_JSON_API_GET_Site_Endpoint(
4 8 array(
5 9 'description' => 'Get information about a site.',
6 10 'group' => 'sites',
@@ -12,8 +16,10 @@
12 16 'path' => '/sites/%s',
13 17 'path_labels' => array(
14 18 '$site' => '(int|string) Site ID or domain',
15 19 ),
20 + 'rest_route' => '/site',
21 + 'rest_min_jp_version' => '15.9',
16 22 'allow_jetpack_site_auth' => true,
17 23
18 24 'allow_fallback_to_jetpack_blog_token' => true,
19 25
@@ -29,8 +35,10 @@
29 35 );
30 36
31 37 /**
32 38 * GET Site endpoint class.
39 + *
40 + * @phan-constructor-used-for-side-effects
33 41 */
34 42 class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
35 43
36 44 /**
@@ -39,8 +47,9 @@
39 47 * @var array $site_format
40 48 */
41 49 public static $site_format = array(
42 50 'ID' => '(int) Site ID',
51 + 'slug' => '(string) Slug of site',
43 52 'name' => '(string) Title of site',
44 53 'description' => '(string) Tagline or description of site',
45 54 'URL' => '(string) Full URL to the site',
46 55 'user_can_manage' => '(bool) The current user can manage this site', // deprecated.
@@ -78,10 +87,24 @@
78 87 'is_wpcom_atomic' => '(bool) If the site is a WP.com Atomic one.',
79 88 'is_wpcom_staging_site' => '(bool) If the site is a WP.com staging site.',
80 89 'user_interactions' => '(array) An array of user interactions with a site.',
81 90 'was_ecommerce_trial' => '(bool) If the site ever used an eCommerce trial.',
91 + 'was_upgraded_from_trial' => '(bool) If the site ever upgraded to a paid plan from a trial.',
82 92 'was_migration_trial' => '(bool) If the site ever used a migration trial.',
93 + 'was_hosting_trial' => '(bool) If the site ever used a hosting trial.',
83 94 'wpcom_site_setup' => '(string) The WP.com site setup identifier.',
95 + 'is_deleted' => '(bool) If the site flagged as deleted.',
96 + 'is_a4a_client' => '(bool) If the site is an A4A client site.',
97 + 'is_a4a_dev_site' => '(bool) If the site is an A4A dev site.',
98 + 'is_garden' => '(bool) If the site is a Garden site.',
99 + 'garden_name' => '(string) The name of the Garden site.',
100 + 'garden_partner' => '(string) The partner of the Garden site.',
101 + 'garden_is_provisioned' => '(bool) If the Garden site is provisioned.',
102 + 'is_wpcom_flex' => '(bool) If the site is a Flex site',
103 + 'big_sky_enabled' => '(bool) Whether the Big Sky AI assistant is enabled for this site.',
104 + 'atomic_email_block' => '(object) State of the block on the site\'s outgoing email, with `status` (`blocked` while a block is active, `at_risk` once it has expired), `reason` and `expires_on` keys, or null when the site has no block history. WordPress.com platform only.',
105 + 'hosting_provider_guess' => '(string) Guess of the hosting provider. WordPress.com platform only; only returned when explicitly requested via the fields parameter.',
106 + '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.',
84 107 );
85 108
86 109 /**
87 110 * No member fields.
@@ -113,8 +136,15 @@
113 136 'is_fse_eligible',
114 137 'is_core_site_editor_enabled',
115 138 'is_wpcom_atomic',
116 139 'is_wpcom_staging_site',
140 + 'is_deleted',
141 + 'is_wpcom_flex',
142 + 'is_a4a_client',
143 + 'is_a4a_dev_site',
144 + 'is_garden',
145 + 'big_sky_enabled',
146 + 'garden_name',
117 147 );
118 148
119 149 /**
120 150 * Site options.
@@ -133,8 +163,9 @@
133 163 'is_redirect',
134 164 'unmapped_url',
135 165 'featured_images_enabled',
136 166 'theme_slug',
167 + 'theme_errors',
137 168 'header_image',
138 169 'background_color',
139 170 'image_default_link_type',
140 171 'image_thumbnail_width',
@@ -194,37 +225,41 @@
194 225 'was_created_with_blank_canvas_design',
195 226 'videopress_storage_used',
196 227 'is_difm_lite_in_progress',
197 228 'difm_lite_site_options',
229 + 'is_gating_business_q1',
230 + 'is_legacy_gating_site',
198 231 'site_intent',
232 + 'site_partner_bundle',
233 + 'onboarding_segment',
199 234 'site_vertical_id',
200 235 'blogging_prompts_settings',
201 236 'launchpad_screen',
202 237 'launchpad_checklist_tasks_statuses',
238 + 'migration_source_site_domain',
203 239 'wpcom_production_blog_id',
204 240 'wpcom_staging_blog_ids',
205 241 'can_blaze',
206 242 'wpcom_site_setup',
207 243 'is_commercial',
244 + 'is_commercial_reasons',
245 + 'wpcom_admin_interface',
246 + 'wpcom_classic_early_release',
247 + 'jetpack_recovery_mode_status',
248 + 'jetpack_sso_require_two_step',
249 + 'apm_enabled',
250 + 'wpcom_ai_launchpad_enabled',
251 + 'wpcom_ai_launchpad_dismissed',
252 + 'wpcom_ai_launchpad_completed',
208 253 );
209 254
210 255 /**
211 - * List of DIFM Lite options to be displayed
212 - *
213 - * @var array $displayed_difm_lite_site_options
214 - */
215 - protected static $displayed_difm_lite_site_options = array(
216 - 'site_category',
217 - 'is_website_content_submitted',
218 - 'selected_page_titles',
219 - );
220 -
221 - /**
222 256 * Jetpack response fields.
223 257 *
224 258 * @var array $jetpack_response_field_additions
225 259 */
226 260 protected static $jetpack_response_field_additions = array(
261 + 'slug',
227 262 'subscribers_count',
228 263 'site_migration',
229 264 'site_owner',
230 265 'is_wpcom_staging_site',
@@ -229,8 +264,18 @@
229 264 'site_owner',
230 265 'is_wpcom_staging_site',
231 266 'was_ecommerce_trial',
232 267 'was_migration_trial',
268 + 'was_hosting_trial',
269 + 'was_upgraded_from_trial',
270 + 'is_a4a_dev_site',
271 + 'is_garden',
272 + 'garden_name',
273 + 'garden_partner',
274 + 'garden_is_provisioned',
275 + 'is_wpcom_flex',
276 + 'big_sky_enabled',
277 + 'atomic_email_block',
233 278 );
234 279
235 280 /**
236 281 * Jetpack response field member additions.
@@ -246,9 +291,9 @@
246 291
247 292 /**
248 293 * Jetpack response option additions.
249 294 *
250 - * @var array $jetpack_response_field_member_additions
295 + * @var array $jetpack_response_option_additions
251 296 */
252 297 protected static $jetpack_response_option_additions = array(
253 298 'publicize_permanently_disabled',
254 299 'ak_vp_bundle_enabled',
@@ -272,8 +317,14 @@
272 317 'blogging_prompts_settings',
273 318 'wpcom_production_blog_id',
274 319 'wpcom_staging_blog_ids',
275 320 'is_commercial',
321 + 'is_commercial_reasons',
322 + 'wpcom_admin_interface',
323 + 'wpcom_classic_early_release',
324 + 'jetpack_recovery_mode_status',
325 + 'jetpack_sso_require_two_step',
326 + 'apm_enabled',
276 327 );
277 328
278 329 /**
279 330 * Current enabled trials.
@@ -282,14 +333,15 @@
282 333 */
283 334 public static $jetpack_enabled_trials = array(
284 335 'was_ecommerce_trial' => 'ecommerce',
285 336 'was_migration_trial' => 'migration',
337 + 'was_hosting_trial' => 'hosting',
286 338 );
287 339
288 340 /**
289 - * Site
341 + * Site.
290 342 *
291 - * @var $site.
343 + * @var SAL_Site $site.
292 344 */
293 345 private $site;
294 346
295 347 /**
@@ -312,10 +364,12 @@
312 364 *
313 365 * /sites/mine
314 366 * /sites/%s -> $blog_id\
315 367 *
316 - * @param string $path - the path.
317 - * @param int $blog_id - the blog ID.
368 + * @param string $path - the path.
369 + * @param int|string $blog_id - the blog ID or the string 'mine'.
370 + *
371 + * @return array|\WP_Error Site response array on success, or WP_Error on failure.
318 372 */
319 373 public function callback( $path = '', $blog_id = 0 ) {
320 374 if ( 'mine' === $blog_id ) {
321 375 $api = WPCOM_JSON_API::init();
@@ -451,8 +505,11 @@
451 505 switch ( $key ) {
452 506 case 'ID':
453 507 $response[ $key ] = $this->site->blog_id;
454 508 break;
509 + case 'slug':
510 + $response[ $key ] = $this->site->get_slug();
511 + break;
455 512 case 'name':
456 513 $response[ $key ] = $this->site->get_name();
457 514 break;
458 515 case 'description':
@@ -558,13 +615,9 @@
558 615 case 'products':
559 616 $response[ $key ] = $this->site->get_products();
560 617 break;
561 618 case 'zendesk_site_meta':
562 - // D59613-code only added this function to the wpcom SAL subclasses. Absent any better idea,
563 - // we'll just omit the key entirely in Jetpack.
564 - if ( is_callable( array( $this->site, 'get_zendesk_site_meta' ) ) ) {
565 - $response[ $key ] = $this->site->get_zendesk_site_meta();
566 - }
619 + $response[ $key ] = $this->site->get_zendesk_site_meta();
567 620 break;
568 621 case 'quota':
569 622 $response[ $key ] = $this->site->get_quota();
570 623 break;
@@ -597,8 +650,60 @@
597 650 break;
598 651 case 'was_migration_trial':
599 652 $response[ $key ] = $this->site->was_trial( self::$jetpack_enabled_trials['was_migration_trial'] );
600 653 break;
654 + case 'was_hosting_trial':
655 + $response[ $key ] = $this->site->was_trial( self::$jetpack_enabled_trials['was_hosting_trial'] );
656 + break;
657 + case 'was_upgraded_from_trial':
658 + $response[ $key ] = $this->site->was_upgraded_from_trial();
659 + break;
660 + case 'is_deleted':
661 + $response[ $key ] = $this->site->is_deleted();
662 + break;
663 + case 'is_a4a_client':
664 + $response[ $key ] = $this->site->is_a4a_client();
665 + break;
666 + case 'is_a4a_dev_site':
667 + $response[ $key ] = $this->site->is_a4a_dev_site();
668 + break;
669 + case 'is_garden':
670 + $response[ $key ] = $this->site->is_garden();
671 + break;
672 + case 'garden_name':
673 + $response[ $key ] = $this->site->garden_name();
674 + break;
675 + case 'garden_partner':
676 + $response[ $key ] = $this->site->garden_partner();
677 + break;
678 + case 'garden_is_provisioned':
679 + $response[ $key ] = $this->site->garden_is_provisioned();
680 + break;
681 + case 'is_wpcom_flex':
682 + $response[ $key ] = $this->site->is_wpcom_flex();
683 + break;
684 + case 'big_sky_enabled':
685 + $response[ $key ] = $this->site->is_big_sky_enabled();
686 + break;
687 + case 'atomic_email_block':
688 + $response[ $key ] = $this->site->get_atomic_email_block();
689 + break;
690 + case 'hosting_provider_guess':
691 + // WordPress.com platform decoration, computed only when explicitly requested
692 + // via `fields` so default `_all` responses are unchanged.
693 + if ( $this->is_wpcom()
694 + && function_exists( 'get_jetpack_hosting_provider' )
695 + && is_array( $this->fields_to_include ) ) {
696 + $response[ $key ] = get_jetpack_hosting_provider( get_current_blog_id() );
697 + }
698 + break;
699 + case 'environment_type':
700 + // WordPress.com platform decoration, computed only when explicitly requested
701 + // via `fields` so default `_all` responses are unchanged.
702 + if ( $this->is_wpcom() && is_array( $this->fields_to_include ) ) {
703 + $response[ $key ] = $this->get_site_environment_type();
704 + }
705 + break;
601 706 }
602 707
603 708 do_action( 'post_render_site_response_key', $key );
604 709 }
@@ -648,8 +753,11 @@
648 753 break;
649 754 case 'theme_slug':
650 755 $options[ $key ] = $site->get_theme_slug();
651 756 break;
757 + case 'theme_errors':
758 + $options[ $key ] = $site->get_theme_errors();
759 + break;
652 760 case 'header_image':
653 761 $options[ $key ] = $site->get_header_image();
654 762 break;
655 763 case 'background_color':
@@ -808,13 +916,9 @@
808 916 case 'import_engine':
809 917 $options[ $key ] = $site->get_import_engine();
810 918 break;
811 919 case 'is_pending_plan':
812 - // D40032-code only added this function to the wpcom SAL subclasses. Absent any better idea,
813 - // we'll just omit the key entirely in Jetpack.
814 - if ( is_callable( array( $site, 'is_pending_plan' ) ) ) {
815 - $options[ $key ] = $site->is_pending_plan();
816 - }
920 + $options[ $key ] = $site->is_pending_plan();
817 921 break;
818 922
819 923 case 'is_wpforteams_site':
820 924 $options[ $key ] = $site->is_wpforteams_site();
@@ -856,25 +960,31 @@
856 960 case 'is_difm_lite_in_progress':
857 961 $options[ $key ] = $site->is_difm_lite_in_progress();
858 962 break;
859 963 case 'difm_lite_site_options':
860 - $difm_lite_options = $site->get_difm_lite_site_options();
861 - $visible_options = self::$displayed_difm_lite_site_options;
862 - $filtered_difm_lite_options = new stdClass();
863 - if ( $difm_lite_options ) {
864 - $filtered_difm_lite_options = array_filter(
865 - $difm_lite_options,
866 - function ( $key ) use ( $visible_options ) {
867 - return in_array( $key, $visible_options, true );
868 - },
869 - ARRAY_FILTER_USE_KEY
870 - );
964 + $difm_lite_site_options = $site->get_difm_lite_site_options();
965 + if ( null !== $difm_lite_site_options ) {
966 + $options[ $key ] = (object) $difm_lite_site_options;
871 967 }
872 - $options[ $key ] = $filtered_difm_lite_options;
873 968 break;
969 + case 'is_gating_business_q1':
970 + $options[ $key ] = $site->is_gating_business_q1();
971 + break;
972 + case 'is_legacy_gating_site':
973 + $options[ $key ] = $site->is_legacy_gating_site();
974 + break;
874 975 case 'site_intent':
875 976 $options[ $key ] = $site->get_site_intent();
876 977 break;
978 + case 'site_partner_bundle':
979 + $options[ $key ] = $site->get_site_partner_bundle();
980 + break;
981 + case 'site_goals':
982 + $options[ $key ] = $site->get_site_goals();
983 + break;
984 + case 'onboarding_segment':
985 + $options[ $key ] = $site->get_onboarding_segment();
986 + break;
877 987 case 'site_vertical_id':
878 988 $options[ $key ] = $site->get_site_vertical_id();
879 989 break;
880 990 case 'blogging_prompts_settings':
@@ -887,8 +997,11 @@
887 997 break;
888 998 case 'launchpad_checklist_tasks_statuses':
889 999 $options[ $key ] = $site->get_launchpad_checklist_tasks_statuses();
890 1000 break;
1001 + case 'migration_source_site_domain':
1002 + $options[ $key ] = $site->get_migration_source_site_domain();
1003 + break;
891 1004 case 'wpcom_production_blog_id':
892 1005 $options[ $key ] = $site->get_wpcom_production_blog_id();
893 1006 break;
894 1007 case 'wpcom_staging_blog_ids':
@@ -902,8 +1015,35 @@
902 1015 break;
903 1016 case 'is_commercial':
904 1017 $options[ $key ] = $site->is_commercial();
905 1018 break;
1019 + case 'is_commercial_reasons':
1020 + $options[ $key ] = $site->get_is_commercial_reasons();
1021 + break;
1022 + case 'wpcom_admin_interface':
1023 + $options[ $key ] = $site->get_wpcom_admin_interface();
1024 + break;
1025 + case 'wpcom_classic_early_release':
1026 + $options[ $key ] = $site->get_wpcom_classic_early_release();
1027 + break;
1028 + case 'jetpack_recovery_mode_status':
1029 + $options[ $key ] = $site->get_jetpack_recovery_mode_status();
1030 + break;
1031 + case 'jetpack_sso_require_two_step':
1032 + $options[ $key ] = $site->get_jetpack_sso_require_two_step();
1033 + break;
1034 + case 'apm_enabled':
1035 + $options[ $key ] = $site->get_apm_enabled();
1036 + break;
1037 + case 'wpcom_ai_launchpad_enabled':
1038 + $options[ $key ] = $site->is_ai_launchpad_enabled();
1039 + break;
1040 + case 'wpcom_ai_launchpad_dismissed':
1041 + $options[ $key ] = $site->is_ai_launchpad_dismissed();
1042 + break;
1043 + case 'wpcom_ai_launchpad_completed':
1044 + $options[ $key ] = $site->is_ai_launchpad_completed();
1045 + break;
906 1046 }
907 1047 }
908 1048
909 1049 return $options;
@@ -935,14 +1075,20 @@
935 1075
936 1076 /**
937 1077 * Apply any WPCOM-only response components to a Jetpack site response.
938 1078 *
939 - * @param array $response - the response.
1079 + * @param object $response - the response.
940 1080 */
941 1081 public function decorate_jetpack_response( &$response ) {
1082 + $this->filter_fields_and_options();
942 1083 $this->site = $this->get_platform()->get_site( $response->ID );
943 1084 switch_to_blog( $this->site->get_id() );
944 1085
1086 + // Allow the SAL site to apply its own overrides to the proxied response.
1087 + if ( method_exists( $this->site, 'decorate_jetpack_response' ) ) {
1088 + $this->site->decorate_jetpack_response( $response ); // @phan-suppress-current-line PhanUndeclaredMethod -- checked via method_exists().
1089 + }
1090 +
945 1091 $wpcom_response = $this->render_response_keys( self::$jetpack_response_field_additions );
946 1092
947 1093 foreach ( $wpcom_response as $key => $value ) {
948 1094 $response->{ $key } = $value;
@@ -947,9 +1093,11 @@
947 1093 foreach ( $wpcom_response as $key => $value ) {
948 1094 $response->{ $key } = $value;
949 1095 }
950 1096
951 - if ( $this->has_user_access() || $this->has_blog_access( $this->api->token_details ) ) {
1097 + $has_site_access = $this->has_user_access() || $this->has_blog_access( $this->api->token_details );
1098 +
1099 + if ( $has_site_access ) {
952 1100 $wpcom_member_response = $this->render_response_keys( self::$jetpack_response_field_member_additions );
953 1101
954 1102 foreach ( $wpcom_member_response as $key => $value ) {
955 1103 $response->{ $key } = $value;
@@ -968,22 +1116,28 @@
968 1116 unset( $response->site_owner );
969 1117 unset( $response->plan );
970 1118 unset( $response->products );
971 1119 unset( $response->zendesk_site_meta );
1120 + unset( $response->atomic_email_block );
972 1121 }
973 1122
974 1123 // render additional options.
975 - if ( $response->options ) {
1124 + if ( isset( $response->options ) && $response->options ) {
976 1125 $wpcom_options_response = $this->render_option_keys( self::$jetpack_response_option_additions );
977 1126
978 1127 // Remove heic from jetpack (and atomic) sites so that the iOS app know to convert the file format into a JPEG.
979 1128 // heic fromat is currently not supported by for uploading.
980 1129 // See https://jetpackp2.wordpress.com/2020/08/19/image-uploads-in-the-wp-ios-app-broken
981 - if ( $this->site->is_jetpack() && isset( $response->options['allowed_file_types'] ) ) {
1130 + if (
1131 + $this->site->is_jetpack()
1132 + && isset( $response->options['allowed_file_types'] )
1133 + && is_array( $response->options['allowed_file_types'] )
1134 + ) {
1135 + $allowed_file_types = (array) $response->options['allowed_file_types'];
982 1136 $remove_file_types = array(
983 1137 'heic',
984 1138 );
985 - $response->options['allowed_file_types'] = array_values( array_diff( $response->options['allowed_file_types'], $remove_file_types ) );
1139 + $response->options['allowed_file_types'] = array_values( array_diff( $allowed_file_types, $remove_file_types ) );
986 1140 }
987 1141
988 1142 foreach ( $wpcom_options_response as $key => $value ) {
989 1143 $response->options[ $key ] = $value;
@@ -989,11 +1143,44 @@
989 1143 $response->options[ $key ] = $value;
990 1144 }
991 1145 }
992 1146
1147 + // WordPress.com platform fields are not part of proxied Jetpack responses;
1148 + // add them only when explicitly requested.
1149 + if ( $this->is_wpcom() && $has_site_access && is_array( $this->fields_to_include ) ) {
1150 + if ( function_exists( 'get_jetpack_hosting_provider' ) && in_array( 'hosting_provider_guess', $this->fields_to_include, true ) ) {
1151 + $response->hosting_provider_guess = get_jetpack_hosting_provider( get_current_blog_id() );
1152 + }
1153 + if ( in_array( 'environment_type', $this->fields_to_include, true ) ) {
1154 + $response->environment_type = $this->get_site_environment_type();
1155 + }
1156 + }
1157 +
993 1158 restore_current_blog();
994 1159 return $response; // possibly no need since it's modified in place.
995 1160 }
1161 +
1162 + /**
1163 + * Whether this request is running on the WordPress.com platform.
1164 + *
1165 + * @return bool
1166 + */
1167 + protected function is_wpcom() {
1168 + return ( new \Automattic\Jetpack\Status\Host() )->is_wpcom_platform();
1169 + }
1170 +
1171 + /**
1172 + * Get the site's synced WP_ENVIRONMENT_TYPE.
1173 + *
1174 + * @return string|null
1175 + */
1176 + protected function get_site_environment_type() {
1177 + if ( function_exists( 'get_blog_option' ) ) {
1178 + return get_blog_option( get_current_blog_id(), 'jetpack_callable_wp_get_environment_type', null );
1179 + }
1180 +
1181 + return get_option( 'jetpack_callable_wp_get_environment_type', null );
1182 + }
996 1183 }
997 1184
998 1185 new WPCOM_JSON_API_List_Post_Formats_Endpoint(
999 1186 array(
@@ -1019,9 +1206,11 @@
1019 1206 )
1020 1207 );
1021 1208
1022 1209 /**
1023 - * List Post Formates endpoint class.
1210 + * List Post Formats endpoint class.
1211 + *
1212 + * @phan-constructor-used-for-side-effects
1024 1213 */
1025 1214 class WPCOM_JSON_API_List_Post_Formats_Endpoint extends WPCOM_JSON_API_Endpoint { // phpcs:ignore
1026 1215 /**
1027 1216 *
@@ -1030,8 +1219,10 @@
1030 1219 * /sites/%s/post-formats -> $blog_id
1031 1220 *
1032 1221 * @param string $path - the path.
1033 1222 * @param int $blog_id - the blog ID.
1223 + *
1224 + * @return array|\WP_Error Array with 'formats' on success, or WP_Error on failure.
1034 1225 */
1035 1226 public function callback( $path = '', $blog_id = 0 ) {
1036 1227 $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
1037 1228 if ( is_wp_error( $blog_id ) ) {
@@ -1085,8 +1276,10 @@
1085 1276 );
1086 1277
1087 1278 /**
1088 1279 * List page templates endpoint class.
1280 + *
1281 + * @phan-constructor-used-for-side-effects
1089 1282 */
1090 1283 class WPCOM_JSON_API_List_Page_Templates_Endpoint extends WPCOM_JSON_API_Endpoint { // phpcs:ignore
1091 1284 /**
1092 1285 *
@@ -1094,8 +1287,10 @@
1094 1287 * /sites/%s/page-templates -> $blog_id
1095 1288 *
1096 1289 * @param string $path - the path.
1097 1290 * @param int $blog_id - the blog ID.
1291 + *
1292 + * @return array|\WP_Error Array with 'templates' on success, or WP_Error on failure.
1098 1293 */
1099 1294 public function callback( $path = '', $blog_id = 0 ) {
1100 1295 $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
1101 1296 if ( is_wp_error( $blog_id ) ) {