summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/class.json-api-endpoints.php')
-rw-r--r--plugins/jetpack/class.json-api-endpoints.php33
1 files changed, 26 insertions, 7 deletions
diff --git a/plugins/jetpack/class.json-api-endpoints.php b/plugins/jetpack/class.json-api-endpoints.php
index 98c17387..48a4c40b 100644
--- a/plugins/jetpack/class.json-api-endpoints.php
+++ b/plugins/jetpack/class.json-api-endpoints.php
@@ -522,6 +522,7 @@ abstract class WPCOM_JSON_API_Endpoint {
'slug' => '(string)',
'description' => '(HTML)',
'post_count' => '(int)',
+ 'feed_url' => '(string)',
'meta' => '(object)',
);
if ( 'category' === $type['type'] ) {
@@ -631,7 +632,7 @@ abstract class WPCOM_JSON_API_Endpoint {
'network' => '(boolean) Whether the plugin can only be activated network wide.',
'autoupdate' => '(boolean) Whether the plugin is auto updated',
'log' => '(array:safehtml) An array of update log strings.',
- 'action_links' => '(array) An array of action links that the plugin uses.',
+ 'action_links' => '(array) An array of action links that the plugin uses.',
);
$return[$key] = (object) $this->cast_and_filter(
$value,
@@ -650,7 +651,9 @@ abstract class WPCOM_JSON_API_Endpoint {
);
break;
case 'plugin_v1_2' :
- $docs = Jetpack_JSON_API_Plugins_Endpoint::$_response_format_v1_2;
+ $docs = class_exists( 'Jetpack_JSON_API_Get_Plugins_v1_2_Endpoint' )
+ ? Jetpack_JSON_API_Get_Plugins_v1_2_Endpoint::$_response_format
+ : Jetpack_JSON_API_Plugins_Endpoint::$_response_format_v1_2;
$return[$key] = (object) $this->cast_and_filter(
$value,
/**
@@ -719,6 +722,14 @@ abstract class WPCOM_JSON_API_Endpoint {
);
$return[$key] = (array) $this->cast_and_filter( $value, $docs, false, $for_output );
break;
+ case 'site_keyring':
+ $docs = array(
+ 'keyring_id' => '(int) Keyring ID',
+ 'service' => '(string) The service name',
+ 'external_user_id' => '(string) External user id for the service'
+ );
+ $return[$key] = (array) $this->cast_and_filter( $value, $docs, false, $for_output );
+ break;
case 'taxonomy':
$docs = array(
'name' => '(string) The taxonomy slug',
@@ -734,7 +745,7 @@ abstract class WPCOM_JSON_API_Endpoint {
default :
$method_name = $type['type'] . '_docs';
- if ( method_exists( WPCOM_JSON_API_Jetpack_Overrides, $method_name ) ) {
+ if ( method_exists( 'WPCOM_JSON_API_Jetpack_Overrides', $method_name ) ) {
$docs = WPCOM_JSON_API_Jetpack_Overrides::$method_name();
}
@@ -1166,6 +1177,12 @@ abstract class WPCOM_JSON_API_Endpoint {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM && ! $is_jetpack ) {
$active_blog = get_active_blog_for_user( $ID );
$site_id = $active_blog->blog_id;
+ if ( $site_id > -1 ) {
+ $site_visible = (
+ -1 != $active_blog->public ||
+ is_private_blog_user( $site_id, get_current_user_id() )
+ );
+ }
$profile_URL = "https://en.gravatar.com/{$login}";
} else {
$profile_URL = 'https://en.gravatar.com/' . md5( strtolower( trim( $email ) ) );
@@ -1197,8 +1214,9 @@ abstract class WPCOM_JSON_API_Endpoint {
'ip_address' => $ip_address, // (string|bool)
);
- if ($site_id > -1) {
- $author['site_ID'] = (int) $site_id;
+ if ( $site_id > -1 ) {
+ $author['site_ID'] = (int) $site_id;
+ $author['site_visible'] = $site_visible;
}
return (object) $author;
@@ -1424,6 +1442,7 @@ abstract class WPCOM_JSON_API_Endpoint {
$response['slug'] = (string) $taxonomy->slug;
$response['description'] = (string) $taxonomy->description;
$response['post_count'] = (int) $taxonomy->count;
+ $response['feed_url'] = get_term_feed_link( $taxonomy->term_id, $taxonomy_type );
if ( is_taxonomy_hierarchical( $taxonomy_type ) ) {
$response['parent'] = (int) $taxonomy->parent;
@@ -1854,9 +1873,9 @@ abstract class WPCOM_JSON_API_Endpoint {
// First check to see if we get a mime-type match by file, otherwise, check to
// see if WordPress supports this file as an image. If neither, then it is not supported.
- if ( ! $this->is_file_supported_for_sideloading( $tmp ) && 'image' === $type && ! file_is_displayable_image( $tmp ) ) {
+ if ( ! $this->is_file_supported_for_sideloading( $tmp ) || 'image' === $type && ! file_is_displayable_image( $tmp ) ) {
@unlink( $tmp );
- return false;
+ return new WP_Error( 'invalid_input', 'Invalid file type.', 403 );
}
// emulate a $_FILES entry