← All changes
|
modules/videopress/class-videopress-attachment-metadata.php
+6
-2
13.7.2
→
16.3-beta
View file →
| @@ -6,8 +6,12 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | use Automattic\Jetpack\Connection\Client; |
| 9 | 9 | |
| 10 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 11 | + exit( 0 ); | |
| 12 | +} | |
| 13 | + | |
| 10 | 14 | /** |
| 11 | 15 | * Class Videopress_Attachment_Metadata |
| 12 | 16 | */ |
| 13 | 17 | class Videopress_Attachment_Metadata { |
| @@ -43,9 +47,9 @@ | ||
| 43 | 47 | $values = self::build_wpcom_api_request_values( $post_title, $caption, $post_excerpt, $rating, $display_embed, $allow_download, $privacy_setting ); |
| 44 | 48 | $endpoint = 'videos'; |
| 45 | 49 | $values['guid'] = $guid; |
| 46 | 50 | |
| 47 | - $result = Client::wpcom_json_api_request_as_blog( $endpoint, '2', $args, wp_json_encode( $values ), 'wpcom' ); | |
| 51 | + $result = Client::wpcom_json_api_request_as_blog( $endpoint, '2', $args, wp_json_encode( $values, JSON_UNESCAPED_SLASHES ), 'wpcom' ); | |
| 48 | 52 | |
| 49 | 53 | $validated_result = self::validate_result( $result ); |
| 50 | 54 | if ( true !== $validated_result ) { |
| 51 | 55 | return $validated_result; |
| @@ -131,9 +135,9 @@ | ||
| 131 | 135 | * |
| 132 | 136 | * @param array|\WP_Error $result The result returned by the client. |
| 133 | 137 | */ |
| 134 | 138 | private static function validate_result( $result ) { |
| 135 | - $response_code = isset( $result['response']['code'] ) ? $result['response']['code'] : 500; | |
| 139 | + $response_code = $result['response']['code'] ?? 500; | |
| 136 | 140 | |
| 137 | 141 | // When Client::wpcom_json_api_request_as_blog is called in WPCOM, bad response codes are not converted to WP_Error. |
| 138 | 142 | // Because of this, we need to manually check the response code to check if the direct API call is 200 (OK). |
| 139 | 143 | if ( 200 === $response_code && ! is_wp_error( $result ) ) { |