class.wpcom-json-api-get-site-v1-2-endpoint.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. new WPCOM_JSON_API_GET_Site_V1_2_Endpoint( array(
  3. 'description' => 'Get information about a site.',
  4. 'group' => 'sites',
  5. 'stat' => 'sites:X',
  6. 'allowed_if_flagged' => true,
  7. 'method' => 'GET',
  8. 'min_version' => '1.2',
  9. 'path' => '/sites/%s',
  10. 'path_labels' => array(
  11. '$site' => '(int|string) Site ID or domain',
  12. ),
  13. 'query_parameters' => array(
  14. 'context' => false,
  15. ),
  16. 'response_format' => WPCOM_JSON_API_GET_Site_V1_2_Endpoint::$site_format,
  17. 'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/en.blog.wordpress.com/',
  18. ) );
  19. class WPCOM_JSON_API_GET_Site_V1_2_Endpoint extends WPCOM_JSON_API_GET_Site_Endpoint {
  20. public static $site_format = array(
  21. 'ID' => '(int) Site ID',
  22. 'name' => '(string) Title of site',
  23. 'description' => '(string) Tagline or description of site',
  24. 'URL' => '(string) Full URL to the site',
  25. 'capabilities' => '(array) Array of capabilities for the current user on this site.',
  26. 'jetpack' => '(bool) Whether the site is a Jetpack site or not',
  27. 'is_multisite' => '(bool) Whether the site is a Multisite site or not. Always true for WP.com sites.',
  28. 'post_count' => '(int) The number of posts the site has',
  29. 'subscribers_count' => '(int) The number of subscribers the site has',
  30. 'locale' => '(string) Primary locale code of the site',
  31. 'icon' => '(array) An array of icon formats for the site',
  32. 'logo' => '(array) The site logo, set in the Customizer',
  33. 'visible' => '(bool) If this site is visible in the user\'s site list',
  34. 'is_private' => '(bool) If the site is a private site or not',
  35. '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.',
  36. 'is_vip' => '(bool) If the site is a VIP site or not.',
  37. 'is_following' => '(bool) If the current user is subscribed to this site in the reader',
  38. '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/',
  39. 'plan' => '(array) Details of the current plan for this site.',
  40. 'updates' => '(array) An array of available updates for plugins, themes, wordpress, and languages.',
  41. 'jetpack_modules' => '(array) A list of active Jetpack modules.',
  42. 'meta' => '(object) Meta data',
  43. 'quota' => '(array) An array describing how much space a user has left for uploads',
  44. );
  45. function callback( $path = '', $blog_id = 0 ) {
  46. add_filter( 'sites_site_format', array( $this, 'site_format' ) );
  47. return parent::callback( $path, $blog_id );
  48. }
  49. public function site_format( $format ) {
  50. return self::$site_format;
  51. }
  52. }