Plugin Directory

Changeset 2739316


Ignore:
Timestamp:
06/08/2022 02:26:08 PM (4 years ago)
Author:
wonderpush
Message:

v1.9.12

Location:
wonderpush-web-push-notifications
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wonderpush-web-push-notifications/tags/1.9.12/readme.txt

    r2733809 r2739316  
    55Requires at least: 5.0
    66Tested up to: 6.0
    7 Stable tag: 1.9.11
     7Stable tag: 1.9.12
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9090
    9191== Changelog ==
     92= 1.9.12 =
     93- Bug fixes
     94
    9295= 1.9.11 =
    9396- Tested with WordPress 6.0
  • wonderpush-web-push-notifications/tags/1.9.12/wonderpush-admin-page.css

    r2733809 r2739316  
    4848  margin-right: 5px;
    4949}
     50.metric {
     51  display: inline-block;
     52  text-align: center;
     53  padding: 0 10px;
     54}
     55.metric span {
     56  display: block;
     57}
     58.metric .legend {
     59  font-size: 0.8em;
     60}
     61.metric .number {
     62  font-size: 2em;
     63  padding: 5px;
     64}
    5065.wonderpush-admin-page > header {
    5166  display: flex;
     
    94109  margin-left: 5px;
    95110}
    96 .metric {
    97   display: inline-block;
    98   text-align: center;
    99   padding: 0 10px;
    100 }
    101 .metric span {
    102   display: block;
    103 }
    104 .metric .legend {
    105   font-size: 0.8em;
    106 }
    107 .metric .number {
    108   font-size: 2em;
    109   padding: 5px;
    110 }
    111111.configuration-form {
    112112  text-align: left;
  • wonderpush-web-push-notifications/tags/1.9.12/wonderpush-admin.php

    r2733809 r2739316  
    33
    44class WonderPushAdmin {
    5   const RESOURCES_VERSION = '1.9.11';
     5  const RESOURCES_VERSION = '1.9.12';
    66  const MENU_SLUG = 'wonderpush';
    77  const META_BOX_ID = 'wonderpush_meta_box';
     
    6262    } catch (Exception $e) {
    6363      $app = null;
    64       error_log('Could not get application: ' . $e->getMessage());
     64      WonderPushUtils::log('Could not get application: ' . $e->getMessage());
    6565    }
    6666
     
    8787        : null;
    8888    } catch (Exception $e) {
    89         $all_segments = array();
    90         error_log('Could not get segment list: ' . $e->getMessage());
     89      $all_segments = array();
     90      WonderPushUtils::log('Could not get segment list: ' . $e->getMessage());
    9191    }
    9292
     
    467467      if ($elapsed < self::DEDUPLICATION_SECONDS && $last_sent_title === $title) {
    468468        if (defined('WP_DEBUG') && WP_DEBUG) {
    469           error_log('Discarding duplicate notification: ' . json_encode((object)$params->toArray()));
     469          WonderPushUtils::log('Discarding duplicate notification: ' . json_encode((object)$params->toArray()));
    470470        }
    471471        return;
     
    485485      // Send the notification
    486486      if (defined('WP_DEBUG') && WP_DEBUG) {
    487         error_log('Sending WonderPush notification: ' . json_encode((object)$params->toArray()));
     487        WonderPushUtils::log('Sending WonderPush notification: ' . json_encode((object)$params->toArray()));
    488488      }
    489489      self::update_last_sent_timestamp();
     
    523523      }
    524524    } catch (Exception $e) {
    525       error_log('Caught Exception:' . $e->getMessage());
     525      WonderPushUtils::log('Caught Exception:' . $e->getMessage());
    526526    }
    527527  }
  • wonderpush-web-push-notifications/tags/1.9.12/wonderpush-utils.php

    r2714997 r2739316  
    44class WonderPushUtils {
    55  const DEFAULT_CACHE_TTL = 300;
     6
     7  public static function log($msg) {
     8    $date = date("c");
     9    $prefix = ' [WonderPush] ';
     10    error_log($date . $prefix . $msg);
     11  }
     12
    613  public static function is_wonderpush_installed() {
    714    $settings = WonderPushSettings::getSettings();
     
    110117    }
    111118    if ($urlParametersUpdated) {
    112       error_log('$merged_url_parameters: ' . print_r($merged_url_parameters, true));
    113119      $wp = new WonderPush\WonderPush($access_token);
    114120      $updatedApp = $wp->applications()->patch($app->getId(), array('urlParameters' => (object)$merged_url_parameters));
  • wonderpush-web-push-notifications/tags/1.9.12/wonderpush-woocommerce.php

    r2685041 r2739316  
    9191      $product = wc_get_product( $product_id );
    9292      if (!($product instanceof WC_Product)) return;
    93       $product_json = self::event_payload_from_product($product);
    94       if (!$product_json) return;
     93      $product_array = self::event_payload_from_product($product);
     94      if (!$product_array) return;
     95      $product_json = json_encode($product_array);
     96      $json_last_error = json_last_error();
     97      if ($json_last_error !== JSON_ERROR_NONE) {
     98          if (function_exists('json_last_error_msg')) {
     99              $msg = json_last_error_msg();
     100          } else {
     101              $msg = '';
     102          }
     103          WonderPushUtils::log("Could not json_encode product array. code:" . $json_last_error . " msg:" . $msg . " product_array:" . print_r($product_array, true));
     104      }
     105      if ($product_json === false) return;
    95106      ?>
    96107    <script type="text/javascript">
     
    109120                window.WonderPush.push(function() {
    110121                   window.WonderPush.trackEvent('Exit', {
    111                        object_product: <?php echo json_encode($product_json); ?>,
     122                       object_product: <?php echo $product_json; ?>,
    112123                       string_url: window.location.href,
    113124                   });
     
    157168        if ($meta_value) {
    158169          if (defined('WP_DEBUG') && WP_DEBUG) {
    159             error_log('Discarding duplicate shipping notification');
     170            WonderPushUtils::log('Discarding duplicate shipping notification');
    160171          }
    161172          return;
     
    169180        }
    170181      } catch (Exception $e) {
    171         error_log('Caught Exception:' . $e->getMessage());
     182        WonderPushUtils::log('Caught Exception:' . $e->getMessage());
    172183      }
    173184    }
     
    187198        if ($meta_value) {
    188199          if (defined('WP_DEBUG') && WP_DEBUG) {
    189             error_log('Discarding duplicate order confirmation notification');
     200            WonderPushUtils::log('Discarding duplicate order confirmation notification');
    190201          }
    191202          return;
     
    199210        }
    200211      } catch (Exception $e) {
    201         error_log('Caught Exception:' . $e->getMessage());
     212        WonderPushUtils::log('Caught Exception:' . $e->getMessage());
    202213      }
    203214    }
     
    250261      // Send the notification
    251262      if (defined('WP_DEBUG') && WP_DEBUG) {
    252         error_log('Sending WonderPush notification: ' . json_encode((object)$params->toArray()));
     263        WonderPushUtils::log('Sending WonderPush notification: ' . json_encode((object)$params->toArray()));
    253264      }
    254265      $wonderPushClient = new \WonderPush\WonderPush($access_token);
     
    258269        return true;
    259270      } else {
    260         error_log('Could not send WonderPush order confirmation notification.');
     271        WonderPushUtils::log('Could not send WonderPush order confirmation notification.');
    261272        return false;
    262273      }
    263274    } catch (Exception $e) {
    264       error_log('Caught Exception:' . $e->getMessage());
     275      WonderPushUtils::log('Caught Exception:' . $e->getMessage());
    265276      return false;
    266277    }
     
    403414      ), WonderPushUtils::get_user_id());
    404415    } catch (Exception $e) {
    405       error_log('Could not set cart reminder properties: ' . $e->getMessage());
     416      WonderPushUtils::log('Could not set cart reminder properties: ' . $e->getMessage());
    406417    }
    407418  }
    408419
    409420  protected static function sanitize($str) {
     421      if (!is_string($str)) return null;
    410422      if (!$str) return $str;
    411423      $html_entity_decode_flags = ENT_QUOTES;
     
    444456      }
    445457    }
    446 
     458    $currency = null;
     459    if (function_exists('get_woocommerce_currency')) {
     460      $currency = get_woocommerce_currency();
     461    }
    447462    return array(
    448463        'string_type' => 'Product',
    449         'string_image' => $pictureUrl ?: null,
     464        'string_image' => $pictureUrl && is_string($pictureUrl) ? $pictureUrl : null,
    450465        'string_name' => $product->get_name() ? self::sanitize($product->get_name()): null,
    451466        'string_description' => $product->get_description() ? self::sanitize($product->get_description()) : null,
    452         'string_sku' => $product->get_sku() ?: null,
     467        'string_sku' => $product->get_sku() && is_string($product->get_sku()) ? $product->get_sku() : null,
    453468        'object_offers' => array(
    454469            'string_type' => 'Offer',
    455470            'float_price' => (float)$product->get_price(),
    456             'string_priceCurrency' => get_woocommerce_currency() ?: null,
    457             'string_url' => $product->get_permalink() ?: null,
     471            'string_priceCurrency' => $currency && is_string($currency) ? $currency : null,
     472            'string_url' => $product->get_permalink() && is_string($product->get_permalink()) ? $product->get_permalink() : null,
    458473            'string_availability' => $availability,
    459474        )
  • wonderpush-web-push-notifications/tags/1.9.12/wonderpush.php

    r2733809 r2739316  
    88Author: WonderPush
    99Author URI: https://www.wonderpush.com/
    10 Version: 1.9.11
     10Version: 1.9.12
    1111License: GPLv2 or later
    1212*/
  • wonderpush-web-push-notifications/trunk/readme.txt

    r2733809 r2739316  
    55Requires at least: 5.0
    66Tested up to: 6.0
    7 Stable tag: 1.9.11
     7Stable tag: 1.9.12
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9090
    9191== Changelog ==
     92= 1.9.12 =
     93- Bug fixes
     94
    9295= 1.9.11 =
    9396- Tested with WordPress 6.0
  • wonderpush-web-push-notifications/trunk/wonderpush-admin-page.css

    r2733809 r2739316  
    4848  margin-right: 5px;
    4949}
     50.metric {
     51  display: inline-block;
     52  text-align: center;
     53  padding: 0 10px;
     54}
     55.metric span {
     56  display: block;
     57}
     58.metric .legend {
     59  font-size: 0.8em;
     60}
     61.metric .number {
     62  font-size: 2em;
     63  padding: 5px;
     64}
    5065.wonderpush-admin-page > header {
    5166  display: flex;
     
    94109  margin-left: 5px;
    95110}
    96 .metric {
    97   display: inline-block;
    98   text-align: center;
    99   padding: 0 10px;
    100 }
    101 .metric span {
    102   display: block;
    103 }
    104 .metric .legend {
    105   font-size: 0.8em;
    106 }
    107 .metric .number {
    108   font-size: 2em;
    109   padding: 5px;
    110 }
    111111.configuration-form {
    112112  text-align: left;
  • wonderpush-web-push-notifications/trunk/wonderpush-admin.php

    r2733809 r2739316  
    33
    44class WonderPushAdmin {
    5   const RESOURCES_VERSION = '1.9.11';
     5  const RESOURCES_VERSION = '1.9.12';
    66  const MENU_SLUG = 'wonderpush';
    77  const META_BOX_ID = 'wonderpush_meta_box';
     
    6262    } catch (Exception $e) {
    6363      $app = null;
    64       error_log('Could not get application: ' . $e->getMessage());
     64      WonderPushUtils::log('Could not get application: ' . $e->getMessage());
    6565    }
    6666
     
    8787        : null;
    8888    } catch (Exception $e) {
    89         $all_segments = array();
    90         error_log('Could not get segment list: ' . $e->getMessage());
     89      $all_segments = array();
     90      WonderPushUtils::log('Could not get segment list: ' . $e->getMessage());
    9191    }
    9292
     
    467467      if ($elapsed < self::DEDUPLICATION_SECONDS && $last_sent_title === $title) {
    468468        if (defined('WP_DEBUG') && WP_DEBUG) {
    469           error_log('Discarding duplicate notification: ' . json_encode((object)$params->toArray()));
     469          WonderPushUtils::log('Discarding duplicate notification: ' . json_encode((object)$params->toArray()));
    470470        }
    471471        return;
     
    485485      // Send the notification
    486486      if (defined('WP_DEBUG') && WP_DEBUG) {
    487         error_log('Sending WonderPush notification: ' . json_encode((object)$params->toArray()));
     487        WonderPushUtils::log('Sending WonderPush notification: ' . json_encode((object)$params->toArray()));
    488488      }
    489489      self::update_last_sent_timestamp();
     
    523523      }
    524524    } catch (Exception $e) {
    525       error_log('Caught Exception:' . $e->getMessage());
     525      WonderPushUtils::log('Caught Exception:' . $e->getMessage());
    526526    }
    527527  }
  • wonderpush-web-push-notifications/trunk/wonderpush-utils.php

    r2714997 r2739316  
    44class WonderPushUtils {
    55  const DEFAULT_CACHE_TTL = 300;
     6
     7  public static function log($msg) {
     8    $date = date("c");
     9    $prefix = ' [WonderPush] ';
     10    error_log($date . $prefix . $msg);
     11  }
     12
    613  public static function is_wonderpush_installed() {
    714    $settings = WonderPushSettings::getSettings();
     
    110117    }
    111118    if ($urlParametersUpdated) {
    112       error_log('$merged_url_parameters: ' . print_r($merged_url_parameters, true));
    113119      $wp = new WonderPush\WonderPush($access_token);
    114120      $updatedApp = $wp->applications()->patch($app->getId(), array('urlParameters' => (object)$merged_url_parameters));
  • wonderpush-web-push-notifications/trunk/wonderpush-woocommerce.php

    r2685041 r2739316  
    9191      $product = wc_get_product( $product_id );
    9292      if (!($product instanceof WC_Product)) return;
    93       $product_json = self::event_payload_from_product($product);
    94       if (!$product_json) return;
     93      $product_array = self::event_payload_from_product($product);
     94      if (!$product_array) return;
     95      $product_json = json_encode($product_array);
     96      $json_last_error = json_last_error();
     97      if ($json_last_error !== JSON_ERROR_NONE) {
     98          if (function_exists('json_last_error_msg')) {
     99              $msg = json_last_error_msg();
     100          } else {
     101              $msg = '';
     102          }
     103          WonderPushUtils::log("Could not json_encode product array. code:" . $json_last_error . " msg:" . $msg . " product_array:" . print_r($product_array, true));
     104      }
     105      if ($product_json === false) return;
    95106      ?>
    96107    <script type="text/javascript">
     
    109120                window.WonderPush.push(function() {
    110121                   window.WonderPush.trackEvent('Exit', {
    111                        object_product: <?php echo json_encode($product_json); ?>,
     122                       object_product: <?php echo $product_json; ?>,
    112123                       string_url: window.location.href,
    113124                   });
     
    157168        if ($meta_value) {
    158169          if (defined('WP_DEBUG') && WP_DEBUG) {
    159             error_log('Discarding duplicate shipping notification');
     170            WonderPushUtils::log('Discarding duplicate shipping notification');
    160171          }
    161172          return;
     
    169180        }
    170181      } catch (Exception $e) {
    171         error_log('Caught Exception:' . $e->getMessage());
     182        WonderPushUtils::log('Caught Exception:' . $e->getMessage());
    172183      }
    173184    }
     
    187198        if ($meta_value) {
    188199          if (defined('WP_DEBUG') && WP_DEBUG) {
    189             error_log('Discarding duplicate order confirmation notification');
     200            WonderPushUtils::log('Discarding duplicate order confirmation notification');
    190201          }
    191202          return;
     
    199210        }
    200211      } catch (Exception $e) {
    201         error_log('Caught Exception:' . $e->getMessage());
     212        WonderPushUtils::log('Caught Exception:' . $e->getMessage());
    202213      }
    203214    }
     
    250261      // Send the notification
    251262      if (defined('WP_DEBUG') && WP_DEBUG) {
    252         error_log('Sending WonderPush notification: ' . json_encode((object)$params->toArray()));
     263        WonderPushUtils::log('Sending WonderPush notification: ' . json_encode((object)$params->toArray()));
    253264      }
    254265      $wonderPushClient = new \WonderPush\WonderPush($access_token);
     
    258269        return true;
    259270      } else {
    260         error_log('Could not send WonderPush order confirmation notification.');
     271        WonderPushUtils::log('Could not send WonderPush order confirmation notification.');
    261272        return false;
    262273      }
    263274    } catch (Exception $e) {
    264       error_log('Caught Exception:' . $e->getMessage());
     275      WonderPushUtils::log('Caught Exception:' . $e->getMessage());
    265276      return false;
    266277    }
     
    403414      ), WonderPushUtils::get_user_id());
    404415    } catch (Exception $e) {
    405       error_log('Could not set cart reminder properties: ' . $e->getMessage());
     416      WonderPushUtils::log('Could not set cart reminder properties: ' . $e->getMessage());
    406417    }
    407418  }
    408419
    409420  protected static function sanitize($str) {
     421      if (!is_string($str)) return null;
    410422      if (!$str) return $str;
    411423      $html_entity_decode_flags = ENT_QUOTES;
     
    444456      }
    445457    }
    446 
     458    $currency = null;
     459    if (function_exists('get_woocommerce_currency')) {
     460      $currency = get_woocommerce_currency();
     461    }
    447462    return array(
    448463        'string_type' => 'Product',
    449         'string_image' => $pictureUrl ?: null,
     464        'string_image' => $pictureUrl && is_string($pictureUrl) ? $pictureUrl : null,
    450465        'string_name' => $product->get_name() ? self::sanitize($product->get_name()): null,
    451466        'string_description' => $product->get_description() ? self::sanitize($product->get_description()) : null,
    452         'string_sku' => $product->get_sku() ?: null,
     467        'string_sku' => $product->get_sku() && is_string($product->get_sku()) ? $product->get_sku() : null,
    453468        'object_offers' => array(
    454469            'string_type' => 'Offer',
    455470            'float_price' => (float)$product->get_price(),
    456             'string_priceCurrency' => get_woocommerce_currency() ?: null,
    457             'string_url' => $product->get_permalink() ?: null,
     471            'string_priceCurrency' => $currency && is_string($currency) ? $currency : null,
     472            'string_url' => $product->get_permalink() && is_string($product->get_permalink()) ? $product->get_permalink() : null,
    458473            'string_availability' => $availability,
    459474        )
  • wonderpush-web-push-notifications/trunk/wonderpush.php

    r2733809 r2739316  
    88Author: WonderPush
    99Author URI: https://www.wonderpush.com/
    10 Version: 1.9.11
     10Version: 1.9.12
    1111License: GPLv2 or later
    1212*/
Note: See TracChangeset for help on using the changeset viewer.