diff options
Diffstat (limited to 'plugins/jetpack/json-endpoints')
4 files changed, 32 insertions, 23 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php index 3ebd3bc1..0f4ea160 100644 --- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php +++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-site-endpoint.php @@ -49,6 +49,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint { protected static $site_options_format = array( 'timezone', 'gmt_offset', + 'blog_public', 'videopress_enabled', 'upgraded_filetypes_enabled', 'login_url', @@ -135,10 +136,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint { return $blog_id; } - // TODO: enable this when we can do so without being interfered with by - // other endpoints that might be wrapping this one. - // Uncomment and see failing test: test_jetpack_site_should_have_true_jetpack_property_via_site_meta - // $this->filter_fields_and_options(); + $this->filter_fields_and_options(); $response = $this->build_current_site_response(); @@ -482,6 +480,9 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint { case 'is_automated_transfer': $options[ $key ] = $site->is_automated_transfer(); break; + case 'blog_public': + $options[ $key ] = $site->get_blog_public(); + break; } } diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php index 8dd17601..3df7bff8 100644 --- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php +++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php @@ -118,10 +118,8 @@ abstract class WPCOM_JSON_API_Post_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint $keys_to_render = array_intersect( $keys_to_render, $limit_to_fields ); } - // always include 'type' because processors require it to validate access - if ( ! in_array( 'type', $keys_to_render ) ) { - array_push( $keys_to_render, 'type' ); - } + // always include some keys because processors require it to validate access + $keys_to_render = array_unique( array_merge( $keys_to_render, array( 'type', 'status', 'password' ) ) ); $response = $this->render_response_keys( $post, $context, $keys_to_render ); diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php index 5aebe8d3..afeb0781 100644 --- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php +++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php @@ -148,7 +148,11 @@ class WPCOM_JSON_API_Site_Settings_Endpoint extends WPCOM_JSON_API_Endpoint { break; case 'settings': - $jetpack_relatedposts_options = Jetpack_Options::get_option( 'relatedposts' ); + $jetpack_relatedposts_options = Jetpack_Options::get_option( 'relatedposts', array() ); + // If the option's enabled key is NOT SET, it is considered enabled by the plugin + if ( ! isset( $jetpack_relatedposts_options['enabled'] ) ) { + $jetpack_relatedposts_options['enabled'] = true; + } if ( method_exists( 'Jetpack', 'is_module_active' ) ) { $jetpack_relatedposts_options[ 'enabled' ] = Jetpack::is_module_active( 'related-posts' ); diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-upload-media-v1-1-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-upload-media-v1-1-endpoint.php index bd34b606..f635f451 100644 --- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-upload-media-v1-1-endpoint.php +++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-upload-media-v1-1-endpoint.php @@ -27,8 +27,12 @@ class WPCOM_JSON_API_Upload_Media_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint return new WP_Error( 'invalid_input', 'No media provided in input.' ); } - // For jetpack sites, we send the media via a different method, because the sync is very different. - $jetpack_sync = Jetpack_Media_Sync::summon( $blog_id ); + $is_jetpack_site = false; + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + // For jetpack sites, we send the media via a different method, because the sync is very different. + $jetpack_sync = Jetpack_Media_Sync::summon( $blog_id ); + $is_jetpack_site = $jetpack_sync->is_jetpack_site(); + } $jetpack_media_files = array(); $other_media_files = array(); @@ -37,7 +41,7 @@ class WPCOM_JSON_API_Upload_Media_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint // We're splitting out videos for Jetpack sites foreach ( $media_files as $media_item ) { - if ( preg_match( '@^video/@', $media_item['type'] ) && $jetpack_sync->is_jetpack_site() ) { + if ( preg_match( '@^video/@', $media_item['type'] ) && $is_jetpack_site ) { $jetpack_media_files[] = $media_item; } else { @@ -46,20 +50,22 @@ class WPCOM_JSON_API_Upload_Media_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint } // New Jetpack / VideoPress media upload processing - if ( count( $jetpack_media_files ) > 0 ) { - add_filter( 'upload_mimes', array( $this, 'allow_video_uploads' ) ); + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + if ( count( $jetpack_media_files ) > 0 ) { + add_filter( 'upload_mimes', array( $this, 'allow_video_uploads' ) ); - $media_items = $jetpack_sync->upload_media( $jetpack_media_files, $this->api ); + $media_items = $jetpack_sync->upload_media( $jetpack_media_files, $this->api ); - $errors = $jetpack_sync->get_errors(); + $errors = $jetpack_sync->get_errors(); - foreach ( $media_items as & $media_item ) { - // More than likely a post has not been created yet, so we pass in the media item we - // got back from the Jetpack site. - $post = (object) $media_item['post']; - $media_item = $this->get_media_item_v1_1( $media_item['ID'], $post, $media_item['file'] ); - } - } + foreach ( $media_items as & $media_item ) { + // More than likely a post has not been created yet, so we pass in the media item we + // got back from the Jetpack site. + $post = (object) $media_item['post']; + $media_item = $this->get_media_item_v1_1( $post->ID, $post, $media_item['file'] ); + } + } + } // Normal WPCOM upload processing if ( count( $other_media_files ) > 0 || count( $media_urls ) > 0 ) { |