class.json-api-site-jetpack.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. require_once dirname( __FILE__ ) . '/class.json-api-site-jetpack-base.php';
  3. require_once dirname( __FILE__ ) . '/class.json-api-post-jetpack.php';
  4. // this code runs on Jetpack (.org) sites
  5. class Jetpack_Site extends Abstract_Jetpack_Site {
  6. protected function get_mock_option( $name ) {
  7. return get_option( 'jetpack_'.$name );
  8. }
  9. protected function get_constant( $name ) {
  10. if ( defined( $name) ) {
  11. return constant( $name );
  12. }
  13. return null;
  14. }
  15. protected function main_network_site() {
  16. return network_site_url();
  17. }
  18. protected function wp_version() {
  19. global $wp_version;
  20. return $wp_version;
  21. }
  22. protected function max_upload_size() {
  23. return wp_max_upload_size();
  24. }
  25. protected function wp_memory_limit() {
  26. return wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
  27. }
  28. protected function wp_max_memory_limit() {
  29. return wp_convert_hr_to_bytes( WP_MAX_MEMORY_LIMIT );
  30. }
  31. protected function is_main_network() {
  32. return Jetpack::is_multi_network();
  33. }
  34. public function is_multisite() {
  35. return (bool) is_multisite();
  36. }
  37. public function is_single_user_site() {
  38. return (bool) Jetpack::is_single_user_site();
  39. }
  40. protected function is_version_controlled() {
  41. return Jetpack_Sync_Functions::is_version_controlled();
  42. }
  43. protected function file_system_write_access() {
  44. return Jetpack_Sync_Functions::file_system_write_access();
  45. }
  46. protected function current_theme_supports( $feature_name ) {
  47. return current_theme_supports( $feature_name );
  48. }
  49. protected function get_theme_support( $feature_name ) {
  50. return get_theme_support( $feature_name );
  51. }
  52. public function get_updates() {
  53. return (array) Jetpack::get_updates();
  54. }
  55. function get_id() {
  56. return $this->platform->token->blog_id;
  57. }
  58. function has_videopress() {
  59. // TODO - this only works on wporg site - need to detect videopress option for remote Jetpack site on WPCOM
  60. $videopress = Jetpack_Options::get_option( 'videopress', array() );
  61. if ( isset( $videopress['blog_id'] ) && $videopress['blog_id'] > 0 ) {
  62. return true;
  63. }
  64. return false;
  65. }
  66. function upgraded_filetypes_enabled() {
  67. return true;
  68. }
  69. function is_mapped_domain() {
  70. return true;
  71. }
  72. function is_redirect() {
  73. return false;
  74. }
  75. function is_following() {
  76. return false;
  77. }
  78. function has_wordads() {
  79. return Jetpack::is_module_active( 'wordads' );
  80. }
  81. function get_frame_nonce() {
  82. return false;
  83. }
  84. function is_headstart_fresh() {
  85. return false;
  86. }
  87. function allowed_file_types() {
  88. $allowed_file_types = array();
  89. // http://codex.wordpress.org/Uploading_Files
  90. $mime_types = get_allowed_mime_types();
  91. foreach ( $mime_types as $type => $mime_type ) {
  92. $extras = explode( '|', $type );
  93. foreach ( $extras as $extra ) {
  94. $allowed_file_types[] = $extra;
  95. }
  96. }
  97. return $allowed_file_types;
  98. }
  99. function is_private() {
  100. return false;
  101. }
  102. function get_plan() {
  103. return false;
  104. }
  105. function get_subscribers_count() {
  106. return 0; // special magic fills this in on the WPCOM side
  107. }
  108. function get_capabilities() {
  109. return false;
  110. }
  111. function get_locale() {
  112. return get_bloginfo( 'language' );
  113. }
  114. function is_jetpack() {
  115. return true;
  116. }
  117. public function get_jetpack_version() {
  118. return JETPACK__VERSION;
  119. }
  120. function get_ak_vp_bundle_enabled() {}
  121. function get_jetpack_seo_front_page_description() {
  122. return Jetpack_SEO_Utils::get_front_page_meta_description();
  123. }
  124. function get_jetpack_seo_title_formats() {
  125. return Jetpack_SEO_Titles::get_custom_title_formats();
  126. }
  127. function get_verification_services_codes() {
  128. return get_option( 'verification_services_codes', null );
  129. }
  130. function get_podcasting_archive() {
  131. return null;
  132. }
  133. function is_connected_site() {
  134. return true;
  135. }
  136. function current_user_can( $role ) {
  137. return current_user_can( $role );
  138. }
  139. /**
  140. * Post functions
  141. */
  142. function wrap_post( $post, $context ) {
  143. return new Jetpack_Post( $this, $post, $context );
  144. }
  145. }