Skip to content

Commit 095fc9c

Browse files
authored
Merge pull request #625 from Freemius/develop
Version 2.5.6
2 parents 72c4f4e + 89edbe2 commit 095fc9c

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

includes/class-fs-api.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ function get( $path = '/', $flush = false, $expiration = WP_FS__TIME_24_HOURS_IN
371371
* @param string $url
372372
* @param array $remote_args
373373
*
374-
* @return mixed
374+
* @return array|WP_Error The response array or a WP_Error on failure.
375375
*/
376376
static function remote_request( $url, $remote_args ) {
377377
if ( ! class_exists( 'Freemius_Api_WordPress' ) ) {
@@ -386,8 +386,11 @@ static function remote_request( $url, $remote_args ) {
386386
$response = wp_remote_request( $url, $remote_args );
387387

388388
if (
389-
empty( $response['headers'] ) ||
390-
empty( $response['headers']['x-api-server'] )
389+
is_array( $response ) &&
390+
(
391+
empty( $response['headers'] ) ||
392+
empty( $response['headers']['x-api-server'] )
393+
)
391394
) {
392395
// API is considered blocked if the response doesn't include the `x-api-server` header. When there's no error but this header doesn't exist, the response is usually not in the expected form (e.g., cannot be JSON-decoded).
393396
$response = new WP_Error( 'api_blocked', htmlentities( $response['body'] ) );

includes/sdk/FreemiusWordPress.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,17 @@ private static function ExecuteRequest( $pUrl, &$pWPRemoteArgs ) {
348348
* @param string $pUrl
349349
* @param array $pWPRemoteArgs
350350
*
351-
* @return mixed
351+
* @return array|WP_Error The response array or a WP_Error on failure.
352352
*/
353353
static function RemoteRequest( $pUrl, $pWPRemoteArgs ) {
354354
$response = wp_remote_request( $pUrl, $pWPRemoteArgs );
355355

356356
if (
357-
empty( $response['headers'] ) ||
358-
empty( $response['headers']['x-api-server'] )
357+
is_array( $response ) &&
358+
(
359+
empty( $response['headers'] ) ||
360+
empty( $response['headers']['x-api-server'] )
361+
)
359362
) {
360363
// API is considered blocked if the response doesn't include the `x-api-server` header. When there's no error but this header doesn't exist, the response is usually not in the expected form (e.g., cannot be JSON-decoded).
361364
$response = new WP_Error( 'api_blocked', htmlentities( $response['body'] ) );

start.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @var string
1717
*/
18-
$this_sdk_version = '2.5.5';
18+
$this_sdk_version = '2.5.6';
1919

2020
#region SDK Selection Logic --------------------------------------------------------------------
2121

0 commit comments

Comments
 (0)