Changeset 2739316
- Timestamp:
- 06/08/2022 02:26:08 PM (4 years ago)
- Location:
- wonderpush-web-push-notifications
- Files:
-
- 12 edited
- 1 copied
-
tags/1.9.12 (copied) (copied from wonderpush-web-push-notifications/trunk)
-
tags/1.9.12/readme.txt (modified) (2 diffs)
-
tags/1.9.12/wonderpush-admin-page.css (modified) (2 diffs)
-
tags/1.9.12/wonderpush-admin.php (modified) (6 diffs)
-
tags/1.9.12/wonderpush-utils.php (modified) (2 diffs)
-
tags/1.9.12/wonderpush-woocommerce.php (modified) (10 diffs)
-
tags/1.9.12/wonderpush.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wonderpush-admin-page.css (modified) (2 diffs)
-
trunk/wonderpush-admin.php (modified) (6 diffs)
-
trunk/wonderpush-utils.php (modified) (2 diffs)
-
trunk/wonderpush-woocommerce.php (modified) (10 diffs)
-
trunk/wonderpush.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wonderpush-web-push-notifications/tags/1.9.12/readme.txt
r2733809 r2739316 5 5 Requires at least: 5.0 6 6 Tested up to: 6.0 7 Stable tag: 1.9.1 17 Stable tag: 1.9.12 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 90 90 91 91 == Changelog == 92 = 1.9.12 = 93 - Bug fixes 94 92 95 = 1.9.11 = 93 96 - Tested with WordPress 6.0 -
wonderpush-web-push-notifications/tags/1.9.12/wonderpush-admin-page.css
r2733809 r2739316 48 48 margin-right: 5px; 49 49 } 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 } 50 65 .wonderpush-admin-page > header { 51 66 display: flex; … … 94 109 margin-left: 5px; 95 110 } 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 }111 111 .configuration-form { 112 112 text-align: left; -
wonderpush-web-push-notifications/tags/1.9.12/wonderpush-admin.php
r2733809 r2739316 3 3 4 4 class WonderPushAdmin { 5 const RESOURCES_VERSION = '1.9.1 1';5 const RESOURCES_VERSION = '1.9.12'; 6 6 const MENU_SLUG = 'wonderpush'; 7 7 const META_BOX_ID = 'wonderpush_meta_box'; … … 62 62 } catch (Exception $e) { 63 63 $app = null; 64 error_log('Could not get application: ' . $e->getMessage());64 WonderPushUtils::log('Could not get application: ' . $e->getMessage()); 65 65 } 66 66 … … 87 87 : null; 88 88 } 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()); 91 91 } 92 92 … … 467 467 if ($elapsed < self::DEDUPLICATION_SECONDS && $last_sent_title === $title) { 468 468 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())); 470 470 } 471 471 return; … … 485 485 // Send the notification 486 486 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())); 488 488 } 489 489 self::update_last_sent_timestamp(); … … 523 523 } 524 524 } catch (Exception $e) { 525 error_log('Caught Exception:' . $e->getMessage());525 WonderPushUtils::log('Caught Exception:' . $e->getMessage()); 526 526 } 527 527 } -
wonderpush-web-push-notifications/tags/1.9.12/wonderpush-utils.php
r2714997 r2739316 4 4 class WonderPushUtils { 5 5 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 6 13 public static function is_wonderpush_installed() { 7 14 $settings = WonderPushSettings::getSettings(); … … 110 117 } 111 118 if ($urlParametersUpdated) { 112 error_log('$merged_url_parameters: ' . print_r($merged_url_parameters, true));113 119 $wp = new WonderPush\WonderPush($access_token); 114 120 $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 91 91 $product = wc_get_product( $product_id ); 92 92 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; 95 106 ?> 96 107 <script type="text/javascript"> … … 109 120 window.WonderPush.push(function() { 110 121 window.WonderPush.trackEvent('Exit', { 111 object_product: <?php echo json_encode($product_json); ?>,122 object_product: <?php echo $product_json; ?>, 112 123 string_url: window.location.href, 113 124 }); … … 157 168 if ($meta_value) { 158 169 if (defined('WP_DEBUG') && WP_DEBUG) { 159 error_log('Discarding duplicate shipping notification');170 WonderPushUtils::log('Discarding duplicate shipping notification'); 160 171 } 161 172 return; … … 169 180 } 170 181 } catch (Exception $e) { 171 error_log('Caught Exception:' . $e->getMessage());182 WonderPushUtils::log('Caught Exception:' . $e->getMessage()); 172 183 } 173 184 } … … 187 198 if ($meta_value) { 188 199 if (defined('WP_DEBUG') && WP_DEBUG) { 189 error_log('Discarding duplicate order confirmation notification');200 WonderPushUtils::log('Discarding duplicate order confirmation notification'); 190 201 } 191 202 return; … … 199 210 } 200 211 } catch (Exception $e) { 201 error_log('Caught Exception:' . $e->getMessage());212 WonderPushUtils::log('Caught Exception:' . $e->getMessage()); 202 213 } 203 214 } … … 250 261 // Send the notification 251 262 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())); 253 264 } 254 265 $wonderPushClient = new \WonderPush\WonderPush($access_token); … … 258 269 return true; 259 270 } else { 260 error_log('Could not send WonderPush order confirmation notification.');271 WonderPushUtils::log('Could not send WonderPush order confirmation notification.'); 261 272 return false; 262 273 } 263 274 } catch (Exception $e) { 264 error_log('Caught Exception:' . $e->getMessage());275 WonderPushUtils::log('Caught Exception:' . $e->getMessage()); 265 276 return false; 266 277 } … … 403 414 ), WonderPushUtils::get_user_id()); 404 415 } 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()); 406 417 } 407 418 } 408 419 409 420 protected static function sanitize($str) { 421 if (!is_string($str)) return null; 410 422 if (!$str) return $str; 411 423 $html_entity_decode_flags = ENT_QUOTES; … … 444 456 } 445 457 } 446 458 $currency = null; 459 if (function_exists('get_woocommerce_currency')) { 460 $currency = get_woocommerce_currency(); 461 } 447 462 return array( 448 463 'string_type' => 'Product', 449 'string_image' => $pictureUrl ?: null,464 'string_image' => $pictureUrl && is_string($pictureUrl) ? $pictureUrl : null, 450 465 'string_name' => $product->get_name() ? self::sanitize($product->get_name()): null, 451 466 '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, 453 468 'object_offers' => array( 454 469 'string_type' => 'Offer', 455 470 '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, 458 473 'string_availability' => $availability, 459 474 ) -
wonderpush-web-push-notifications/tags/1.9.12/wonderpush.php
r2733809 r2739316 8 8 Author: WonderPush 9 9 Author URI: https://www.wonderpush.com/ 10 Version: 1.9.1 110 Version: 1.9.12 11 11 License: GPLv2 or later 12 12 */ -
wonderpush-web-push-notifications/trunk/readme.txt
r2733809 r2739316 5 5 Requires at least: 5.0 6 6 Tested up to: 6.0 7 Stable tag: 1.9.1 17 Stable tag: 1.9.12 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 90 90 91 91 == Changelog == 92 = 1.9.12 = 93 - Bug fixes 94 92 95 = 1.9.11 = 93 96 - Tested with WordPress 6.0 -
wonderpush-web-push-notifications/trunk/wonderpush-admin-page.css
r2733809 r2739316 48 48 margin-right: 5px; 49 49 } 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 } 50 65 .wonderpush-admin-page > header { 51 66 display: flex; … … 94 109 margin-left: 5px; 95 110 } 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 }111 111 .configuration-form { 112 112 text-align: left; -
wonderpush-web-push-notifications/trunk/wonderpush-admin.php
r2733809 r2739316 3 3 4 4 class WonderPushAdmin { 5 const RESOURCES_VERSION = '1.9.1 1';5 const RESOURCES_VERSION = '1.9.12'; 6 6 const MENU_SLUG = 'wonderpush'; 7 7 const META_BOX_ID = 'wonderpush_meta_box'; … … 62 62 } catch (Exception $e) { 63 63 $app = null; 64 error_log('Could not get application: ' . $e->getMessage());64 WonderPushUtils::log('Could not get application: ' . $e->getMessage()); 65 65 } 66 66 … … 87 87 : null; 88 88 } 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()); 91 91 } 92 92 … … 467 467 if ($elapsed < self::DEDUPLICATION_SECONDS && $last_sent_title === $title) { 468 468 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())); 470 470 } 471 471 return; … … 485 485 // Send the notification 486 486 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())); 488 488 } 489 489 self::update_last_sent_timestamp(); … … 523 523 } 524 524 } catch (Exception $e) { 525 error_log('Caught Exception:' . $e->getMessage());525 WonderPushUtils::log('Caught Exception:' . $e->getMessage()); 526 526 } 527 527 } -
wonderpush-web-push-notifications/trunk/wonderpush-utils.php
r2714997 r2739316 4 4 class WonderPushUtils { 5 5 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 6 13 public static function is_wonderpush_installed() { 7 14 $settings = WonderPushSettings::getSettings(); … … 110 117 } 111 118 if ($urlParametersUpdated) { 112 error_log('$merged_url_parameters: ' . print_r($merged_url_parameters, true));113 119 $wp = new WonderPush\WonderPush($access_token); 114 120 $updatedApp = $wp->applications()->patch($app->getId(), array('urlParameters' => (object)$merged_url_parameters)); -
wonderpush-web-push-notifications/trunk/wonderpush-woocommerce.php
r2685041 r2739316 91 91 $product = wc_get_product( $product_id ); 92 92 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; 95 106 ?> 96 107 <script type="text/javascript"> … … 109 120 window.WonderPush.push(function() { 110 121 window.WonderPush.trackEvent('Exit', { 111 object_product: <?php echo json_encode($product_json); ?>,122 object_product: <?php echo $product_json; ?>, 112 123 string_url: window.location.href, 113 124 }); … … 157 168 if ($meta_value) { 158 169 if (defined('WP_DEBUG') && WP_DEBUG) { 159 error_log('Discarding duplicate shipping notification');170 WonderPushUtils::log('Discarding duplicate shipping notification'); 160 171 } 161 172 return; … … 169 180 } 170 181 } catch (Exception $e) { 171 error_log('Caught Exception:' . $e->getMessage());182 WonderPushUtils::log('Caught Exception:' . $e->getMessage()); 172 183 } 173 184 } … … 187 198 if ($meta_value) { 188 199 if (defined('WP_DEBUG') && WP_DEBUG) { 189 error_log('Discarding duplicate order confirmation notification');200 WonderPushUtils::log('Discarding duplicate order confirmation notification'); 190 201 } 191 202 return; … … 199 210 } 200 211 } catch (Exception $e) { 201 error_log('Caught Exception:' . $e->getMessage());212 WonderPushUtils::log('Caught Exception:' . $e->getMessage()); 202 213 } 203 214 } … … 250 261 // Send the notification 251 262 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())); 253 264 } 254 265 $wonderPushClient = new \WonderPush\WonderPush($access_token); … … 258 269 return true; 259 270 } else { 260 error_log('Could not send WonderPush order confirmation notification.');271 WonderPushUtils::log('Could not send WonderPush order confirmation notification.'); 261 272 return false; 262 273 } 263 274 } catch (Exception $e) { 264 error_log('Caught Exception:' . $e->getMessage());275 WonderPushUtils::log('Caught Exception:' . $e->getMessage()); 265 276 return false; 266 277 } … … 403 414 ), WonderPushUtils::get_user_id()); 404 415 } 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()); 406 417 } 407 418 } 408 419 409 420 protected static function sanitize($str) { 421 if (!is_string($str)) return null; 410 422 if (!$str) return $str; 411 423 $html_entity_decode_flags = ENT_QUOTES; … … 444 456 } 445 457 } 446 458 $currency = null; 459 if (function_exists('get_woocommerce_currency')) { 460 $currency = get_woocommerce_currency(); 461 } 447 462 return array( 448 463 'string_type' => 'Product', 449 'string_image' => $pictureUrl ?: null,464 'string_image' => $pictureUrl && is_string($pictureUrl) ? $pictureUrl : null, 450 465 'string_name' => $product->get_name() ? self::sanitize($product->get_name()): null, 451 466 '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, 453 468 'object_offers' => array( 454 469 'string_type' => 'Offer', 455 470 '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, 458 473 'string_availability' => $availability, 459 474 ) -
wonderpush-web-push-notifications/trunk/wonderpush.php
r2733809 r2739316 8 8 Author: WonderPush 9 9 Author URI: https://www.wonderpush.com/ 10 Version: 1.9.1 110 Version: 1.9.12 11 11 License: GPLv2 or later 12 12 */
Note: See TracChangeset
for help on using the changeset viewer.