Plugin Directory

Changeset 2588630


Ignore:
Timestamp:
08/25/2021 03:12:18 PM (5 years ago)
Author:
wonderpush
Message:

v1.9.0

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

Legend:

Unmodified
Added
Removed
  • wonderpush-web-push-notifications/tags/1.9.0/lib/Api/Applications.php

    r2481484 r2588630  
    3333    return $response->checkedResult('\WonderPush\Obj\ApplicationCollection');
    3434  }
     35
     36  public function patch($applicationId, $body = array(), $params = array()) {
     37    $response = $this->wp->rest()->patch('/applications/' . $applicationId, array_merge($params, array('body' => $body)));
     38    return $response->checkedResult('\WonderPush\Obj\Application', 'application');
     39  }
    3540}
  • wonderpush-web-push-notifications/tags/1.9.0/lib/Net/Response.php

    r2481484 r2588630  
    266266   * @throws \WonderPush\Errors\Base
    267267   */
    268   public function checkedResult($cls) {
     268  public function checkedResult($cls, $key = null) {
    269269    $exception = $this->exception();
    270270    if ($exception) {
     
    273273    $this->parseBody();
    274274    $body = $this->parsedBody();
    275     return new $cls($body);
     275    return new $cls($key ? $body->{$key} : $body);
    276276  }
    277277
  • wonderpush-web-push-notifications/tags/1.9.0/lib/Obj/Application.php

    r2481484 r2588630  
    2525  /** @var WebSdkInitOptions */
    2626  private $webSdkInitOptions;
     27  /** @var object */
     28  private $urlParameters;
    2729
    2830  /**
     
    120122    return $this;
    121123  }
     124
     125  /**
     126   * @return object
     127   */
     128  public function getUrlParameters()
     129  {
     130    return $this->urlParameters ?: (object)array();
     131  }
     132
     133  /**
     134   * @param object $urlParameters
     135   * @return Application
     136   */
     137  public function setUrlParameters($urlParameters)
     138  {
     139    $this->urlParameters = (object)$urlParameters;
     140    return $this;
     141  }
    122142}
  • wonderpush-web-push-notifications/tags/1.9.0/lib/Params/DeliveriesCreateParams.php

    r2481484 r2588630  
    2424  private $notificationId;
    2525  private $deliveryDate;
     26  /** @var bool */
     27  private $inheritUrlParameters;
    2628
    2729  /**
     
    5456      'notificationId' => $this->notificationId,
    5557      'deliveryDate' => $this->deliveryDate ? $this->deliveryDate : null,
     58      'inheritUrlParameters' => (bool)$this->inheritUrlParameters,
    5659    ));
    5760  }
     
    199202    return $this;
    200203  }
     204
     205  /**
     206   * @return bool
     207   */
     208  public function getInheritUrlParameters() {
     209    return $this->inheritUrlParameters;
     210  }
     211
     212  /**
     213   * @param bool $inheritUrlParameters
     214   * @return DeliveriesCreateParams
     215   */
     216  public function setInheritUrlParameters($inheritUrlParameters) {
     217    $this->inheritUrlParameters = $inheritUrlParameters;
     218    return $this;
     219  }
    201220}
  • wonderpush-web-push-notifications/tags/1.9.0/readme.txt

    r2584905 r2588630  
    55Requires at least: 5.0
    66Tested up to: 5.8
    7 Stable tag: 1.8.0
     7Stable tag: 1.9.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9090
    9191== Changelog ==
     92= 1.9.0 =
     93- Manage UTM parameters to automatically add to all your push notifications
     94
    9295= 1.8.0 =
    9396- Allow selecting a segment from the WordPress editor, and a default segment from the WonderPush blogging settings
  • wonderpush-web-push-notifications/tags/1.9.0/wonderpush-admin.php

    r2584905 r2588630  
    33
    44class WonderPushAdmin {
    5   const RESOURCES_VERSION = '1.8.0';
     5  const RESOURCES_VERSION = '1.9.0';
    66  const MENU_SLUG = 'wonderpush';
    77  const META_BOX_ID = 'wonderpush_meta_box';
     
    5858    $settings = WonderPushSettings::getSettings();
    5959    $access_token = $settings->getAccessToken();
     60    $app = $access_token ? WonderPushUtils::application_from_access_token($access_token) : null;
    6061
    6162    // Add an nonce field so we can check for it later.
     
    8283    // UTM params
    8384    $utm_params = array();
     85    $url_parameters = $app ? (array)$app->getUrlParameters() : array();
    8486    foreach (WonderPushUtils::utm_parameters() as $utm_parameter) {
    8587      $value = get_post_meta($post->ID, "wonderpush_$utm_parameter", true);
    86       $value = $value ?: $settings->getUtmParameter($utm_parameter);
     88      $value = $value ?: array_key_exists($utm_parameter, $url_parameters) ? $url_parameters[$utm_parameter] : null;
    8789      $utm_params[$utm_parameter] = $value;
    8890    }
     
    432434      if ($large_image) $web->setImage($large_image);
    433435      $params = new \WonderPush\Params\DeliveriesCreateParams();
     436      $params->setInheritUrlParameters(true);
    434437      $params->setNotification($notification);
    435438      $params->setTargetSegmentIds($segmentId);
  • wonderpush-web-push-notifications/tags/1.9.0/wonderpush-api.php

    r2584905 r2588630  
    7070      $app = WonderPushUtils::application_from_access_token($access_token);
    7171    }
     72    $urlParameters = $app ? (object)array_merge($settings->getUtmParameters(), (array)$app->getUrlParameters()) : (object)array();
    7273    self::returnResult((object)array(
    7374      'accessToken' => $access_token ? $access_token : null,
     
    101102      'ampButtonWidth' => (int)$settings->getAmpButtonWidth(),
    102103      'ampButtonHeight' => (int)$settings->getAmpButtonHeight(),
    103       'utmSource' => $settings->getUtmSource(),
    104       'utmCampaign' => $settings->getUtmCampaign(),
    105       'utmMedium' => $settings->getUtmMedium(),
    106       'utmTerm' => $settings->getUtmTerm(),
    107       'utmContent' => $settings->getUtmContent(),
     104      'utmSource' => property_exists($urlParameters, 'utm_source') ? $urlParameters->utm_source : null,
     105      'utmCampaign' => property_exists($urlParameters, 'utm_campaign') ? $urlParameters->utm_campaign : null,
     106      'utmMedium' => property_exists($urlParameters, 'utm_medium') ? $urlParameters->utm_medium : null,
     107      'utmTerm' => property_exists($urlParameters, 'utm_term') ? $urlParameters->utm_term : null,
     108      'utmContent' => property_exists($urlParameters, 'utm_content') ? $urlParameters->utm_content : null,
    108109      'additionalInitOptionsJson' => $settings->getAdditionalInitOptionsJson(),
    109110
     
    250251
    251252    // utm parameters
     253    $urlParameters = $settings->getUtmParameters(); // They are deprecated
    252254    foreach (array('Source', 'Medium', 'Campaign', 'Term', 'Content') as $utm) {
    253255      $key = "utm$utm";
     
    262264        $value = $value && strlen($value) ? $value : null;
    263265
    264         $settings->setUtmParameter($utm, $value);
    265         $save = true;
    266       }
    267     }
     266        $urlParameters["utm_" . lcfirst($utm)] = $value;
     267      }
     268    }
     269    WonderPushUtils::patch_application_url_parameters($settings->getAccessToken(), $urlParameters);
     270    $settings->clearUtmParameters(); // They are deprecated
     271
    268272    // Additional init options
    269273    if (array_key_exists('additionalInitOptionsJson', $_POST)) {
  • wonderpush-web-push-notifications/tags/1.9.0/wonderpush-settings.php

    r2584905 r2588630  
    264264  }
    265265
     266  /**
     267   * @deprecated Use Application::getUrlParameters instead
     268   */
    266269  public function getUtmParameters() {
    267270    $utm_params = array();
    268271    foreach (WonderPushUtils::utm_parameters() as $utm_parameter) {
    269       $utm_params[$utm_parameter] = $this->getUtmParameter($utm_parameter);
     272      $parameter = str_replace('utm_', '', $utm_parameter);
     273      $parameter = "utm" . ucfirst($parameter);
     274      $utm_params[$utm_parameter] = $this->get($parameter);
    270275    }
    271276    return $utm_params;
    272277  }
    273278
    274   public function getUtmParameter($parameter) {
    275     $parameter = str_replace('utm_', '', $parameter);
    276     $parameter = ucfirst($parameter);
    277     return $this->{"getUtm$parameter"}();
    278   }
    279   public function setUtmParameter($parameter, $value) {
    280     $parameter = str_replace('utm_', '', $parameter);
    281     $parameter = ucfirst($parameter);
    282     return $this->{"setUtm$parameter"}($value);
    283   }
    284   public function getUtmSource() {
    285     return $this->get('utmSource');
    286   }
    287 
    288   public function setUtmSource($value) {
    289     $this->set('utmSource', $value);
    290     return $this;
    291   }
    292 
    293   public function getUtmMedium() {
    294     return $this->get('utmMedium');
    295   }
    296 
    297   public function setUtmMedium($value) {
    298     $this->set('utmMedium', $value);
    299     return $this;
    300   }
    301 
    302   public function getUtmCampaign() {
    303     return $this->get('utmCampaign');
    304   }
    305 
    306   public function setUtmCampaign($value) {
    307     $this->set('utmCampaign', $value);
    308     return $this;
    309   }
    310 
    311   public function getUtmTerm() {
    312     return $this->get('utmTerm');
    313   }
    314 
    315   public function setUtmTerm($value) {
    316     $this->set('utmTerm', $value);
    317     return $this;
    318   }
    319 
    320   public function getUtmContent() {
    321     return $this->get('utmContent');
    322   }
    323 
    324   public function setUtmContent($value) {
    325     $this->set('utmContent', $value);
    326     return $this;
     279  public function clearUtmParameters() {
     280    foreach (WonderPushUtils::utm_parameters() as $utm_parameter) {
     281      $parameter = str_replace('utm_', '', $utm_parameter);
     282      $parameter = "utm" . ucfirst($parameter);
     283      $this->set($parameter, null);
     284    }
    327285  }
    328286
  • wonderpush-web-push-notifications/tags/1.9.0/wonderpush-utils.php

    r2584905 r2588630  
    33
    44class WonderPushUtils {
     5  const DEFAULT_CACHE_TTL = 300;
    56  public static function is_wonderpush_installed() {
    67    $settings = WonderPushSettings::getSettings();
     
    7374
    7475  }
    75   /**
     76
     77  /**
     78   * @param string $access_token
     79   * @param array $url_parameters
     80   * @throws Exception
     81   */
     82  public static function patch_application_url_parameters($access_token, $url_parameters) {
     83    if (!$access_token) return;
     84    $app = WonderPushUtils::application_from_access_token($access_token, 300, true);
     85    if (!$app) return;
     86    $merged_url_parameters = $app ? (array)$app->getUrlParameters() : array();
     87    $urlParametersUpdated = false;
     88    foreach ($url_parameters as $utm => $value) {
     89      if ($value && (!array_key_exists($utm, $merged_url_parameters) || $merged_url_parameters[$utm] !== $value)) {
     90        $merged_url_parameters[$utm] = $value;
     91        $urlParametersUpdated = true;
     92      } else if (!$value && array_key_exists($utm, $merged_url_parameters) && $merged_url_parameters[$utm]) {
     93        $merged_url_parameters[$utm] = null;
     94        $urlParametersUpdated = true;
     95      }
     96    }
     97    if ($urlParametersUpdated) {
     98      error_log('$merged_url_parameters: ' . print_r($merged_url_parameters, true));
     99      $wp = new WonderPush\WonderPush($access_token);
     100      $updatedApp = $wp->applications()->patch($app->getId(), array('urlParameters' => (object)$merged_url_parameters));
     101      $cache_key = "WonderPush:Application:" . $access_token;
     102      set_transient($cache_key, $updatedApp, self::DEFAULT_CACHE_TTL);
     103    }
     104  }
     105      /**
    76106   * Returns the first application associated with the provided access token,
    77107   * or false if the access token is not valid.
     
    83113   * @return false|\WonderPush\Obj\Application
    84114   */
    85   public static function application_from_access_token($access_token, $expiration = 300) {
     115  public static function application_from_access_token($access_token, $expiration = self::DEFAULT_CACHE_TTL, $forceFetch = false) {
    86116    // Cached value ?
    87117    $cache_key = "WonderPush:Application:" . $access_token;
    88     $cached = get_transient($cache_key);
     118    $cached = $forceFetch ? null : get_transient($cache_key);
    89119    if ($cached) {
    90120      return $cached;
  • wonderpush-web-push-notifications/tags/1.9.0/wonderpush-woocommerce.php

    r2481484 r2588630  
    159159      if ($product_image_url) $web->setImage($product_image_url);
    160160      $params = new \WonderPush\Params\DeliveriesCreateParams();
     161      $params->setInheritUrlParameters(true);
    161162      $params->setNotification($notification);
    162163      $params->setTargetUserIds(strval($customer_id));
  • wonderpush-web-push-notifications/tags/1.9.0/wonderpush.php

    r2584905 r2588630  
    88Author: WonderPush
    99Author URI: https://www.wonderpush.com/
    10 Version: 1.8.0
     10Version: 1.9.0
    1111License: GPLv2 or later
    1212*/
  • wonderpush-web-push-notifications/trunk/lib/Api/Applications.php

    r2481484 r2588630  
    3333    return $response->checkedResult('\WonderPush\Obj\ApplicationCollection');
    3434  }
     35
     36  public function patch($applicationId, $body = array(), $params = array()) {
     37    $response = $this->wp->rest()->patch('/applications/' . $applicationId, array_merge($params, array('body' => $body)));
     38    return $response->checkedResult('\WonderPush\Obj\Application', 'application');
     39  }
    3540}
  • wonderpush-web-push-notifications/trunk/lib/Net/Response.php

    r2481484 r2588630  
    266266   * @throws \WonderPush\Errors\Base
    267267   */
    268   public function checkedResult($cls) {
     268  public function checkedResult($cls, $key = null) {
    269269    $exception = $this->exception();
    270270    if ($exception) {
     
    273273    $this->parseBody();
    274274    $body = $this->parsedBody();
    275     return new $cls($body);
     275    return new $cls($key ? $body->{$key} : $body);
    276276  }
    277277
  • wonderpush-web-push-notifications/trunk/lib/Obj/Application.php

    r2481484 r2588630  
    2525  /** @var WebSdkInitOptions */
    2626  private $webSdkInitOptions;
     27  /** @var object */
     28  private $urlParameters;
    2729
    2830  /**
     
    120122    return $this;
    121123  }
     124
     125  /**
     126   * @return object
     127   */
     128  public function getUrlParameters()
     129  {
     130    return $this->urlParameters ?: (object)array();
     131  }
     132
     133  /**
     134   * @param object $urlParameters
     135   * @return Application
     136   */
     137  public function setUrlParameters($urlParameters)
     138  {
     139    $this->urlParameters = (object)$urlParameters;
     140    return $this;
     141  }
    122142}
  • wonderpush-web-push-notifications/trunk/lib/Params/DeliveriesCreateParams.php

    r2481484 r2588630  
    2424  private $notificationId;
    2525  private $deliveryDate;
     26  /** @var bool */
     27  private $inheritUrlParameters;
    2628
    2729  /**
     
    5456      'notificationId' => $this->notificationId,
    5557      'deliveryDate' => $this->deliveryDate ? $this->deliveryDate : null,
     58      'inheritUrlParameters' => (bool)$this->inheritUrlParameters,
    5659    ));
    5760  }
     
    199202    return $this;
    200203  }
     204
     205  /**
     206   * @return bool
     207   */
     208  public function getInheritUrlParameters() {
     209    return $this->inheritUrlParameters;
     210  }
     211
     212  /**
     213   * @param bool $inheritUrlParameters
     214   * @return DeliveriesCreateParams
     215   */
     216  public function setInheritUrlParameters($inheritUrlParameters) {
     217    $this->inheritUrlParameters = $inheritUrlParameters;
     218    return $this;
     219  }
    201220}
  • wonderpush-web-push-notifications/trunk/readme.txt

    r2584905 r2588630  
    55Requires at least: 5.0
    66Tested up to: 5.8
    7 Stable tag: 1.8.0
     7Stable tag: 1.9.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9090
    9191== Changelog ==
     92= 1.9.0 =
     93- Manage UTM parameters to automatically add to all your push notifications
     94
    9295= 1.8.0 =
    9396- Allow selecting a segment from the WordPress editor, and a default segment from the WonderPush blogging settings
  • wonderpush-web-push-notifications/trunk/wonderpush-admin.php

    r2584905 r2588630  
    33
    44class WonderPushAdmin {
    5   const RESOURCES_VERSION = '1.8.0';
     5  const RESOURCES_VERSION = '1.9.0';
    66  const MENU_SLUG = 'wonderpush';
    77  const META_BOX_ID = 'wonderpush_meta_box';
     
    5858    $settings = WonderPushSettings::getSettings();
    5959    $access_token = $settings->getAccessToken();
     60    $app = $access_token ? WonderPushUtils::application_from_access_token($access_token) : null;
    6061
    6162    // Add an nonce field so we can check for it later.
     
    8283    // UTM params
    8384    $utm_params = array();
     85    $url_parameters = $app ? (array)$app->getUrlParameters() : array();
    8486    foreach (WonderPushUtils::utm_parameters() as $utm_parameter) {
    8587      $value = get_post_meta($post->ID, "wonderpush_$utm_parameter", true);
    86       $value = $value ?: $settings->getUtmParameter($utm_parameter);
     88      $value = $value ?: array_key_exists($utm_parameter, $url_parameters) ? $url_parameters[$utm_parameter] : null;
    8789      $utm_params[$utm_parameter] = $value;
    8890    }
     
    432434      if ($large_image) $web->setImage($large_image);
    433435      $params = new \WonderPush\Params\DeliveriesCreateParams();
     436      $params->setInheritUrlParameters(true);
    434437      $params->setNotification($notification);
    435438      $params->setTargetSegmentIds($segmentId);
  • wonderpush-web-push-notifications/trunk/wonderpush-api.php

    r2584905 r2588630  
    7070      $app = WonderPushUtils::application_from_access_token($access_token);
    7171    }
     72    $urlParameters = $app ? (object)array_merge($settings->getUtmParameters(), (array)$app->getUrlParameters()) : (object)array();
    7273    self::returnResult((object)array(
    7374      'accessToken' => $access_token ? $access_token : null,
     
    101102      'ampButtonWidth' => (int)$settings->getAmpButtonWidth(),
    102103      'ampButtonHeight' => (int)$settings->getAmpButtonHeight(),
    103       'utmSource' => $settings->getUtmSource(),
    104       'utmCampaign' => $settings->getUtmCampaign(),
    105       'utmMedium' => $settings->getUtmMedium(),
    106       'utmTerm' => $settings->getUtmTerm(),
    107       'utmContent' => $settings->getUtmContent(),
     104      'utmSource' => property_exists($urlParameters, 'utm_source') ? $urlParameters->utm_source : null,
     105      'utmCampaign' => property_exists($urlParameters, 'utm_campaign') ? $urlParameters->utm_campaign : null,
     106      'utmMedium' => property_exists($urlParameters, 'utm_medium') ? $urlParameters->utm_medium : null,
     107      'utmTerm' => property_exists($urlParameters, 'utm_term') ? $urlParameters->utm_term : null,
     108      'utmContent' => property_exists($urlParameters, 'utm_content') ? $urlParameters->utm_content : null,
    108109      'additionalInitOptionsJson' => $settings->getAdditionalInitOptionsJson(),
    109110
     
    250251
    251252    // utm parameters
     253    $urlParameters = $settings->getUtmParameters(); // They are deprecated
    252254    foreach (array('Source', 'Medium', 'Campaign', 'Term', 'Content') as $utm) {
    253255      $key = "utm$utm";
     
    262264        $value = $value && strlen($value) ? $value : null;
    263265
    264         $settings->setUtmParameter($utm, $value);
    265         $save = true;
    266       }
    267     }
     266        $urlParameters["utm_" . lcfirst($utm)] = $value;
     267      }
     268    }
     269    WonderPushUtils::patch_application_url_parameters($settings->getAccessToken(), $urlParameters);
     270    $settings->clearUtmParameters(); // They are deprecated
     271
    268272    // Additional init options
    269273    if (array_key_exists('additionalInitOptionsJson', $_POST)) {
  • wonderpush-web-push-notifications/trunk/wonderpush-settings.php

    r2584905 r2588630  
    264264  }
    265265
     266  /**
     267   * @deprecated Use Application::getUrlParameters instead
     268   */
    266269  public function getUtmParameters() {
    267270    $utm_params = array();
    268271    foreach (WonderPushUtils::utm_parameters() as $utm_parameter) {
    269       $utm_params[$utm_parameter] = $this->getUtmParameter($utm_parameter);
     272      $parameter = str_replace('utm_', '', $utm_parameter);
     273      $parameter = "utm" . ucfirst($parameter);
     274      $utm_params[$utm_parameter] = $this->get($parameter);
    270275    }
    271276    return $utm_params;
    272277  }
    273278
    274   public function getUtmParameter($parameter) {
    275     $parameter = str_replace('utm_', '', $parameter);
    276     $parameter = ucfirst($parameter);
    277     return $this->{"getUtm$parameter"}();
    278   }
    279   public function setUtmParameter($parameter, $value) {
    280     $parameter = str_replace('utm_', '', $parameter);
    281     $parameter = ucfirst($parameter);
    282     return $this->{"setUtm$parameter"}($value);
    283   }
    284   public function getUtmSource() {
    285     return $this->get('utmSource');
    286   }
    287 
    288   public function setUtmSource($value) {
    289     $this->set('utmSource', $value);
    290     return $this;
    291   }
    292 
    293   public function getUtmMedium() {
    294     return $this->get('utmMedium');
    295   }
    296 
    297   public function setUtmMedium($value) {
    298     $this->set('utmMedium', $value);
    299     return $this;
    300   }
    301 
    302   public function getUtmCampaign() {
    303     return $this->get('utmCampaign');
    304   }
    305 
    306   public function setUtmCampaign($value) {
    307     $this->set('utmCampaign', $value);
    308     return $this;
    309   }
    310 
    311   public function getUtmTerm() {
    312     return $this->get('utmTerm');
    313   }
    314 
    315   public function setUtmTerm($value) {
    316     $this->set('utmTerm', $value);
    317     return $this;
    318   }
    319 
    320   public function getUtmContent() {
    321     return $this->get('utmContent');
    322   }
    323 
    324   public function setUtmContent($value) {
    325     $this->set('utmContent', $value);
    326     return $this;
     279  public function clearUtmParameters() {
     280    foreach (WonderPushUtils::utm_parameters() as $utm_parameter) {
     281      $parameter = str_replace('utm_', '', $utm_parameter);
     282      $parameter = "utm" . ucfirst($parameter);
     283      $this->set($parameter, null);
     284    }
    327285  }
    328286
  • wonderpush-web-push-notifications/trunk/wonderpush-utils.php

    r2584905 r2588630  
    33
    44class WonderPushUtils {
     5  const DEFAULT_CACHE_TTL = 300;
    56  public static function is_wonderpush_installed() {
    67    $settings = WonderPushSettings::getSettings();
     
    7374
    7475  }
    75   /**
     76
     77  /**
     78   * @param string $access_token
     79   * @param array $url_parameters
     80   * @throws Exception
     81   */
     82  public static function patch_application_url_parameters($access_token, $url_parameters) {
     83    if (!$access_token) return;
     84    $app = WonderPushUtils::application_from_access_token($access_token, 300, true);
     85    if (!$app) return;
     86    $merged_url_parameters = $app ? (array)$app->getUrlParameters() : array();
     87    $urlParametersUpdated = false;
     88    foreach ($url_parameters as $utm => $value) {
     89      if ($value && (!array_key_exists($utm, $merged_url_parameters) || $merged_url_parameters[$utm] !== $value)) {
     90        $merged_url_parameters[$utm] = $value;
     91        $urlParametersUpdated = true;
     92      } else if (!$value && array_key_exists($utm, $merged_url_parameters) && $merged_url_parameters[$utm]) {
     93        $merged_url_parameters[$utm] = null;
     94        $urlParametersUpdated = true;
     95      }
     96    }
     97    if ($urlParametersUpdated) {
     98      error_log('$merged_url_parameters: ' . print_r($merged_url_parameters, true));
     99      $wp = new WonderPush\WonderPush($access_token);
     100      $updatedApp = $wp->applications()->patch($app->getId(), array('urlParameters' => (object)$merged_url_parameters));
     101      $cache_key = "WonderPush:Application:" . $access_token;
     102      set_transient($cache_key, $updatedApp, self::DEFAULT_CACHE_TTL);
     103    }
     104  }
     105      /**
    76106   * Returns the first application associated with the provided access token,
    77107   * or false if the access token is not valid.
     
    83113   * @return false|\WonderPush\Obj\Application
    84114   */
    85   public static function application_from_access_token($access_token, $expiration = 300) {
     115  public static function application_from_access_token($access_token, $expiration = self::DEFAULT_CACHE_TTL, $forceFetch = false) {
    86116    // Cached value ?
    87117    $cache_key = "WonderPush:Application:" . $access_token;
    88     $cached = get_transient($cache_key);
     118    $cached = $forceFetch ? null : get_transient($cache_key);
    89119    if ($cached) {
    90120      return $cached;
  • wonderpush-web-push-notifications/trunk/wonderpush-woocommerce.php

    r2481484 r2588630  
    159159      if ($product_image_url) $web->setImage($product_image_url);
    160160      $params = new \WonderPush\Params\DeliveriesCreateParams();
     161      $params->setInheritUrlParameters(true);
    161162      $params->setNotification($notification);
    162163      $params->setTargetUserIds(strval($customer_id));
  • wonderpush-web-push-notifications/trunk/wonderpush.php

    r2584905 r2588630  
    88Author: WonderPush
    99Author URI: https://www.wonderpush.com/
    10 Version: 1.8.0
     10Version: 1.9.0
    1111License: GPLv2 or later
    1212*/
Note: See TracChangeset for help on using the changeset viewer.