← All changes
|
_inc/lib/core-api/class.jetpack-core-api-site-endpoints.php
+6
-5
13.2.4
→
16.3-a.1
View file →
| @@ -5,8 +5,9 @@ | ||
| 5 | 5 | * @package automattic/jetpack |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | use Automattic\Jetpack\Connection\Client; |
| 9 | +use Automattic\Jetpack\Publicize\Publicize; | |
| 9 | 10 | use Automattic\Jetpack\Stats\WPCOM_Stats; |
| 10 | 11 | |
| 11 | 12 | /** |
| 12 | 13 | * This is the endpoint class for `/site` endpoints. |
| @@ -60,16 +61,16 @@ | ||
| 60 | 61 | ); |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | /** |
| 64 | - * Returns the result of `/sites/%s/purchases` endpoint call. | |
| 65 | + * Returns the result of `/upgrades` endpoint call. | |
| 65 | 66 | * |
| 66 | 67 | * @return array of site purchases. |
| 67 | 68 | */ |
| 68 | 69 | public static function get_purchases() { |
| 69 | 70 | // Make the API request. |
| 70 | - $request = sprintf( '/sites/%d/purchases', Jetpack_Options::get_option( 'id' ) ); | |
| 71 | - $response = Client::wpcom_json_api_request_as_blog( $request, '1.1' ); | |
| 71 | + $request = sprintf( '/upgrades?site=%d', Jetpack_Options::get_option( 'id' ) ); | |
| 72 | + $response = Client::wpcom_json_api_request_as_blog( $request, '1.2' ); | |
| 72 | 73 | |
| 73 | 74 | // Bail if there was an error or malformed response. |
| 74 | 75 | if ( is_wp_error( $response ) || ! is_array( $response ) || ! isset( $response['body'] ) ) { |
| 75 | 76 | return self::get_failed_fetch_error(); |
| @@ -252,9 +253,9 @@ | ||
| 252 | 253 | } |
| 253 | 254 | } |
| 254 | 255 | |
| 255 | 256 | // Number of active Publicize connections. |
| 256 | - if ( Jetpack::is_module_active( 'publicize' ) && class_exists( 'Publicize' ) ) { | |
| 257 | + if ( Jetpack::is_module_active( 'publicize' ) && class_exists( Publicize::class ) ) { | |
| 257 | 258 | $publicize = new Publicize(); |
| 258 | 259 | $connections = $publicize->get_all_connections(); |
| 259 | 260 | |
| 260 | 261 | $number_of_connections = 0; |
| @@ -294,9 +295,9 @@ | ||
| 294 | 295 | return rest_ensure_response( |
| 295 | 296 | array( |
| 296 | 297 | 'code' => 'success', |
| 297 | 298 | 'message' => esc_html__( 'Site benefits correctly received.', 'jetpack' ), |
| 298 | - 'data' => wp_json_encode( $benefits ), | |
| 299 | + 'data' => wp_json_encode( $benefits, JSON_UNESCAPED_SLASHES ), | |
| 299 | 300 | ) |
| 300 | 301 | ); |
| 301 | 302 | } |
| 302 | 303 | } |