Skip to content

Commit

Permalink
Merge pull request #5 from SparkartGroupInc/fix-uncaught-wp-error
Browse files Browse the repository at this point in the history
catch wp errors on wp_remote_request
  • Loading branch information
localjo committed Aug 20, 2015
2 parents d862d10 + 7bd6630 commit 9b2f21c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions storyteller-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Storyteller Helper
* Plugin URI: https://github.com/SparkartGroupInc/storyteller-helper
* Description: Adds useful features for use with Storyteller.io such as triggering webhooks to clear the Storyteller cache on post updates.
* Version: 1.0.0
* Version: 1.0.1
* Author: Sparkart Group, Inc.
* Author URI: http://sparkart.com
* License: MIT
Expand Down Expand Up @@ -54,10 +54,14 @@ function clear_storyteller_cache($routes_to_clear) {
)
);
$response = wp_remote_request( $url, $args );
$response_body = json_decode($response['body']);
if ($response_body->status == 'ok') {
array_push($routes_cleared, $route);
} elseif ($response_body->status == 'error') {
if( !is_wp_error( $response ) ) {
$response_body = json_decode($response['body']);
if ($response_body->status == 'ok') {
array_push($routes_cleared, $route);
} elseif ($response_body->status == 'error') {
array_push($routes_errored, $route);
}
} else {
array_push($routes_errored, $route);
}
}
Expand Down

0 comments on commit 9b2f21c

Please sign in to comment.