Plugin Directory

Changeset 1541822


Ignore:
Timestamp:
11/28/2016 09:55:13 AM (9 years ago)
Author:
fomo
Message:

Fixed error handling on Wordpress error

Location:
fomo/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fomo/trunk/readme.txt

    r1540626 r1541822  
    102102== Changelog ==
    103103
     104= 1.0.8 =
     105* Fixed error handling on Wordpress error
     106
    104107= 1.0.7 =
    105108* Updated pricing
  • fomo/trunk/woocommerce-plugin-fomo.php

    r1540626 r1541822  
    44Plugin URI: https://www.usefomo.com
    55Description: Fomo displays recent orders on your WooCommerce storefront
    6 Version: 1.0.7
     6Version: 1.0.8
    77Author: fomo
    88Author URI: https://www.usefomo.com
     
    309309
    310310            $response = wp_remote_post($url, $http_args);
    311             if ($response != null) {
    312                 switch ($response['response']['code']) {
    313                     case 200:  # OK
    314                         break;
    315                     case 401:
    316                         // reinitialize key exchange
    317                         fomofwc_init(home_url());
    318                         break;
    319                     default:
    320                         // Unexpected HTTP code: $http_code
    321                         break;
     311            if (is_wp_error($response)) {
     312                // error, CURL not installed, firewall blocked or Fomo server down
     313            } else {
     314                if ($response != null) {
     315                    switch ($response['response']['code']) {
     316                        case 200:  # OK
     317                            break;
     318                        case 401:
     319                            // reinitialize key exchange
     320                            fomofwc_init(home_url());
     321                            break;
     322                        default:
     323                            // Unexpected HTTP code: $http_code
     324                            break;
     325                    }
    322326                }
    323327            }
     
    343347            '&hmac=' . hash_hmac('sha256', $shop_url . $time, $key);
    344348        $response = wp_remote_get($url);
    345         if ($response != null && isset($response['body'])) {
    346             return json_decode($response['body'], true);
     349        if (is_wp_error($response)) {
     350            // error, CURL not installed, firewall blocked or Fomo server down
     351        } else {
     352            if ($response != null && isset($response['body'])) {
     353                return json_decode($response['body'], true);
     354            }
    347355        }
    348356    }
Note: See TracChangeset for help on using the changeset viewer.