PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 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 All 507 releases
← All changes | json-endpoints/class.wpcom-json-api-get-site-endpoint.php +248 -44 12.4.2 → 16.3-beta 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,36 +225,42 @@
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',
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',
253 + 'wpcom_ai_launchpad_no_guidance',
207 254 );
208 255
209 256 /**
210 - * List of DIFM Lite options to be displayed
211 - *
212 - * @var array $displayed_difm_lite_site_options
213 - */
214 - protected static $displayed_difm_lite_site_options = array(
215 - 'site_category',
216 - 'is_website_content_submitted',
217 - 'selected_page_titles',
218 - );
219 -
220 - /**
221 257 * Jetpack response fields.
222 258 *
223 259 * @var array $jetpack_response_field_additions
224 260 */
225 261 protected static $jetpack_response_field_additions = array(
262 + 'slug',
226 263 'subscribers_count',
227 264 'site_migration',
228 265 'site_owner',
229 266 'is_wpcom_staging_site',
@@ -228,8 +265,18 @@
228 265 'site_owner',
229 266 'is_wpcom_staging_site',
230 267 'was_ecommerce_trial',
231 268 'was_migration_trial',
269 + 'was_hosting_trial',
270 + 'was_upgraded_from_trial',
271 + 'is_a4a_dev_site',
272 + 'is_garden',
273 + 'garden_name',
274 + 'garden_partner',
275 + 'garden_is_provisioned',
276 + 'is_wpcom_flex',
277 + 'big_sky_enabled',
278 + 'atomic_email_block',
232 279 );
233 280
234 281 /**
235 282 * Jetpack response field member additions.
@@ -245,9 +292,9 @@
245 292
246 293 /**
247 294 * Jetpack response option additions.
248 295 *
249 - * @var array $jetpack_response_field_member_additions
296 + * @var array $jetpack_response_option_additions
250 297 */
251 298 protected static $jetpack_response_option_additions = array(
252 299 'publicize_permanently_disabled',
253 300 'ak_vp_bundle_enabled',
@@ -270,8 +317,15 @@
270 317 'videopress_storage_used',
271 318 'blogging_prompts_settings',
272 319 'wpcom_production_blog_id',
273 320 'wpcom_staging_blog_ids',
321 + 'is_commercial',
322 + 'is_commercial_reasons',
323 + 'wpcom_admin_interface',
324 + 'wpcom_classic_early_release',
325 + 'jetpack_recovery_mode_status',
326 + 'jetpack_sso_require_two_step',
327 + 'apm_enabled',
274 328 );
275 329
276 330 /**
277 331 * Current enabled trials.
@@ -280,14 +334,15 @@
280 334 */
281 335 public static $jetpack_enabled_trials = array(
282 336 'was_ecommerce_trial' => 'ecommerce',
283 337 'was_migration_trial' => 'migration',
338 + 'was_hosting_trial' => 'hosting',
284 339 );
285 340
286 341 /**
287 - * Site
342 + * Site.
288 343 *
289 - * @var $site.
344 + * @var SAL_Site $site.
290 345 */
291 346 private $site;
292 347
293 348 /**
@@ -310,10 +365,12 @@
310 365 *
311 366 * /sites/mine
312 367 * /sites/%s -> $blog_id\
313 368 *
314 - * @param string $path - the path.
315 - * @param int $blog_id - the blog ID.
369 + * @param string $path - the path.
370 + * @param int|string $blog_id - the blog ID or the string 'mine'.
371 + *
372 + * @return array|\WP_Error Site response array on success, or WP_Error on failure.
316 373 */
317 374 public function callback( $path = '', $blog_id = 0 ) {
318 375 if ( 'mine' === $blog_id ) {
319 376 $api = WPCOM_JSON_API::init();
@@ -449,8 +506,11 @@
449 506 switch ( $key ) {
450 507 case 'ID':
451 508 $response[ $key ] = $this->site->blog_id;
452 509 break;
510 + case 'slug':
511 + $response[ $key ] = $this->site->get_slug();
512 + break;
453 513 case 'name':
454 514 $response[ $key ] = $this->site->get_name();
455 515 break;
456 516 case 'description':
@@ -556,13 +616,9 @@
556 616 case 'products':
557 617 $response[ $key ] = $this->site->get_products();
558 618 break;
559 619 case 'zendesk_site_meta':
560 - // D59613-code only added this function to the wpcom SAL subclasses. Absent any better idea,
561 - // we'll just omit the key entirely in Jetpack.
562 - if ( is_callable( array( $this->site, 'get_zendesk_site_meta' ) ) ) {
563 - $response[ $key ] = $this->site->get_zendesk_site_meta();
564 - }
620 + $response[ $key ] = $this->site->get_zendesk_site_meta();
565 621 break;
566 622 case 'quota':
567 623 $response[ $key ] = $this->site->get_quota();
568 624 break;
@@ -595,8 +651,60 @@
595 651 break;
596 652 case 'was_migration_trial':
597 653 $response[ $key ] = $this->site->was_trial( self::$jetpack_enabled_trials['was_migration_trial'] );
598 654 break;
655 + case 'was_hosting_trial':
656 + $response[ $key ] = $this->site->was_trial( self::$jetpack_enabled_trials['was_hosting_trial'] );
657 + break;
658 + case 'was_upgraded_from_trial':
659 + $response[ $key ] = $this->site->was_upgraded_from_trial();
660 + break;
661 + case 'is_deleted':
662 + $response[ $key ] = $this->site->is_deleted();
663 + break;
664 + case 'is_a4a_client':
665 + $response[ $key ] = $this->site->is_a4a_client();
666 + break;
667 + case 'is_a4a_dev_site':
668 + $response[ $key ] = $this->site->is_a4a_dev_site();
669 + break;
670 + case 'is_garden':
671 + $response[ $key ] = $this->site->is_garden();
672 + break;
673 + case 'garden_name':
674 + $response[ $key ] = $this->site->garden_name();
675 + break;
676 + case 'garden_partner':
677 + $response[ $key ] = $this->site->garden_partner();
678 + break;
679 + case 'garden_is_provisioned':
680 + $response[ $key ] = $this->site->garden_is_provisioned();
681 + break;
682 + case 'is_wpcom_flex':
683 + $response[ $key ] = $this->site->is_wpcom_flex();
684 + break;
685 + case 'big_sky_enabled':
686 + $response[ $key ] = $this->site->is_big_sky_enabled();
687 + break;
688 + case 'atomic_email_block':
689 + $response[ $key ] = $this->site->get_atomic_email_block();
690 + break;
691 + case 'hosting_provider_guess':
692 + // WordPress.com platform decoration, computed only when explicitly requested
693 + // via `fields` so default `_all` responses are unchanged.
694 + if ( $this->is_wpcom()
695 + && function_exists( 'get_jetpack_hosting_provider' )
696 + && is_array( $this->fields_to_include ) ) {
697 + $response[ $key ] = get_jetpack_hosting_provider( get_current_blog_id() );
698 + }
699 + break;
700 + case 'environment_type':
701 + // WordPress.com platform decoration, computed only when explicitly requested
702 + // via `fields` so default `_all` responses are unchanged.
703 + if ( $this->is_wpcom() && is_array( $this->fields_to_include ) ) {
704 + $response[ $key ] = $this->get_site_environment_type();
705 + }
706 + break;
599 707 }
600 708
601 709 do_action( 'post_render_site_response_key', $key );
602 710 }
@@ -646,8 +754,11 @@
646 754 break;
647 755 case 'theme_slug':
648 756 $options[ $key ] = $site->get_theme_slug();
649 757 break;
758 + case 'theme_errors':
759 + $options[ $key ] = $site->get_theme_errors();
760 + break;
650 761 case 'header_image':
651 762 $options[ $key ] = $site->get_header_image();
652 763 break;
653 764 case 'background_color':
@@ -806,13 +917,9 @@
806 917 case 'import_engine':
807 918 $options[ $key ] = $site->get_import_engine();
808 919 break;
809 920 case 'is_pending_plan':
810 - // D40032-code only added this function to the wpcom SAL subclasses. Absent any better idea,
811 - // we'll just omit the key entirely in Jetpack.
812 - if ( is_callable( array( $site, 'is_pending_plan' ) ) ) {
813 - $options[ $key ] = $site->is_pending_plan();
814 - }
921 + $options[ $key ] = $site->is_pending_plan();
815 922 break;
816 923
817 924 case 'is_wpforteams_site':
818 925 $options[ $key ] = $site->is_wpforteams_site();
@@ -854,25 +961,31 @@
854 961 case 'is_difm_lite_in_progress':
855 962 $options[ $key ] = $site->is_difm_lite_in_progress();
856 963 break;
857 964 case 'difm_lite_site_options':
858 - $difm_lite_options = $site->get_difm_lite_site_options();
859 - $visible_options = self::$displayed_difm_lite_site_options;
860 - $filtered_difm_lite_options = new stdClass();
861 - if ( $difm_lite_options ) {
862 - $filtered_difm_lite_options = array_filter(
863 - $difm_lite_options,
864 - function ( $key ) use ( $visible_options ) {
865 - return in_array( $key, $visible_options, true );
866 - },
867 - ARRAY_FILTER_USE_KEY
868 - );
965 + $difm_lite_site_options = $site->get_difm_lite_site_options();
966 + if ( null !== $difm_lite_site_options ) {
967 + $options[ $key ] = (object) $difm_lite_site_options;
869 968 }
870 - $options[ $key ] = $filtered_difm_lite_options;
871 969 break;
970 + case 'is_gating_business_q1':
971 + $options[ $key ] = $site->is_gating_business_q1();
972 + break;
973 + case 'is_legacy_gating_site':
974 + $options[ $key ] = $site->is_legacy_gating_site();
975 + break;
872 976 case 'site_intent':
873 977 $options[ $key ] = $site->get_site_intent();
874 978 break;
979 + case 'site_partner_bundle':
980 + $options[ $key ] = $site->get_site_partner_bundle();
981 + break;
982 + case 'site_goals':
983 + $options[ $key ] = $site->get_site_goals();
984 + break;
985 + case 'onboarding_segment':
986 + $options[ $key ] = $site->get_onboarding_segment();
987 + break;
875 988 case 'site_vertical_id':
876 989 $options[ $key ] = $site->get_site_vertical_id();
877 990 break;
878 991 case 'blogging_prompts_settings':
@@ -885,8 +998,11 @@
885 998 break;
886 999 case 'launchpad_checklist_tasks_statuses':
887 1000 $options[ $key ] = $site->get_launchpad_checklist_tasks_statuses();
888 1001 break;
1002 + case 'migration_source_site_domain':
1003 + $options[ $key ] = $site->get_migration_source_site_domain();
1004 + break;
889 1005 case 'wpcom_production_blog_id':
890 1006 $options[ $key ] = $site->get_wpcom_production_blog_id();
891 1007 break;
892 1008 case 'wpcom_staging_blog_ids':
@@ -897,8 +1013,41 @@
897 1013 break;
898 1014 case 'wpcom_site_setup':
899 1015 $options[ $key ] = $site->get_wpcom_site_setup();
900 1016 break;
1017 + case 'is_commercial':
1018 + $options[ $key ] = $site->is_commercial();
1019 + break;
1020 + case 'is_commercial_reasons':
1021 + $options[ $key ] = $site->get_is_commercial_reasons();
1022 + break;
1023 + case 'wpcom_admin_interface':
1024 + $options[ $key ] = $site->get_wpcom_admin_interface();
1025 + break;
1026 + case 'wpcom_classic_early_release':
1027 + $options[ $key ] = $site->get_wpcom_classic_early_release();
1028 + break;
1029 + case 'jetpack_recovery_mode_status':
1030 + $options[ $key ] = $site->get_jetpack_recovery_mode_status();
1031 + break;
1032 + case 'jetpack_sso_require_two_step':
1033 + $options[ $key ] = $site->get_jetpack_sso_require_two_step();
1034 + break;
1035 + case 'apm_enabled':
1036 + $options[ $key ] = $site->get_apm_enabled();
1037 + break;
1038 + case 'wpcom_ai_launchpad_enabled':
1039 + $options[ $key ] = $site->is_ai_launchpad_enabled();
1040 + break;
1041 + case 'wpcom_ai_launchpad_dismissed':
1042 + $options[ $key ] = $site->is_ai_launchpad_dismissed();
1043 + break;
1044 + case 'wpcom_ai_launchpad_completed':
1045 + $options[ $key ] = $site->is_ai_launchpad_completed();
1046 + break;
1047 + case 'wpcom_ai_launchpad_no_guidance':
1048 + $options[ $key ] = $site->is_ai_launchpad_no_guidance();
1049 + break;
901 1050 }
902 1051 }
903 1052
904 1053 return $options;
@@ -930,14 +1079,20 @@
930 1079
931 1080 /**
932 1081 * Apply any WPCOM-only response components to a Jetpack site response.
933 1082 *
934 - * @param array $response - the response.
1083 + * @param object $response - the response.
935 1084 */
936 1085 public function decorate_jetpack_response( &$response ) {
1086 + $this->filter_fields_and_options();
937 1087 $this->site = $this->get_platform()->get_site( $response->ID );
938 1088 switch_to_blog( $this->site->get_id() );
939 1089
1090 + // Allow the SAL site to apply its own overrides to the proxied response.
1091 + if ( method_exists( $this->site, 'decorate_jetpack_response' ) ) {
1092 + $this->site->decorate_jetpack_response( $response ); // @phan-suppress-current-line PhanUndeclaredMethod -- checked via method_exists().
1093 + }
1094 +
940 1095 $wpcom_response = $this->render_response_keys( self::$jetpack_response_field_additions );
941 1096
942 1097 foreach ( $wpcom_response as $key => $value ) {
943 1098 $response->{ $key } = $value;
@@ -942,9 +1097,11 @@
942 1097 foreach ( $wpcom_response as $key => $value ) {
943 1098 $response->{ $key } = $value;
944 1099 }
945 1100
946 - if ( $this->has_user_access() || $this->has_blog_access( $this->api->token_details ) ) {
1101 + $has_site_access = $this->has_user_access() || $this->has_blog_access( $this->api->token_details );
1102 +
1103 + if ( $has_site_access ) {
947 1104 $wpcom_member_response = $this->render_response_keys( self::$jetpack_response_field_member_additions );
948 1105
949 1106 foreach ( $wpcom_member_response as $key => $value ) {
950 1107 $response->{ $key } = $value;
@@ -963,22 +1120,28 @@
963 1120 unset( $response->site_owner );
964 1121 unset( $response->plan );
965 1122 unset( $response->products );
966 1123 unset( $response->zendesk_site_meta );
1124 + unset( $response->atomic_email_block );
967 1125 }
968 1126
969 1127 // render additional options.
970 - if ( $response->options ) {
1128 + if ( isset( $response->options ) && $response->options ) {
971 1129 $wpcom_options_response = $this->render_option_keys( self::$jetpack_response_option_additions );
972 1130
973 1131 // Remove heic from jetpack (and atomic) sites so that the iOS app know to convert the file format into a JPEG.
974 1132 // heic fromat is currently not supported by for uploading.
975 1133 // See https://jetpackp2.wordpress.com/2020/08/19/image-uploads-in-the-wp-ios-app-broken
976 - if ( $this->site->is_jetpack() && isset( $response->options['allowed_file_types'] ) ) {
1134 + if (
1135 + $this->site->is_jetpack()
1136 + && isset( $response->options['allowed_file_types'] )
1137 + && is_array( $response->options['allowed_file_types'] )
1138 + ) {
1139 + $allowed_file_types = (array) $response->options['allowed_file_types'];
977 1140 $remove_file_types = array(
978 1141 'heic',
979 1142 );
980 - $response->options['allowed_file_types'] = array_values( array_diff( $response->options['allowed_file_types'], $remove_file_types ) );
1143 + $response->options['allowed_file_types'] = array_values( array_diff( $allowed_file_types, $remove_file_types ) );
981 1144 }
982 1145
983 1146 foreach ( $wpcom_options_response as $key => $value ) {
984 1147 $response->options[ $key ] = $value;
@@ -984,11 +1147,44 @@
984 1147 $response->options[ $key ] = $value;
985 1148 }
986 1149 }
987 1150
1151 + // WordPress.com platform fields are not part of proxied Jetpack responses;
1152 + // add them only when explicitly requested.
1153 + if ( $this->is_wpcom() && $has_site_access && is_array( $this->fields_to_include ) ) {
1154 + if ( function_exists( 'get_jetpack_hosting_provider' ) && in_array( 'hosting_provider_guess', $this->fields_to_include, true ) ) {
1155 + $response->hosting_provider_guess = get_jetpack_hosting_provider( get_current_blog_id() );
1156 + }
1157 + if ( in_array( 'environment_type', $this->fields_to_include, true ) ) {
1158 + $response->environment_type = $this->get_site_environment_type();
1159 + }
1160 + }
1161 +
988 1162 restore_current_blog();
989 1163 return $response; // possibly no need since it's modified in place.
990 1164 }
1165 +
1166 + /**
1167 + * Whether this request is running on the WordPress.com platform.
1168 + *
1169 + * @return bool
1170 + */
1171 + protected function is_wpcom() {
1172 + return ( new \Automattic\Jetpack\Status\Host() )->is_wpcom_platform();
1173 + }
1174 +
1175 + /**
1176 + * Get the site's synced WP_ENVIRONMENT_TYPE.
1177 + *
1178 + * @return string|null
1179 + */
1180 + protected function get_site_environment_type() {
1181 + if ( function_exists( 'get_blog_option' ) ) {
1182 + return get_blog_option( get_current_blog_id(), 'jetpack_callable_wp_get_environment_type', null );
1183 + }
1184 +
1185 + return get_option( 'jetpack_callable_wp_get_environment_type', null );
1186 + }
991 1187 }
992 1188
993 1189 new WPCOM_JSON_API_List_Post_Formats_Endpoint(
994 1190 array(
@@ -1014,9 +1210,11 @@
1014 1210 )
1015 1211 );
1016 1212
1017 1213 /**
1018 - * List Post Formates endpoint class.
1214 + * List Post Formats endpoint class.
1215 + *
1216 + * @phan-constructor-used-for-side-effects
1019 1217 */
1020 1218 class WPCOM_JSON_API_List_Post_Formats_Endpoint extends WPCOM_JSON_API_Endpoint { // phpcs:ignore
1021 1219 /**
1022 1220 *
@@ -1025,8 +1223,10 @@
1025 1223 * /sites/%s/post-formats -> $blog_id
1026 1224 *
1027 1225 * @param string $path - the path.
1028 1226 * @param int $blog_id - the blog ID.
1227 + *
1228 + * @return array|\WP_Error Array with 'formats' on success, or WP_Error on failure.
1029 1229 */
1030 1230 public function callback( $path = '', $blog_id = 0 ) {
1031 1231 $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
1032 1232 if ( is_wp_error( $blog_id ) ) {
@@ -1080,8 +1280,10 @@
1080 1280 );
1081 1281
1082 1282 /**
1083 1283 * List page templates endpoint class.
1284 + *
1285 + * @phan-constructor-used-for-side-effects
1084 1286 */
1085 1287 class WPCOM_JSON_API_List_Page_Templates_Endpoint extends WPCOM_JSON_API_Endpoint { // phpcs:ignore
1086 1288 /**
1087 1289 *
@@ -1089,8 +1291,10 @@
1089 1291 * /sites/%s/page-templates -> $blog_id
1090 1292 *
1091 1293 * @param string $path - the path.
1092 1294 * @param int $blog_id - the blog ID.
1295 + *
1296 + * @return array|\WP_Error Array with 'templates' on success, or WP_Error on failure.
1093 1297 */
1094 1298 public function callback( $path = '', $blog_id = 0 ) {
1095 1299 $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
1096 1300 if ( is_wp_error( $blog_id ) ) {