Changeset 3313743
- Timestamp:
- 06/18/2025 09:54:47 AM (10 months ago)
- Location:
- wonderpush-web-push-notifications
- Files:
-
- 24 added
- 26 edited
- 1 copied
-
tags/1.12.0 (copied) (copied from wonderpush-web-push-notifications/trunk)
-
tags/1.12.0/init.php (modified) (1 diff)
-
tags/1.12.0/lib/Api/Campaigns.php (added)
-
tags/1.12.0/lib/Api/Rest.php (modified) (1 diff)
-
tags/1.12.0/lib/Net/CurlHttpClient.php (modified) (5 diffs)
-
tags/1.12.0/lib/Net/Request.php (modified) (3 diffs)
-
tags/1.12.0/lib/Obj/Application.php (modified) (2 diffs)
-
tags/1.12.0/lib/Obj/Campaign.php (added)
-
tags/1.12.0/lib/Obj/CampaignCapping.php (added)
-
tags/1.12.0/lib/Obj/CampaignCollection.php (added)
-
tags/1.12.0/lib/Obj/CampaignSchedule.php (added)
-
tags/1.12.0/lib/Obj/CampaignSchedulePressure.php (added)
-
tags/1.12.0/lib/Obj/CampaignScheduleUrlCriterion.php (added)
-
tags/1.12.0/lib/Obj/CampaignStats.php (added)
-
tags/1.12.0/lib/Obj/CampaignSuccessResponse.php (added)
-
tags/1.12.0/lib/Obj/CampaignUrlFilters.php (added)
-
tags/1.12.0/lib/Obj/WebSdkInitOptions.php (modified) (2 diffs)
-
tags/1.12.0/lib/Params/CreateCampaignParams.php (added)
-
tags/1.12.0/lib/Params/DeliveriesCreateParams.php (modified) (1 diff)
-
tags/1.12.0/lib/Params/PatchCampaignParams.php (added)
-
tags/1.12.0/lib/WonderPush.php (modified) (9 diffs)
-
tags/1.12.0/readme.txt (modified) (2 diffs)
-
tags/1.12.0/wonderpush-admin-page.css (modified) (2 diffs)
-
tags/1.12.0/wonderpush-admin.php (modified) (1 diff)
-
tags/1.12.0/wonderpush-public.php (modified) (1 diff)
-
tags/1.12.0/wonderpush.php (modified) (1 diff)
-
trunk/init.php (modified) (1 diff)
-
trunk/lib/Api/Campaigns.php (added)
-
trunk/lib/Api/Rest.php (modified) (1 diff)
-
trunk/lib/Net/CurlHttpClient.php (modified) (5 diffs)
-
trunk/lib/Net/Request.php (modified) (3 diffs)
-
trunk/lib/Obj/Application.php (modified) (2 diffs)
-
trunk/lib/Obj/Campaign.php (added)
-
trunk/lib/Obj/CampaignCapping.php (added)
-
trunk/lib/Obj/CampaignCollection.php (added)
-
trunk/lib/Obj/CampaignSchedule.php (added)
-
trunk/lib/Obj/CampaignSchedulePressure.php (added)
-
trunk/lib/Obj/CampaignScheduleUrlCriterion.php (added)
-
trunk/lib/Obj/CampaignStats.php (added)
-
trunk/lib/Obj/CampaignSuccessResponse.php (added)
-
trunk/lib/Obj/CampaignUrlFilters.php (added)
-
trunk/lib/Obj/WebSdkInitOptions.php (modified) (2 diffs)
-
trunk/lib/Params/CreateCampaignParams.php (added)
-
trunk/lib/Params/DeliveriesCreateParams.php (modified) (1 diff)
-
trunk/lib/Params/PatchCampaignParams.php (added)
-
trunk/lib/WonderPush.php (modified) (9 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wonderpush-admin-page.css (modified) (2 diffs)
-
trunk/wonderpush-admin.php (modified) (1 diff)
-
trunk/wonderpush-public.php (modified) (1 diff)
-
trunk/wonderpush.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wonderpush-web-push-notifications/tags/1.12.0/init.php
r2922221 r3313743 2 2 3 3 // WonderPush\Util 4 require(dirname(__FILE__) . '/lib/Util/JsonSerializable.php');5 require(dirname(__FILE__) . '/lib/Util/Logger.php');6 require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php');7 require(dirname(__FILE__) . '/lib/Util/ArrayUtil.php');8 require(dirname(__FILE__) . '/lib/Util/StringUtil.php');9 require(dirname(__FILE__) . '/lib/Util/TimeUnit.php');10 require(dirname(__FILE__) . '/lib/Util/TimeUtil.php');11 require(dirname(__FILE__) . '/lib/Util/TimeValue.php');12 require(dirname(__FILE__) . '/lib/Util/UrlUtil.php');4 if (!interface_exists('WonderPush\Util\JsonSerializable')) require(dirname(__FILE__) . '/lib/Util/JsonSerializable.php'); 5 if (!interface_exists('WonderPush\Util\Logger')) require(dirname(__FILE__) . '/lib/Util/Logger.php'); 6 if (!class_exists('WonderPush\Util\DefaultLogger')) require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php'); 7 if (!class_exists('WonderPush\Util\ArrayUtil')) require(dirname(__FILE__) . '/lib/Util/ArrayUtil.php'); 8 if (!class_exists('WonderPush\Util\StringUtil')) require(dirname(__FILE__) . '/lib/Util/StringUtil.php'); 9 if (!class_exists('WonderPush\Util\TimeUnit')) require(dirname(__FILE__) . '/lib/Util/TimeUnit.php'); 10 if (!class_exists('WonderPush\Util\TimeUtil')) require(dirname(__FILE__) . '/lib/Util/TimeUtil.php'); 11 if (!class_exists('WonderPush\Util\TimeValue')) require(dirname(__FILE__) . '/lib/Util/TimeValue.php'); 12 if (!class_exists('WonderPush\Util\UrlUtil')) require(dirname(__FILE__) . '/lib/Util/UrlUtil.php'); 13 13 14 14 // WonderPush 15 require(dirname(__FILE__) . '/lib/WonderPush.php');15 if (!class_exists('WonderPush\WonderPush')) require(dirname(__FILE__) . '/lib/WonderPush.php'); 16 16 17 17 // WonderPush\Obj 18 require(dirname(__FILE__) . '/lib/Obj/BaseObject.php'); 19 require(dirname(__FILE__) . '/lib/Obj/SuccessResponse.php'); 20 require(dirname(__FILE__) . '/lib/Obj/DeliveriesCreateResponse.php'); 21 require(dirname(__FILE__) . '/lib/Obj/Pagination.php'); 22 require(dirname(__FILE__) . '/lib/Obj/NullObject.php'); 23 require(dirname(__FILE__) . '/lib/Obj/Application.php'); 24 require(dirname(__FILE__) . '/lib/Obj/Segment.php'); 25 require(dirname(__FILE__) . '/lib/Obj/GeoLocation.php'); 26 require(dirname(__FILE__) . '/lib/Obj/User.php'); 27 require(dirname(__FILE__) . '/lib/Obj/Collection.php'); 28 require(dirname(__FILE__) . '/lib/Obj/ApplicationCollection.php'); 29 require(dirname(__FILE__) . '/lib/Obj/SegmentCollection.php'); 30 require(dirname(__FILE__) . '/lib/Obj/Installation.php'); 31 require(dirname(__FILE__) . '/lib/Obj/InstallationCollection.php'); 32 require(dirname(__FILE__) . '/lib/Obj/InstallationApplicationApple.php'); 33 require(dirname(__FILE__) . '/lib/Obj/InstallationApplication.php'); 34 require(dirname(__FILE__) . '/lib/Obj/InstallationDeviceCapabilities.php'); 35 require(dirname(__FILE__) . '/lib/Obj/InstallationDeviceConfiguration.php'); 36 require(dirname(__FILE__) . '/lib/Obj/InstallationDevice.php'); 37 require(dirname(__FILE__) . '/lib/Obj/InstallationPreferences.php'); 38 require(dirname(__FILE__) . '/lib/Obj/InstallationPushToken.php'); 39 require(dirname(__FILE__) . '/lib/Obj/Event.php'); 40 require(dirname(__FILE__) . '/lib/Obj/FrequentFieldValues.php'); 41 require(dirname(__FILE__) . '/lib/Obj/NotificationButton.php'); 42 require(dirname(__FILE__) . '/lib/Obj/NotificationButtonAction.php'); 43 require(dirname(__FILE__) . '/lib/Obj/NotificationButtonActionEvent.php'); 44 require(dirname(__FILE__) . '/lib/Obj/Notification.php'); 45 require(dirname(__FILE__) . '/lib/Obj/NotificationAlert.php'); 46 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertAndroid.php'); 47 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertAndroidButton.php'); 48 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIos.php'); 49 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIosAttachment.php'); 50 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIosForeground.php'); 51 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertWeb.php'); 52 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertWebButton.php'); 53 require(dirname(__FILE__) . '/lib/Obj/NotificationInApp.php'); 54 require(dirname(__FILE__) . '/lib/Obj/NotificationInAppButton.php'); 55 require(dirname(__FILE__) . '/lib/Obj/NotificationInAppMap.php'); 56 require(dirname(__FILE__) . '/lib/Obj/NotificationInAppMapPlace.php'); 57 require(dirname(__FILE__) . '/lib/Obj/NotificationPush.php'); 58 require(dirname(__FILE__) . '/lib/Obj/NotificationPushAndroid.php'); 59 require(dirname(__FILE__) . '/lib/Obj/NotificationPushIos.php'); 60 require(dirname(__FILE__) . '/lib/Obj/NotificationPushWeb.php'); 61 require(dirname(__FILE__) . '/lib/Obj/WebSdkInitOptions.php'); 18 if (!class_exists('WonderPush\Obj\BaseObject')) require(dirname(__FILE__) . '/lib/Obj/BaseObject.php'); 19 if (!class_exists('WonderPush\Obj\SuccessResponse')) require(dirname(__FILE__) . '/lib/Obj/SuccessResponse.php'); 20 if (!class_exists('WonderPush\Obj\CampaignSuccessResponse')) require(dirname(__FILE__) . '/lib/Obj/CampaignSuccessResponse.php'); 21 if (!class_exists('WonderPush\Obj\DeliveriesCreateResponse')) require(dirname(__FILE__) . '/lib/Obj/DeliveriesCreateResponse.php'); 22 if (!class_exists('WonderPush\Obj\Pagination')) require(dirname(__FILE__) . '/lib/Obj/Pagination.php'); 23 if (!class_exists('WonderPush\Obj\NullObject')) require(dirname(__FILE__) . '/lib/Obj/NullObject.php'); 24 if (!class_exists('WonderPush\Obj\Application')) require(dirname(__FILE__) . '/lib/Obj/Application.php'); 25 if (!class_exists('WonderPush\Obj\Segment')) require(dirname(__FILE__) . '/lib/Obj/Segment.php'); 26 if (!class_exists('WonderPush\Obj\GeoLocation')) require(dirname(__FILE__) . '/lib/Obj/GeoLocation.php'); 27 if (!class_exists('WonderPush\Obj\User')) require(dirname(__FILE__) . '/lib/Obj/User.php'); 28 if (!class_exists('WonderPush\Obj\Collection')) require(dirname(__FILE__) . '/lib/Obj/Collection.php'); 29 if (!class_exists('WonderPush\Obj\CampaignCollection')) require(dirname(__FILE__) . '/lib/Obj/CampaignCollection.php'); 30 if (!class_exists('WonderPush\Obj\ApplicationCollection')) require(dirname(__FILE__) . '/lib/Obj/ApplicationCollection.php'); 31 if (!class_exists('WonderPush\Obj\SegmentCollection')) require(dirname(__FILE__) . '/lib/Obj/SegmentCollection.php'); 32 if (!class_exists('WonderPush\Obj\Installation')) require(dirname(__FILE__) . '/lib/Obj/Installation.php'); 33 if (!class_exists('WonderPush\Obj\InstallationCollection')) require(dirname(__FILE__) . '/lib/Obj/InstallationCollection.php'); 34 if (!class_exists('WonderPush\Obj\InstallationApplicationApple')) require(dirname(__FILE__) . '/lib/Obj/InstallationApplicationApple.php'); 35 if (!class_exists('WonderPush\Obj\InstallationApplication')) require(dirname(__FILE__) . '/lib/Obj/InstallationApplication.php'); 36 if (!class_exists('WonderPush\Obj\InstallationDeviceCapabilities')) require(dirname(__FILE__) . '/lib/Obj/InstallationDeviceCapabilities.php'); 37 if (!class_exists('WonderPush\Obj\InstallationDeviceConfiguration')) require(dirname(__FILE__) . '/lib/Obj/InstallationDeviceConfiguration.php'); 38 if (!class_exists('WonderPush\Obj\InstallationDevice')) require(dirname(__FILE__) . '/lib/Obj/InstallationDevice.php'); 39 if (!class_exists('WonderPush\Obj\InstallationPreferences')) require(dirname(__FILE__) . '/lib/Obj/InstallationPreferences.php'); 40 if (!class_exists('WonderPush\Obj\InstallationPushToken')) require(dirname(__FILE__) . '/lib/Obj/InstallationPushToken.php'); 41 if (!class_exists('WonderPush\Obj\Event')) require(dirname(__FILE__) . '/lib/Obj/Event.php'); 42 if (!class_exists('WonderPush\Obj\FrequentFieldValues')) require(dirname(__FILE__) . '/lib/Obj/FrequentFieldValues.php'); 43 if (!class_exists('WonderPush\Obj\NotificationButton')) require(dirname(__FILE__) . '/lib/Obj/NotificationButton.php'); 44 if (!class_exists('WonderPush\Obj\NotificationButtonAction')) require(dirname(__FILE__) . '/lib/Obj/NotificationButtonAction.php'); 45 if (!class_exists('WonderPush\Obj\NotificationButtonActionEvent')) require(dirname(__FILE__) . '/lib/Obj/NotificationButtonActionEvent.php'); 46 if (!class_exists('WonderPush\Obj\Notification')) require(dirname(__FILE__) . '/lib/Obj/Notification.php'); 47 if (!class_exists('WonderPush\Obj\NotificationAlert')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlert.php'); 48 if (!class_exists('WonderPush\Obj\NotificationAlertAndroid')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertAndroid.php'); 49 if (!class_exists('WonderPush\Obj\NotificationAlertAndroidButton')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertAndroidButton.php'); 50 if (!class_exists('WonderPush\Obj\NotificationAlertIos')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIos.php'); 51 if (!class_exists('WonderPush\Obj\NotificationAlertIosAttachment')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIosAttachment.php'); 52 if (!class_exists('WonderPush\Obj\NotificationAlertIosForeground')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIosForeground.php'); 53 if (!class_exists('WonderPush\Obj\NotificationAlertWeb')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertWeb.php'); 54 if (!class_exists('WonderPush\Obj\NotificationAlertWebButton')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertWebButton.php'); 55 if (!class_exists('WonderPush\Obj\NotificationInApp')) require(dirname(__FILE__) . '/lib/Obj/NotificationInApp.php'); 56 if (!class_exists('WonderPush\Obj\NotificationInAppButton')) require(dirname(__FILE__) . '/lib/Obj/NotificationInAppButton.php'); 57 if (!class_exists('WonderPush\Obj\NotificationInAppMap')) require(dirname(__FILE__) . '/lib/Obj/NotificationInAppMap.php'); 58 if (!class_exists('WonderPush\Obj\NotificationInAppMapPlace')) require(dirname(__FILE__) . '/lib/Obj/NotificationInAppMapPlace.php'); 59 if (!class_exists('WonderPush\Obj\NotificationPush')) require(dirname(__FILE__) . '/lib/Obj/NotificationPush.php'); 60 if (!class_exists('WonderPush\Obj\NotificationPushAndroid')) require(dirname(__FILE__) . '/lib/Obj/NotificationPushAndroid.php'); 61 if (!class_exists('WonderPush\Obj\NotificationPushIos')) require(dirname(__FILE__) . '/lib/Obj/NotificationPushIos.php'); 62 if (!class_exists('WonderPush\Obj\NotificationPushWeb')) require(dirname(__FILE__) . '/lib/Obj/NotificationPushWeb.php'); 63 if (!class_exists('WonderPush\Obj\Campaign')) require(dirname(__FILE__) . '/lib/Obj/Campaign.php'); 64 if (!class_exists('WonderPush\Obj\CampaignSchedule')) require(dirname(__FILE__) . '/lib/Obj/CampaignSchedule.php'); 65 if (!class_exists('WonderPush\Obj\CampaignSchedulePressure')) require(dirname(__FILE__) . '/lib/Obj/CampaignSchedulePressure.php'); 66 if (!class_exists('WonderPush\Obj\CampaignScheduleUrlCriterion')) require(dirname(__FILE__) . '/lib/Obj/CampaignScheduleUrlCriterion.php'); 67 if (!class_exists('WonderPush\Obj\CampaignStats')) require(dirname(__FILE__) . '/lib/Obj/CampaignStats.php'); 68 if (!class_exists('WonderPush\Obj\CampaignUrlFilters')) require(dirname(__FILE__) . '/lib/Obj/CampaignUrlFilters.php'); 69 if (!class_exists('WonderPush\Obj\CampaignCapping')) require(dirname(__FILE__) . '/lib/Obj/CampaignCapping.php'); 70 71 if (!class_exists('WonderPush\Obj\WebSdkInitOptions')) require(dirname(__FILE__) . '/lib/Obj/WebSdkInitOptions.php'); 62 72 63 73 // WonderPush\Params 64 require(dirname(__FILE__) . '/lib/Params/CollectionParams.php'); 65 require(dirname(__FILE__) . '/lib/Params/DeliveriesCreateParams.php'); 66 require(dirname(__FILE__) . '/lib/Params/FrequentFieldValuesParams.php'); 67 require(dirname(__FILE__) . '/lib/Params/AllInstallationsParams.php'); 68 require(dirname(__FILE__) . '/lib/Params/PatchInstallationParams.php'); 69 require(dirname(__FILE__) . '/lib/Params/TrackEventParams.php'); 74 if (!class_exists('WonderPush\Params\CollectionParams')) require(dirname(__FILE__) . '/lib/Params/CollectionParams.php'); 75 if (!class_exists('WonderPush\Params\DeliveriesCreateParams')) require(dirname(__FILE__) . '/lib/Params/DeliveriesCreateParams.php'); 76 if (!class_exists('WonderPush\Params\FrequentFieldValuesParams')) require(dirname(__FILE__) . '/lib/Params/FrequentFieldValuesParams.php'); 77 if (!class_exists('WonderPush\Params\AllInstallationsParams')) require(dirname(__FILE__) . '/lib/Params/AllInstallationsParams.php'); 78 if (!class_exists('WonderPush\Params\PatchInstallationParams')) require(dirname(__FILE__) . '/lib/Params/PatchInstallationParams.php'); 79 if (!class_exists('WonderPush\Params\TrackEventParams')) require(dirname(__FILE__) . '/lib/Params/TrackEventParams.php'); 80 if (!class_exists('WonderPush\Params\PatchCampaignParams')) require(dirname(__FILE__) . '/lib/Params/PatchCampaignParams.php'); 81 if (!class_exists('WonderPush\Params\CreateCampaignParams')) require(dirname(__FILE__) . '/lib/Params/CreateCampaignParams.php'); 70 82 71 83 // WonderPush\Net 72 require(dirname(__FILE__) . '/lib/Net/Request.php');73 require(dirname(__FILE__) . '/lib/Net/Response.php');74 require(dirname(__FILE__) . '/lib/Net/HttpClientInterface.php');75 require(dirname(__FILE__) . '/lib/Net/CurlHttpClient.php');84 if (!class_exists('WonderPush\Net\Request')) require(dirname(__FILE__) . '/lib/Net/Request.php'); 85 if (!class_exists('WonderPush\Net\Response')) require(dirname(__FILE__) . '/lib/Net/Response.php'); 86 if (!interface_exists('WonderPush\Net\HttpClientInterface')) require(dirname(__FILE__) . '/lib/Net/HttpClientInterface.php'); 87 if (!class_exists('WonderPush\Net\CurlHttpClient')) require(dirname(__FILE__) . '/lib/Net/CurlHttpClient.php'); 76 88 77 89 // WonderPush\Errors 78 require(dirname(__FILE__) . '/lib/Errors/Base.php');79 require(dirname(__FILE__) . '/lib/Errors/Parsing.php');80 require(dirname(__FILE__) . '/lib/Errors/Server.php');81 require(dirname(__FILE__) . '/lib/Errors/Network.php');90 if (!class_exists('WonderPush\Errors\Base')) require(dirname(__FILE__) . '/lib/Errors/Base.php'); 91 if (!class_exists('WonderPush\Errors\Parsing')) require(dirname(__FILE__) . '/lib/Errors/Parsing.php'); 92 if (!class_exists('WonderPush\Errors\Server')) require(dirname(__FILE__) . '/lib/Errors/Server.php'); 93 if (!class_exists('WonderPush\Errors\Network')) require(dirname(__FILE__) . '/lib/Errors/Network.php'); 82 94 83 95 // WonderPush\Api 84 require(dirname(__FILE__) . '/lib/Api/Rest.php'); 85 require(dirname(__FILE__) . '/lib/Api/Deliveries.php'); 86 require(dirname(__FILE__) . '/lib/Api/Applications.php'); 87 require(dirname(__FILE__) . '/lib/Api/Segments.php'); 88 require(dirname(__FILE__) . '/lib/Api/Stats.php'); 89 require(dirname(__FILE__) . '/lib/Api/Installations.php'); 90 require(dirname(__FILE__) . '/lib/Api/Events.php'); 96 if (!class_exists('WonderPush\Api\Rest')) require(dirname(__FILE__) . '/lib/Api/Rest.php'); 97 if (!class_exists('WonderPush\Api\Deliveries')) require(dirname(__FILE__) . '/lib/Api/Deliveries.php'); 98 if (!class_exists('WonderPush\Api\Applications')) require(dirname(__FILE__) . '/lib/Api/Applications.php'); 99 if (!class_exists('WonderPush\Api\Segments')) require(dirname(__FILE__) . '/lib/Api/Segments.php'); 100 if (!class_exists('WonderPush\Api\Stats')) require(dirname(__FILE__) . '/lib/Api/Stats.php'); 101 if (!class_exists('WonderPush\Api\Installations')) require(dirname(__FILE__) . '/lib/Api/Installations.php'); 102 if (!class_exists('WonderPush\Api\Campaigns')) require(dirname(__FILE__) . '/lib/Api/Campaigns.php'); 103 if (!class_exists('WonderPush\Api\Events')) require(dirname(__FILE__) . '/lib/Api/Events.php'); -
wonderpush-web-push-notifications/tags/1.12.0/lib/Api/Rest.php
r2481484 r3313743 38 38 $rtn->setPath($path); 39 39 $rtn->setParams($params); 40 $rtn->setQsParam s(array_filter(array(41 'accessToken' => $this->wp->getAccessToken(),42 'applicationId' => $this->wp->getApplicationId(), // filtered if null43 )));40 $rtn->setQsParam('applicationId', $this->wp->getApplicationId()); // filtered if null 41 if ($this->wp->getCredentials()) { 42 $this->wp->getCredentials()->authenticate($rtn); 43 } 44 44 return $rtn; 45 45 } -
wonderpush-web-push-notifications/tags/1.12.0/lib/Net/CurlHttpClient.php
r3097137 r3313743 9 9 */ 10 10 class CurlHttpClient implements HttpClientInterface { 11 12 public static $logging = false; 13 public static $loggingResponses = false; 11 14 12 15 /** … … 53 56 case Request::GET: 54 57 case Request::DELETE: 55 $qsParams = array_merge($qsParams , $request->getParams());58 $qsParams = array_merge($qsParams ?: array(), $request->getParams()); 56 59 break; 57 60 case Request::PUT: … … 59 62 case Request::PATCH: 60 63 $body = $request->getParams(); 61 if (empty($body)) { 64 $files = $request->getFiles(); 65 if (count($files)) { 66 $body = $request->getParams() ?: array(); 67 foreach ($files as $name => $file) { 68 $body[$name] = new \CURLFile($file['tmp_name'], $file['type'], $file['name']); 69 } 70 } else if (empty($body)) { 62 71 $body = null; 63 72 } else { … … 133 142 134 143 // Execute cURL request 144 $start = microtime(true); 135 145 $rawResponse = curl_exec($ch); 146 if (self::$logging) { 147 error_log('--> ' . $request->getMethod() . ' ' . $url . ' ' . $body . (empty($headers) ? '' : ' ' . json_encode($headers)) . ' (' . intval(1000 * (microtime(true) - $start)) . 'ms)'); 148 } 136 149 137 150 // Parse response … … 155 168 } 156 169 170 if (self::$logging && self::$loggingResponses) { 171 error_log('<-- (' . $response->getStatusCode() . ') ' . ($response->getRawBody() ?: '<no body>') . (empty($response->getHeaders()) ? '' : ' ' . json_encode($response->getHeaders()))); 172 } 173 157 174 // Cleanup 158 175 curl_close($ch); -
wonderpush-web-push-notifications/tags/1.12.0/lib/Net/Request.php
r2481484 r3313743 78 78 79 79 /** 80 * An associative array of 'paramName' => ['tmp_name' => '/full/path','name' => 'filename.png', 'type' => 'image/png']. 81 * @var mixed 82 */ 83 private $files = array(); 84 85 /** 80 86 * HTTP headers. 81 87 * @var mixed[] … … 174 180 175 181 /** 182 * @param $key 183 * @param $value 184 * @return $this 185 */ 186 public function setQsParam($key, $value) { 187 if ($key === null) return $this; 188 if (!$this->qsParams) { 189 $this->qsParams = array(); 190 } 191 if ($value === null) { 192 unset($this->qsParams[$key]); 193 } else { 194 $this->qsParams[$key] = $value; 195 } 196 return $this; 197 } 198 199 public function addFile($paramName, $filename, $path, $type) { 200 $this->files[$paramName] = array( 201 'name' => $filename, 202 'tmp_name' => $path, 203 'type' => $type, 204 ); 205 return $this; 206 } 207 208 public function removeFile($paramName) { 209 unset($this->files[$paramName]); 210 return $this; 211 } 212 213 public function getFiles() { 214 return $this->files; 215 } 216 217 /** 176 218 * The body parameters. 177 219 * … … 215 257 } 216 258 259 /** 260 * @param $key 261 * @param $value 262 * @return $this 263 */ 264 public function setHeader($key, $value) { 265 if ($key === null) return $this; 266 if (!$this->headers) { 267 $this->headers = array(); 268 } 269 if ($value === null) { 270 unset($this->headers[$key]); 271 } else { 272 $this->headers[$key] = $value; 273 } 274 return $this; 275 } 217 276 } -
wonderpush-web-push-notifications/tags/1.12.0/lib/Obj/Application.php
r2588630 r3313743 27 27 /** @var object */ 28 28 private $urlParameters; 29 /** @var string */ 30 private $status; 31 /** @var integer */ 32 private $subscribers; 33 /** @var array */ 34 private $pushDisabledPlatforms; 35 /** @var boolean */ 36 private $wordPressSnippetDeactivated; 29 37 30 38 /** … … 140 148 return $this; 141 149 } 150 151 /** 152 * @return string|null 153 */ 154 public function getStatus() 155 { 156 return $this->status ?: null; 157 } 158 159 /** 160 * @param string $status 161 * @return Application 162 */ 163 public function setStatus($status) 164 { 165 $this->status = $status; 166 return $this; 167 } 168 169 /** 170 * @return int 171 */ 172 public function getSubscribers() 173 { 174 return $this->subscribers ?: 0; 175 } 176 177 /** 178 * @param int $subscribers 179 * @return Application 180 */ 181 public function setSubscribers( $subscribers ) 182 { 183 $this->subscribers = $subscribers; 184 return $this; 185 } 186 187 /** 188 * @return array 189 */ 190 public function getPushDisabledPlatforms() 191 { 192 return $this->pushDisabledPlatforms; 193 } 194 195 /** 196 * @param array $pushDisabledPlatforms 197 * @return Application 198 */ 199 public function setPushDisabledPlatforms($pushDisabledPlatforms) 200 { 201 $this->pushDisabledPlatforms = (array)$pushDisabledPlatforms; 202 return $this; 203 } 204 205 public function getWordPressSnippetDeactivated() 206 { 207 return (bool)$this->wordPressSnippetDeactivated; 208 } 209 210 public function setWordPressSnippetDeactivated($wordPressSnippetDeactivated) 211 { 212 $this->wordPressSnippetDeactivated = (bool)$wordPressSnippetDeactivated; 213 return $this; 214 } 142 215 } -
wonderpush-web-push-notifications/tags/1.12.0/lib/Obj/WebSdkInitOptions.php
r2481484 r3313743 19 19 /** @var string */ 20 20 private $manifestUrl; 21 /** @var bool */ 22 private $resubscribe; 23 24 /** @var array */ 25 private $allowedSubscriptionDomains; 26 /** @var mixed */ 27 private $subscriptionNative; 28 /** @var mixed */ 29 private $subscriptionDialog; 30 /** @var mixed */ 31 private $subscriptionBell; 32 /** @var mixed */ 33 private $subscriptionBlurb; 34 /** @var mixed */ 35 private $optInOptions; 36 /** @var mixed */ 37 private $plugins; 38 /** @var string */ 39 private $serviceWorkerUrl; 40 /** @var string */ 41 private $frameUrl; 21 42 22 43 /** … … 125 146 return null; 126 147 } 148 149 /** 150 * @return bool 151 */ 152 public function getResubscribe() { 153 return $this->resubscribe !== false; // A missing value means "true" 154 } 155 156 /** 157 * @param bool $resubscribe 158 * @return WebSdkInitOptions 159 */ 160 public function setResubscribe($resubscribe) { 161 $this->resubscribe = $resubscribe !== false; 162 return $this; 163 } 164 165 /** 166 * @return array 167 */ 168 public function getAllowedSubscriptionDomains() { 169 return $this->allowedSubscriptionDomains; 170 } 171 172 /** 173 * @param array $allowedSubscriptionDomains 174 * @return WebSdkInitOptions 175 */ 176 public function setAllowedSubscriptionDomains($allowedSubscriptionDomains) { 177 $this->allowedSubscriptionDomains = $allowedSubscriptionDomains; 178 return $this; 179 } 180 181 /** 182 * @return mixed 183 */ 184 public function getSubscriptionNative() { 185 return $this->subscriptionNative; 186 } 187 188 /** 189 * @param mixed $subscriptionNative 190 * @return WebSdkInitOptions 191 */ 192 public function setSubscriptionNative($subscriptionNative) { 193 $this->subscriptionNative = $subscriptionNative; 194 return $this; 195 } 196 197 /** 198 * @return mixed 199 */ 200 public function getSubscriptionDialog() { 201 return $this->subscriptionDialog; 202 } 203 204 /** 205 * @param mixed $subscriptionDialog 206 * @return WebSdkInitOptions 207 */ 208 public function setSubscriptionDialog($subscriptionDialog) { 209 $this->subscriptionDialog = $subscriptionDialog; 210 return $this; 211 } 212 213 /** 214 * @return mixed 215 */ 216 public function getSubscriptionBell() { 217 return $this->subscriptionBell; 218 } 219 220 /** 221 * @param mixed $subscriptionBell 222 * @return WebSdkInitOptions 223 */ 224 public function setSubscriptionBell($subscriptionBell) { 225 $this->subscriptionBell = $subscriptionBell; 226 return $this; 227 } 228 229 /** 230 * @return mixed 231 */ 232 public function getSubscriptionBlurb() { 233 return $this->subscriptionBlurb; 234 } 235 236 /** 237 * @param mixed $subscriptionBlurb 238 * @return WebSdkInitOptions 239 */ 240 public function setSubscriptionBlurb($subscriptionBlurb) { 241 $this->subscriptionBlurb = $subscriptionBlurb; 242 return $this; 243 } 244 245 /** 246 * @return mixed 247 */ 248 public function getOptInOptions() { 249 return $this->optInOptions; 250 } 251 252 /** 253 * @param mixed $optInOptions 254 * @return WebSdkInitOptions 255 */ 256 public function setOptInOptions($optInOptions) { 257 $this->optInOptions = $optInOptions; 258 return $this; 259 } 260 261 /** 262 * @return mixed 263 */ 264 public function getPlugins() { 265 return $this->plugins; 266 } 267 268 /** 269 * @param mixed $plugins 270 * @return WebSdkInitOptions 271 */ 272 public function setPlugins($plugins) { 273 $this->plugins = $plugins; 274 return $this; 275 } 276 277 /** 278 * @return string 279 */ 280 public function getServiceWorkerUrl() { 281 return $this->serviceWorkerUrl; 282 } 283 284 /** 285 * @param string $serviceWorkerUrl 286 * @return WebSdkInitOptions 287 */ 288 public function setServiceWorkerUrl($serviceWorkerUrl) { 289 $this->serviceWorkerUrl = $serviceWorkerUrl; 290 return $this; 291 } 292 293 /** 294 * @return string 295 */ 296 public function getFrameUrl() { 297 return $this->frameUrl; 298 } 299 300 /** 301 * @param string $frameUrl 302 * @return WebSdkInitOptions 303 */ 304 public function setFrameUrl($frameUrl) { 305 $this->frameUrl = $frameUrl; 306 return $this; 307 } 308 127 309 } -
wonderpush-web-push-notifications/tags/1.12.0/lib/Params/DeliveriesCreateParams.php
r2663493 r3313743 117 117 118 118 /** 119 * @param int|int[] $segmentId A single id, an array of ids, or multiple id parameters. 120 * @return $this 121 */ 122 public function setTargetBrevoSegmentIds($segmentId) { 123 $this->targetType = 'targetBrevoSegmentIds'; 124 $this->targetValues = \WonderPush\Util\ArrayUtil::flatten(func_get_args()); 125 return $this; 126 } 127 128 /** 129 * @param int|int[] $listId A single id, an array of ids, or multiple id parameters. 130 * @return $this 131 */ 132 public function setTargetBrevoListIds($segmentId) { 133 $this->targetType = 'targetBrevoListIds'; 134 $this->targetValues = \WonderPush\Util\ArrayUtil::flatten(func_get_args()); 135 return $this; 136 } 137 138 /** 119 139 * @param array $segment A segment definition 120 140 * @return $this -
wonderpush-web-push-notifications/tags/1.12.0/lib/WonderPush.php
r2922221 r3313743 2 2 3 3 namespace WonderPush; 4 5 use WonderPush\Net\Request; 4 6 5 7 if (count(get_included_files()) === 1) { http_response_code(403); exit(); } // Prevent direct access … … 11 13 12 14 /** 13 * API base URL.15 * WonderPush Management API base URL. 14 16 * 15 17 * Must contain scheme, host and optional port. … … 19 21 * @see getApiRoot() 20 22 */ 21 const API_BASE = 'https://management-api.wonderpush.com'; // DO NOT END WITH SLASH 23 const WONDERPUSH_MANAGEMENT_API_BASE = 'https://management-api.wonderpush.com'; // DO NOT END WITH SLASH 24 25 /** 26 * @deprecated 27 */ 28 const API_BASE = self::WONDERPUSH_MANAGEMENT_API_BASE; 29 30 /** 31 * Brevo Management API base URL. 32 * 33 * Must contain scheme, host and optional port. 34 * Can contain an additional path. 35 * Must not end with a slash. 36 * @see getApiBase() 37 * @see getApiRoot() 38 */ 39 const BREVO_API_BASE = 'https://api.brevo.com/v3/wonderpush'; // DO NOT END WITH SLASH 22 40 23 41 /** … … 38 56 const VERSION = '2.1.2-dev'; 39 57 40 /** @var string*/41 private $ accessToken;58 /** @var Credentials */ 59 private $credentials; 42 60 /** @var string */ 43 61 private $applicationId; … … 88 106 89 107 /** 108 * Lazily initialized Campaigns endpoints. 109 * @var Api\Campaigns 110 */ 111 private $campaigns; 112 113 /** 90 114 * Lazily initialized Installations endpoints. 91 115 * @var Api\Installations … … 115 139 * You can find your credentials in the _Settings_ / _Configuration_ page of {@link https://dashboard.wonderpush.com/ your project dashboard}. 116 140 * 117 * @param string $accessToken141 * @param string|Credentials A credentials object, or a WonderPush access token string 118 142 * The Management API access token used to perform API calls. 119 143 * @param string $applicationId 120 144 * The application id corresponding to the access token. 121 145 */ 122 public function __construct($ accessToken, $applicationId = null) {123 $this-> accessToken = $accessToken;146 public function __construct($credentials, $applicationId = null) { 147 $this->credentials = is_string($credentials) ? new AccessTokenCredentials($credentials) : $credentials; 124 148 $this->applicationId = $applicationId; 149 } 150 151 public function getCredentials() { 152 return $this->credentials; 125 153 } 126 154 … … 198 226 * 199 227 * @return string 200 * @see API_BASE228 * @see WONDERPUSH_MANAGEMENT_API_BASE 201 229 */ 202 230 public function getApiBase() { 203 return $this->apiBase ?: self::API_BASE; 231 if ($this->apiBase) { 232 return $this->apiBase; 233 } 234 if ($this->credentials instanceof BrevoAPIKeyV3Credentials) { 235 return self::BREVO_API_BASE; 236 } 237 return self::WONDERPUSH_MANAGEMENT_API_BASE; 204 238 } 205 239 … … 285 319 286 320 /** 321 * Campaigns endpoints 322 * @return Api\Campaigns 323 */ 324 public function campaigns() { 325 if ($this->campaigns === null) { 326 $this->campaigns = new Api\Campaigns($this); 327 } 328 return $this->campaigns; 329 } 330 331 /** 287 332 * Stats endpoints 288 333 * @return Api\Stats … … 308 353 } 309 354 355 interface Credentials { 356 /** 357 * @param Request $request 358 * @return mixed 359 */ 360 public function authenticate($request); 361 } 362 363 class AccessTokenCredentials implements Credentials { 364 365 /** @var string */ 366 var $accessToken; 367 368 public function __construct($accessToken = null) { 369 $this->accessToken = $accessToken; 370 } 371 372 public function authenticate($request) { 373 $request->setQsParam('accessToken', $this->accessToken); 374 } 375 376 } 377 378 class BrevoAPIKeyV3Credentials implements Credentials { 379 380 /** @var string */ 381 var $apiKey; 382 383 public function __construct($apiKey = null) { 384 $this->apiKey = $apiKey; 385 } 386 387 public function authenticate($request) { 388 $request->setHeader('api-key', $this->apiKey); 389 } 390 391 } 392 310 393 WonderPush::setGlobalLogger(new Util\DefaultLogger()); -
wonderpush-web-push-notifications/tags/1.12.0/readme.txt
r3306411 r3313743 5 5 Requires at least: 5.0 6 6 Tested up to: 6.8.1 7 Stable tag: 1.1 1.67 Stable tag: 1.12.0 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.12.0 = 93 - Fixed compatibility with Brevo WordPress plugin 94 92 95 = 1.11.6 = 93 96 - Tested support for latest WordPress version -
wonderpush-web-push-notifications/tags/1.12.0/wonderpush-admin-page.css
r3097137 r3313743 94 94 margin-left: 5px; 95 95 } 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 96 .configuration-form { 112 97 text-align: left; … … 145 130 padding: 50px 0; 146 131 } 132 .metric { 133 display: inline-block; 134 text-align: center; 135 padding: 0 10px; 136 } 137 .metric span { 138 display: block; 139 } 140 .metric .legend { 141 font-size: 0.8em; 142 } 143 .metric .number { 144 font-size: 2em; 145 padding: 5px; 146 } -
wonderpush-web-push-notifications/tags/1.12.0/wonderpush-admin.php
r3306411 r3313743 3 3 4 4 class WonderPushAdmin { 5 const RESOURCES_VERSION = '1.1 1.6';5 const RESOURCES_VERSION = '1.12.0'; 6 6 const MENU_SLUG = 'wonderpush'; 7 7 const META_BOX_ID = 'wonderpush_meta_box'; -
wonderpush-web-push-notifications/tags/1.12.0/wonderpush-public.php
r3306411 r3313743 6 6 static function init() { 7 7 add_action('wp_head', array(__CLASS__, 'wonderpush_snippet'), 10); 8 // For AMP9 8 add_filter( 'the_content', array(__CLASS__, 'the_content'), 10); 10 9 if (WonderPushUtils::get_woocommerce() -
wonderpush-web-push-notifications/tags/1.12.0/wonderpush.php
r3306411 r3313743 8 8 Author: WonderPush 9 9 Author URI: https://www.wonderpush.com/ 10 Version: 1.1 1.610 Version: 1.12.0 11 11 License: GPLv2 or later 12 12 */ -
wonderpush-web-push-notifications/trunk/init.php
r2922221 r3313743 2 2 3 3 // WonderPush\Util 4 require(dirname(__FILE__) . '/lib/Util/JsonSerializable.php');5 require(dirname(__FILE__) . '/lib/Util/Logger.php');6 require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php');7 require(dirname(__FILE__) . '/lib/Util/ArrayUtil.php');8 require(dirname(__FILE__) . '/lib/Util/StringUtil.php');9 require(dirname(__FILE__) . '/lib/Util/TimeUnit.php');10 require(dirname(__FILE__) . '/lib/Util/TimeUtil.php');11 require(dirname(__FILE__) . '/lib/Util/TimeValue.php');12 require(dirname(__FILE__) . '/lib/Util/UrlUtil.php');4 if (!interface_exists('WonderPush\Util\JsonSerializable')) require(dirname(__FILE__) . '/lib/Util/JsonSerializable.php'); 5 if (!interface_exists('WonderPush\Util\Logger')) require(dirname(__FILE__) . '/lib/Util/Logger.php'); 6 if (!class_exists('WonderPush\Util\DefaultLogger')) require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php'); 7 if (!class_exists('WonderPush\Util\ArrayUtil')) require(dirname(__FILE__) . '/lib/Util/ArrayUtil.php'); 8 if (!class_exists('WonderPush\Util\StringUtil')) require(dirname(__FILE__) . '/lib/Util/StringUtil.php'); 9 if (!class_exists('WonderPush\Util\TimeUnit')) require(dirname(__FILE__) . '/lib/Util/TimeUnit.php'); 10 if (!class_exists('WonderPush\Util\TimeUtil')) require(dirname(__FILE__) . '/lib/Util/TimeUtil.php'); 11 if (!class_exists('WonderPush\Util\TimeValue')) require(dirname(__FILE__) . '/lib/Util/TimeValue.php'); 12 if (!class_exists('WonderPush\Util\UrlUtil')) require(dirname(__FILE__) . '/lib/Util/UrlUtil.php'); 13 13 14 14 // WonderPush 15 require(dirname(__FILE__) . '/lib/WonderPush.php');15 if (!class_exists('WonderPush\WonderPush')) require(dirname(__FILE__) . '/lib/WonderPush.php'); 16 16 17 17 // WonderPush\Obj 18 require(dirname(__FILE__) . '/lib/Obj/BaseObject.php'); 19 require(dirname(__FILE__) . '/lib/Obj/SuccessResponse.php'); 20 require(dirname(__FILE__) . '/lib/Obj/DeliveriesCreateResponse.php'); 21 require(dirname(__FILE__) . '/lib/Obj/Pagination.php'); 22 require(dirname(__FILE__) . '/lib/Obj/NullObject.php'); 23 require(dirname(__FILE__) . '/lib/Obj/Application.php'); 24 require(dirname(__FILE__) . '/lib/Obj/Segment.php'); 25 require(dirname(__FILE__) . '/lib/Obj/GeoLocation.php'); 26 require(dirname(__FILE__) . '/lib/Obj/User.php'); 27 require(dirname(__FILE__) . '/lib/Obj/Collection.php'); 28 require(dirname(__FILE__) . '/lib/Obj/ApplicationCollection.php'); 29 require(dirname(__FILE__) . '/lib/Obj/SegmentCollection.php'); 30 require(dirname(__FILE__) . '/lib/Obj/Installation.php'); 31 require(dirname(__FILE__) . '/lib/Obj/InstallationCollection.php'); 32 require(dirname(__FILE__) . '/lib/Obj/InstallationApplicationApple.php'); 33 require(dirname(__FILE__) . '/lib/Obj/InstallationApplication.php'); 34 require(dirname(__FILE__) . '/lib/Obj/InstallationDeviceCapabilities.php'); 35 require(dirname(__FILE__) . '/lib/Obj/InstallationDeviceConfiguration.php'); 36 require(dirname(__FILE__) . '/lib/Obj/InstallationDevice.php'); 37 require(dirname(__FILE__) . '/lib/Obj/InstallationPreferences.php'); 38 require(dirname(__FILE__) . '/lib/Obj/InstallationPushToken.php'); 39 require(dirname(__FILE__) . '/lib/Obj/Event.php'); 40 require(dirname(__FILE__) . '/lib/Obj/FrequentFieldValues.php'); 41 require(dirname(__FILE__) . '/lib/Obj/NotificationButton.php'); 42 require(dirname(__FILE__) . '/lib/Obj/NotificationButtonAction.php'); 43 require(dirname(__FILE__) . '/lib/Obj/NotificationButtonActionEvent.php'); 44 require(dirname(__FILE__) . '/lib/Obj/Notification.php'); 45 require(dirname(__FILE__) . '/lib/Obj/NotificationAlert.php'); 46 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertAndroid.php'); 47 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertAndroidButton.php'); 48 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIos.php'); 49 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIosAttachment.php'); 50 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIosForeground.php'); 51 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertWeb.php'); 52 require(dirname(__FILE__) . '/lib/Obj/NotificationAlertWebButton.php'); 53 require(dirname(__FILE__) . '/lib/Obj/NotificationInApp.php'); 54 require(dirname(__FILE__) . '/lib/Obj/NotificationInAppButton.php'); 55 require(dirname(__FILE__) . '/lib/Obj/NotificationInAppMap.php'); 56 require(dirname(__FILE__) . '/lib/Obj/NotificationInAppMapPlace.php'); 57 require(dirname(__FILE__) . '/lib/Obj/NotificationPush.php'); 58 require(dirname(__FILE__) . '/lib/Obj/NotificationPushAndroid.php'); 59 require(dirname(__FILE__) . '/lib/Obj/NotificationPushIos.php'); 60 require(dirname(__FILE__) . '/lib/Obj/NotificationPushWeb.php'); 61 require(dirname(__FILE__) . '/lib/Obj/WebSdkInitOptions.php'); 18 if (!class_exists('WonderPush\Obj\BaseObject')) require(dirname(__FILE__) . '/lib/Obj/BaseObject.php'); 19 if (!class_exists('WonderPush\Obj\SuccessResponse')) require(dirname(__FILE__) . '/lib/Obj/SuccessResponse.php'); 20 if (!class_exists('WonderPush\Obj\CampaignSuccessResponse')) require(dirname(__FILE__) . '/lib/Obj/CampaignSuccessResponse.php'); 21 if (!class_exists('WonderPush\Obj\DeliveriesCreateResponse')) require(dirname(__FILE__) . '/lib/Obj/DeliveriesCreateResponse.php'); 22 if (!class_exists('WonderPush\Obj\Pagination')) require(dirname(__FILE__) . '/lib/Obj/Pagination.php'); 23 if (!class_exists('WonderPush\Obj\NullObject')) require(dirname(__FILE__) . '/lib/Obj/NullObject.php'); 24 if (!class_exists('WonderPush\Obj\Application')) require(dirname(__FILE__) . '/lib/Obj/Application.php'); 25 if (!class_exists('WonderPush\Obj\Segment')) require(dirname(__FILE__) . '/lib/Obj/Segment.php'); 26 if (!class_exists('WonderPush\Obj\GeoLocation')) require(dirname(__FILE__) . '/lib/Obj/GeoLocation.php'); 27 if (!class_exists('WonderPush\Obj\User')) require(dirname(__FILE__) . '/lib/Obj/User.php'); 28 if (!class_exists('WonderPush\Obj\Collection')) require(dirname(__FILE__) . '/lib/Obj/Collection.php'); 29 if (!class_exists('WonderPush\Obj\CampaignCollection')) require(dirname(__FILE__) . '/lib/Obj/CampaignCollection.php'); 30 if (!class_exists('WonderPush\Obj\ApplicationCollection')) require(dirname(__FILE__) . '/lib/Obj/ApplicationCollection.php'); 31 if (!class_exists('WonderPush\Obj\SegmentCollection')) require(dirname(__FILE__) . '/lib/Obj/SegmentCollection.php'); 32 if (!class_exists('WonderPush\Obj\Installation')) require(dirname(__FILE__) . '/lib/Obj/Installation.php'); 33 if (!class_exists('WonderPush\Obj\InstallationCollection')) require(dirname(__FILE__) . '/lib/Obj/InstallationCollection.php'); 34 if (!class_exists('WonderPush\Obj\InstallationApplicationApple')) require(dirname(__FILE__) . '/lib/Obj/InstallationApplicationApple.php'); 35 if (!class_exists('WonderPush\Obj\InstallationApplication')) require(dirname(__FILE__) . '/lib/Obj/InstallationApplication.php'); 36 if (!class_exists('WonderPush\Obj\InstallationDeviceCapabilities')) require(dirname(__FILE__) . '/lib/Obj/InstallationDeviceCapabilities.php'); 37 if (!class_exists('WonderPush\Obj\InstallationDeviceConfiguration')) require(dirname(__FILE__) . '/lib/Obj/InstallationDeviceConfiguration.php'); 38 if (!class_exists('WonderPush\Obj\InstallationDevice')) require(dirname(__FILE__) . '/lib/Obj/InstallationDevice.php'); 39 if (!class_exists('WonderPush\Obj\InstallationPreferences')) require(dirname(__FILE__) . '/lib/Obj/InstallationPreferences.php'); 40 if (!class_exists('WonderPush\Obj\InstallationPushToken')) require(dirname(__FILE__) . '/lib/Obj/InstallationPushToken.php'); 41 if (!class_exists('WonderPush\Obj\Event')) require(dirname(__FILE__) . '/lib/Obj/Event.php'); 42 if (!class_exists('WonderPush\Obj\FrequentFieldValues')) require(dirname(__FILE__) . '/lib/Obj/FrequentFieldValues.php'); 43 if (!class_exists('WonderPush\Obj\NotificationButton')) require(dirname(__FILE__) . '/lib/Obj/NotificationButton.php'); 44 if (!class_exists('WonderPush\Obj\NotificationButtonAction')) require(dirname(__FILE__) . '/lib/Obj/NotificationButtonAction.php'); 45 if (!class_exists('WonderPush\Obj\NotificationButtonActionEvent')) require(dirname(__FILE__) . '/lib/Obj/NotificationButtonActionEvent.php'); 46 if (!class_exists('WonderPush\Obj\Notification')) require(dirname(__FILE__) . '/lib/Obj/Notification.php'); 47 if (!class_exists('WonderPush\Obj\NotificationAlert')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlert.php'); 48 if (!class_exists('WonderPush\Obj\NotificationAlertAndroid')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertAndroid.php'); 49 if (!class_exists('WonderPush\Obj\NotificationAlertAndroidButton')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertAndroidButton.php'); 50 if (!class_exists('WonderPush\Obj\NotificationAlertIos')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIos.php'); 51 if (!class_exists('WonderPush\Obj\NotificationAlertIosAttachment')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIosAttachment.php'); 52 if (!class_exists('WonderPush\Obj\NotificationAlertIosForeground')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertIosForeground.php'); 53 if (!class_exists('WonderPush\Obj\NotificationAlertWeb')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertWeb.php'); 54 if (!class_exists('WonderPush\Obj\NotificationAlertWebButton')) require(dirname(__FILE__) . '/lib/Obj/NotificationAlertWebButton.php'); 55 if (!class_exists('WonderPush\Obj\NotificationInApp')) require(dirname(__FILE__) . '/lib/Obj/NotificationInApp.php'); 56 if (!class_exists('WonderPush\Obj\NotificationInAppButton')) require(dirname(__FILE__) . '/lib/Obj/NotificationInAppButton.php'); 57 if (!class_exists('WonderPush\Obj\NotificationInAppMap')) require(dirname(__FILE__) . '/lib/Obj/NotificationInAppMap.php'); 58 if (!class_exists('WonderPush\Obj\NotificationInAppMapPlace')) require(dirname(__FILE__) . '/lib/Obj/NotificationInAppMapPlace.php'); 59 if (!class_exists('WonderPush\Obj\NotificationPush')) require(dirname(__FILE__) . '/lib/Obj/NotificationPush.php'); 60 if (!class_exists('WonderPush\Obj\NotificationPushAndroid')) require(dirname(__FILE__) . '/lib/Obj/NotificationPushAndroid.php'); 61 if (!class_exists('WonderPush\Obj\NotificationPushIos')) require(dirname(__FILE__) . '/lib/Obj/NotificationPushIos.php'); 62 if (!class_exists('WonderPush\Obj\NotificationPushWeb')) require(dirname(__FILE__) . '/lib/Obj/NotificationPushWeb.php'); 63 if (!class_exists('WonderPush\Obj\Campaign')) require(dirname(__FILE__) . '/lib/Obj/Campaign.php'); 64 if (!class_exists('WonderPush\Obj\CampaignSchedule')) require(dirname(__FILE__) . '/lib/Obj/CampaignSchedule.php'); 65 if (!class_exists('WonderPush\Obj\CampaignSchedulePressure')) require(dirname(__FILE__) . '/lib/Obj/CampaignSchedulePressure.php'); 66 if (!class_exists('WonderPush\Obj\CampaignScheduleUrlCriterion')) require(dirname(__FILE__) . '/lib/Obj/CampaignScheduleUrlCriterion.php'); 67 if (!class_exists('WonderPush\Obj\CampaignStats')) require(dirname(__FILE__) . '/lib/Obj/CampaignStats.php'); 68 if (!class_exists('WonderPush\Obj\CampaignUrlFilters')) require(dirname(__FILE__) . '/lib/Obj/CampaignUrlFilters.php'); 69 if (!class_exists('WonderPush\Obj\CampaignCapping')) require(dirname(__FILE__) . '/lib/Obj/CampaignCapping.php'); 70 71 if (!class_exists('WonderPush\Obj\WebSdkInitOptions')) require(dirname(__FILE__) . '/lib/Obj/WebSdkInitOptions.php'); 62 72 63 73 // WonderPush\Params 64 require(dirname(__FILE__) . '/lib/Params/CollectionParams.php'); 65 require(dirname(__FILE__) . '/lib/Params/DeliveriesCreateParams.php'); 66 require(dirname(__FILE__) . '/lib/Params/FrequentFieldValuesParams.php'); 67 require(dirname(__FILE__) . '/lib/Params/AllInstallationsParams.php'); 68 require(dirname(__FILE__) . '/lib/Params/PatchInstallationParams.php'); 69 require(dirname(__FILE__) . '/lib/Params/TrackEventParams.php'); 74 if (!class_exists('WonderPush\Params\CollectionParams')) require(dirname(__FILE__) . '/lib/Params/CollectionParams.php'); 75 if (!class_exists('WonderPush\Params\DeliveriesCreateParams')) require(dirname(__FILE__) . '/lib/Params/DeliveriesCreateParams.php'); 76 if (!class_exists('WonderPush\Params\FrequentFieldValuesParams')) require(dirname(__FILE__) . '/lib/Params/FrequentFieldValuesParams.php'); 77 if (!class_exists('WonderPush\Params\AllInstallationsParams')) require(dirname(__FILE__) . '/lib/Params/AllInstallationsParams.php'); 78 if (!class_exists('WonderPush\Params\PatchInstallationParams')) require(dirname(__FILE__) . '/lib/Params/PatchInstallationParams.php'); 79 if (!class_exists('WonderPush\Params\TrackEventParams')) require(dirname(__FILE__) . '/lib/Params/TrackEventParams.php'); 80 if (!class_exists('WonderPush\Params\PatchCampaignParams')) require(dirname(__FILE__) . '/lib/Params/PatchCampaignParams.php'); 81 if (!class_exists('WonderPush\Params\CreateCampaignParams')) require(dirname(__FILE__) . '/lib/Params/CreateCampaignParams.php'); 70 82 71 83 // WonderPush\Net 72 require(dirname(__FILE__) . '/lib/Net/Request.php');73 require(dirname(__FILE__) . '/lib/Net/Response.php');74 require(dirname(__FILE__) . '/lib/Net/HttpClientInterface.php');75 require(dirname(__FILE__) . '/lib/Net/CurlHttpClient.php');84 if (!class_exists('WonderPush\Net\Request')) require(dirname(__FILE__) . '/lib/Net/Request.php'); 85 if (!class_exists('WonderPush\Net\Response')) require(dirname(__FILE__) . '/lib/Net/Response.php'); 86 if (!interface_exists('WonderPush\Net\HttpClientInterface')) require(dirname(__FILE__) . '/lib/Net/HttpClientInterface.php'); 87 if (!class_exists('WonderPush\Net\CurlHttpClient')) require(dirname(__FILE__) . '/lib/Net/CurlHttpClient.php'); 76 88 77 89 // WonderPush\Errors 78 require(dirname(__FILE__) . '/lib/Errors/Base.php');79 require(dirname(__FILE__) . '/lib/Errors/Parsing.php');80 require(dirname(__FILE__) . '/lib/Errors/Server.php');81 require(dirname(__FILE__) . '/lib/Errors/Network.php');90 if (!class_exists('WonderPush\Errors\Base')) require(dirname(__FILE__) . '/lib/Errors/Base.php'); 91 if (!class_exists('WonderPush\Errors\Parsing')) require(dirname(__FILE__) . '/lib/Errors/Parsing.php'); 92 if (!class_exists('WonderPush\Errors\Server')) require(dirname(__FILE__) . '/lib/Errors/Server.php'); 93 if (!class_exists('WonderPush\Errors\Network')) require(dirname(__FILE__) . '/lib/Errors/Network.php'); 82 94 83 95 // WonderPush\Api 84 require(dirname(__FILE__) . '/lib/Api/Rest.php'); 85 require(dirname(__FILE__) . '/lib/Api/Deliveries.php'); 86 require(dirname(__FILE__) . '/lib/Api/Applications.php'); 87 require(dirname(__FILE__) . '/lib/Api/Segments.php'); 88 require(dirname(__FILE__) . '/lib/Api/Stats.php'); 89 require(dirname(__FILE__) . '/lib/Api/Installations.php'); 90 require(dirname(__FILE__) . '/lib/Api/Events.php'); 96 if (!class_exists('WonderPush\Api\Rest')) require(dirname(__FILE__) . '/lib/Api/Rest.php'); 97 if (!class_exists('WonderPush\Api\Deliveries')) require(dirname(__FILE__) . '/lib/Api/Deliveries.php'); 98 if (!class_exists('WonderPush\Api\Applications')) require(dirname(__FILE__) . '/lib/Api/Applications.php'); 99 if (!class_exists('WonderPush\Api\Segments')) require(dirname(__FILE__) . '/lib/Api/Segments.php'); 100 if (!class_exists('WonderPush\Api\Stats')) require(dirname(__FILE__) . '/lib/Api/Stats.php'); 101 if (!class_exists('WonderPush\Api\Installations')) require(dirname(__FILE__) . '/lib/Api/Installations.php'); 102 if (!class_exists('WonderPush\Api\Campaigns')) require(dirname(__FILE__) . '/lib/Api/Campaigns.php'); 103 if (!class_exists('WonderPush\Api\Events')) require(dirname(__FILE__) . '/lib/Api/Events.php'); -
wonderpush-web-push-notifications/trunk/lib/Api/Rest.php
r2481484 r3313743 38 38 $rtn->setPath($path); 39 39 $rtn->setParams($params); 40 $rtn->setQsParam s(array_filter(array(41 'accessToken' => $this->wp->getAccessToken(),42 'applicationId' => $this->wp->getApplicationId(), // filtered if null43 )));40 $rtn->setQsParam('applicationId', $this->wp->getApplicationId()); // filtered if null 41 if ($this->wp->getCredentials()) { 42 $this->wp->getCredentials()->authenticate($rtn); 43 } 44 44 return $rtn; 45 45 } -
wonderpush-web-push-notifications/trunk/lib/Net/CurlHttpClient.php
r3097137 r3313743 9 9 */ 10 10 class CurlHttpClient implements HttpClientInterface { 11 12 public static $logging = false; 13 public static $loggingResponses = false; 11 14 12 15 /** … … 53 56 case Request::GET: 54 57 case Request::DELETE: 55 $qsParams = array_merge($qsParams , $request->getParams());58 $qsParams = array_merge($qsParams ?: array(), $request->getParams()); 56 59 break; 57 60 case Request::PUT: … … 59 62 case Request::PATCH: 60 63 $body = $request->getParams(); 61 if (empty($body)) { 64 $files = $request->getFiles(); 65 if (count($files)) { 66 $body = $request->getParams() ?: array(); 67 foreach ($files as $name => $file) { 68 $body[$name] = new \CURLFile($file['tmp_name'], $file['type'], $file['name']); 69 } 70 } else if (empty($body)) { 62 71 $body = null; 63 72 } else { … … 133 142 134 143 // Execute cURL request 144 $start = microtime(true); 135 145 $rawResponse = curl_exec($ch); 146 if (self::$logging) { 147 error_log('--> ' . $request->getMethod() . ' ' . $url . ' ' . $body . (empty($headers) ? '' : ' ' . json_encode($headers)) . ' (' . intval(1000 * (microtime(true) - $start)) . 'ms)'); 148 } 136 149 137 150 // Parse response … … 155 168 } 156 169 170 if (self::$logging && self::$loggingResponses) { 171 error_log('<-- (' . $response->getStatusCode() . ') ' . ($response->getRawBody() ?: '<no body>') . (empty($response->getHeaders()) ? '' : ' ' . json_encode($response->getHeaders()))); 172 } 173 157 174 // Cleanup 158 175 curl_close($ch); -
wonderpush-web-push-notifications/trunk/lib/Net/Request.php
r2481484 r3313743 78 78 79 79 /** 80 * An associative array of 'paramName' => ['tmp_name' => '/full/path','name' => 'filename.png', 'type' => 'image/png']. 81 * @var mixed 82 */ 83 private $files = array(); 84 85 /** 80 86 * HTTP headers. 81 87 * @var mixed[] … … 174 180 175 181 /** 182 * @param $key 183 * @param $value 184 * @return $this 185 */ 186 public function setQsParam($key, $value) { 187 if ($key === null) return $this; 188 if (!$this->qsParams) { 189 $this->qsParams = array(); 190 } 191 if ($value === null) { 192 unset($this->qsParams[$key]); 193 } else { 194 $this->qsParams[$key] = $value; 195 } 196 return $this; 197 } 198 199 public function addFile($paramName, $filename, $path, $type) { 200 $this->files[$paramName] = array( 201 'name' => $filename, 202 'tmp_name' => $path, 203 'type' => $type, 204 ); 205 return $this; 206 } 207 208 public function removeFile($paramName) { 209 unset($this->files[$paramName]); 210 return $this; 211 } 212 213 public function getFiles() { 214 return $this->files; 215 } 216 217 /** 176 218 * The body parameters. 177 219 * … … 215 257 } 216 258 259 /** 260 * @param $key 261 * @param $value 262 * @return $this 263 */ 264 public function setHeader($key, $value) { 265 if ($key === null) return $this; 266 if (!$this->headers) { 267 $this->headers = array(); 268 } 269 if ($value === null) { 270 unset($this->headers[$key]); 271 } else { 272 $this->headers[$key] = $value; 273 } 274 return $this; 275 } 217 276 } -
wonderpush-web-push-notifications/trunk/lib/Obj/Application.php
r2588630 r3313743 27 27 /** @var object */ 28 28 private $urlParameters; 29 /** @var string */ 30 private $status; 31 /** @var integer */ 32 private $subscribers; 33 /** @var array */ 34 private $pushDisabledPlatforms; 35 /** @var boolean */ 36 private $wordPressSnippetDeactivated; 29 37 30 38 /** … … 140 148 return $this; 141 149 } 150 151 /** 152 * @return string|null 153 */ 154 public function getStatus() 155 { 156 return $this->status ?: null; 157 } 158 159 /** 160 * @param string $status 161 * @return Application 162 */ 163 public function setStatus($status) 164 { 165 $this->status = $status; 166 return $this; 167 } 168 169 /** 170 * @return int 171 */ 172 public function getSubscribers() 173 { 174 return $this->subscribers ?: 0; 175 } 176 177 /** 178 * @param int $subscribers 179 * @return Application 180 */ 181 public function setSubscribers( $subscribers ) 182 { 183 $this->subscribers = $subscribers; 184 return $this; 185 } 186 187 /** 188 * @return array 189 */ 190 public function getPushDisabledPlatforms() 191 { 192 return $this->pushDisabledPlatforms; 193 } 194 195 /** 196 * @param array $pushDisabledPlatforms 197 * @return Application 198 */ 199 public function setPushDisabledPlatforms($pushDisabledPlatforms) 200 { 201 $this->pushDisabledPlatforms = (array)$pushDisabledPlatforms; 202 return $this; 203 } 204 205 public function getWordPressSnippetDeactivated() 206 { 207 return (bool)$this->wordPressSnippetDeactivated; 208 } 209 210 public function setWordPressSnippetDeactivated($wordPressSnippetDeactivated) 211 { 212 $this->wordPressSnippetDeactivated = (bool)$wordPressSnippetDeactivated; 213 return $this; 214 } 142 215 } -
wonderpush-web-push-notifications/trunk/lib/Obj/WebSdkInitOptions.php
r2481484 r3313743 19 19 /** @var string */ 20 20 private $manifestUrl; 21 /** @var bool */ 22 private $resubscribe; 23 24 /** @var array */ 25 private $allowedSubscriptionDomains; 26 /** @var mixed */ 27 private $subscriptionNative; 28 /** @var mixed */ 29 private $subscriptionDialog; 30 /** @var mixed */ 31 private $subscriptionBell; 32 /** @var mixed */ 33 private $subscriptionBlurb; 34 /** @var mixed */ 35 private $optInOptions; 36 /** @var mixed */ 37 private $plugins; 38 /** @var string */ 39 private $serviceWorkerUrl; 40 /** @var string */ 41 private $frameUrl; 21 42 22 43 /** … … 125 146 return null; 126 147 } 148 149 /** 150 * @return bool 151 */ 152 public function getResubscribe() { 153 return $this->resubscribe !== false; // A missing value means "true" 154 } 155 156 /** 157 * @param bool $resubscribe 158 * @return WebSdkInitOptions 159 */ 160 public function setResubscribe($resubscribe) { 161 $this->resubscribe = $resubscribe !== false; 162 return $this; 163 } 164 165 /** 166 * @return array 167 */ 168 public function getAllowedSubscriptionDomains() { 169 return $this->allowedSubscriptionDomains; 170 } 171 172 /** 173 * @param array $allowedSubscriptionDomains 174 * @return WebSdkInitOptions 175 */ 176 public function setAllowedSubscriptionDomains($allowedSubscriptionDomains) { 177 $this->allowedSubscriptionDomains = $allowedSubscriptionDomains; 178 return $this; 179 } 180 181 /** 182 * @return mixed 183 */ 184 public function getSubscriptionNative() { 185 return $this->subscriptionNative; 186 } 187 188 /** 189 * @param mixed $subscriptionNative 190 * @return WebSdkInitOptions 191 */ 192 public function setSubscriptionNative($subscriptionNative) { 193 $this->subscriptionNative = $subscriptionNative; 194 return $this; 195 } 196 197 /** 198 * @return mixed 199 */ 200 public function getSubscriptionDialog() { 201 return $this->subscriptionDialog; 202 } 203 204 /** 205 * @param mixed $subscriptionDialog 206 * @return WebSdkInitOptions 207 */ 208 public function setSubscriptionDialog($subscriptionDialog) { 209 $this->subscriptionDialog = $subscriptionDialog; 210 return $this; 211 } 212 213 /** 214 * @return mixed 215 */ 216 public function getSubscriptionBell() { 217 return $this->subscriptionBell; 218 } 219 220 /** 221 * @param mixed $subscriptionBell 222 * @return WebSdkInitOptions 223 */ 224 public function setSubscriptionBell($subscriptionBell) { 225 $this->subscriptionBell = $subscriptionBell; 226 return $this; 227 } 228 229 /** 230 * @return mixed 231 */ 232 public function getSubscriptionBlurb() { 233 return $this->subscriptionBlurb; 234 } 235 236 /** 237 * @param mixed $subscriptionBlurb 238 * @return WebSdkInitOptions 239 */ 240 public function setSubscriptionBlurb($subscriptionBlurb) { 241 $this->subscriptionBlurb = $subscriptionBlurb; 242 return $this; 243 } 244 245 /** 246 * @return mixed 247 */ 248 public function getOptInOptions() { 249 return $this->optInOptions; 250 } 251 252 /** 253 * @param mixed $optInOptions 254 * @return WebSdkInitOptions 255 */ 256 public function setOptInOptions($optInOptions) { 257 $this->optInOptions = $optInOptions; 258 return $this; 259 } 260 261 /** 262 * @return mixed 263 */ 264 public function getPlugins() { 265 return $this->plugins; 266 } 267 268 /** 269 * @param mixed $plugins 270 * @return WebSdkInitOptions 271 */ 272 public function setPlugins($plugins) { 273 $this->plugins = $plugins; 274 return $this; 275 } 276 277 /** 278 * @return string 279 */ 280 public function getServiceWorkerUrl() { 281 return $this->serviceWorkerUrl; 282 } 283 284 /** 285 * @param string $serviceWorkerUrl 286 * @return WebSdkInitOptions 287 */ 288 public function setServiceWorkerUrl($serviceWorkerUrl) { 289 $this->serviceWorkerUrl = $serviceWorkerUrl; 290 return $this; 291 } 292 293 /** 294 * @return string 295 */ 296 public function getFrameUrl() { 297 return $this->frameUrl; 298 } 299 300 /** 301 * @param string $frameUrl 302 * @return WebSdkInitOptions 303 */ 304 public function setFrameUrl($frameUrl) { 305 $this->frameUrl = $frameUrl; 306 return $this; 307 } 308 127 309 } -
wonderpush-web-push-notifications/trunk/lib/Params/DeliveriesCreateParams.php
r2663493 r3313743 117 117 118 118 /** 119 * @param int|int[] $segmentId A single id, an array of ids, or multiple id parameters. 120 * @return $this 121 */ 122 public function setTargetBrevoSegmentIds($segmentId) { 123 $this->targetType = 'targetBrevoSegmentIds'; 124 $this->targetValues = \WonderPush\Util\ArrayUtil::flatten(func_get_args()); 125 return $this; 126 } 127 128 /** 129 * @param int|int[] $listId A single id, an array of ids, or multiple id parameters. 130 * @return $this 131 */ 132 public function setTargetBrevoListIds($segmentId) { 133 $this->targetType = 'targetBrevoListIds'; 134 $this->targetValues = \WonderPush\Util\ArrayUtil::flatten(func_get_args()); 135 return $this; 136 } 137 138 /** 119 139 * @param array $segment A segment definition 120 140 * @return $this -
wonderpush-web-push-notifications/trunk/lib/WonderPush.php
r2922221 r3313743 2 2 3 3 namespace WonderPush; 4 5 use WonderPush\Net\Request; 4 6 5 7 if (count(get_included_files()) === 1) { http_response_code(403); exit(); } // Prevent direct access … … 11 13 12 14 /** 13 * API base URL.15 * WonderPush Management API base URL. 14 16 * 15 17 * Must contain scheme, host and optional port. … … 19 21 * @see getApiRoot() 20 22 */ 21 const API_BASE = 'https://management-api.wonderpush.com'; // DO NOT END WITH SLASH 23 const WONDERPUSH_MANAGEMENT_API_BASE = 'https://management-api.wonderpush.com'; // DO NOT END WITH SLASH 24 25 /** 26 * @deprecated 27 */ 28 const API_BASE = self::WONDERPUSH_MANAGEMENT_API_BASE; 29 30 /** 31 * Brevo Management API base URL. 32 * 33 * Must contain scheme, host and optional port. 34 * Can contain an additional path. 35 * Must not end with a slash. 36 * @see getApiBase() 37 * @see getApiRoot() 38 */ 39 const BREVO_API_BASE = 'https://api.brevo.com/v3/wonderpush'; // DO NOT END WITH SLASH 22 40 23 41 /** … … 38 56 const VERSION = '2.1.2-dev'; 39 57 40 /** @var string*/41 private $ accessToken;58 /** @var Credentials */ 59 private $credentials; 42 60 /** @var string */ 43 61 private $applicationId; … … 88 106 89 107 /** 108 * Lazily initialized Campaigns endpoints. 109 * @var Api\Campaigns 110 */ 111 private $campaigns; 112 113 /** 90 114 * Lazily initialized Installations endpoints. 91 115 * @var Api\Installations … … 115 139 * You can find your credentials in the _Settings_ / _Configuration_ page of {@link https://dashboard.wonderpush.com/ your project dashboard}. 116 140 * 117 * @param string $accessToken141 * @param string|Credentials A credentials object, or a WonderPush access token string 118 142 * The Management API access token used to perform API calls. 119 143 * @param string $applicationId 120 144 * The application id corresponding to the access token. 121 145 */ 122 public function __construct($ accessToken, $applicationId = null) {123 $this-> accessToken = $accessToken;146 public function __construct($credentials, $applicationId = null) { 147 $this->credentials = is_string($credentials) ? new AccessTokenCredentials($credentials) : $credentials; 124 148 $this->applicationId = $applicationId; 149 } 150 151 public function getCredentials() { 152 return $this->credentials; 125 153 } 126 154 … … 198 226 * 199 227 * @return string 200 * @see API_BASE228 * @see WONDERPUSH_MANAGEMENT_API_BASE 201 229 */ 202 230 public function getApiBase() { 203 return $this->apiBase ?: self::API_BASE; 231 if ($this->apiBase) { 232 return $this->apiBase; 233 } 234 if ($this->credentials instanceof BrevoAPIKeyV3Credentials) { 235 return self::BREVO_API_BASE; 236 } 237 return self::WONDERPUSH_MANAGEMENT_API_BASE; 204 238 } 205 239 … … 285 319 286 320 /** 321 * Campaigns endpoints 322 * @return Api\Campaigns 323 */ 324 public function campaigns() { 325 if ($this->campaigns === null) { 326 $this->campaigns = new Api\Campaigns($this); 327 } 328 return $this->campaigns; 329 } 330 331 /** 287 332 * Stats endpoints 288 333 * @return Api\Stats … … 308 353 } 309 354 355 interface Credentials { 356 /** 357 * @param Request $request 358 * @return mixed 359 */ 360 public function authenticate($request); 361 } 362 363 class AccessTokenCredentials implements Credentials { 364 365 /** @var string */ 366 var $accessToken; 367 368 public function __construct($accessToken = null) { 369 $this->accessToken = $accessToken; 370 } 371 372 public function authenticate($request) { 373 $request->setQsParam('accessToken', $this->accessToken); 374 } 375 376 } 377 378 class BrevoAPIKeyV3Credentials implements Credentials { 379 380 /** @var string */ 381 var $apiKey; 382 383 public function __construct($apiKey = null) { 384 $this->apiKey = $apiKey; 385 } 386 387 public function authenticate($request) { 388 $request->setHeader('api-key', $this->apiKey); 389 } 390 391 } 392 310 393 WonderPush::setGlobalLogger(new Util\DefaultLogger()); -
wonderpush-web-push-notifications/trunk/readme.txt
r3306411 r3313743 5 5 Requires at least: 5.0 6 6 Tested up to: 6.8.1 7 Stable tag: 1.1 1.67 Stable tag: 1.12.0 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.12.0 = 93 - Fixed compatibility with Brevo WordPress plugin 94 92 95 = 1.11.6 = 93 96 - Tested support for latest WordPress version -
wonderpush-web-push-notifications/trunk/wonderpush-admin-page.css
r3097137 r3313743 94 94 margin-left: 5px; 95 95 } 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 96 .configuration-form { 112 97 text-align: left; … … 145 130 padding: 50px 0; 146 131 } 132 .metric { 133 display: inline-block; 134 text-align: center; 135 padding: 0 10px; 136 } 137 .metric span { 138 display: block; 139 } 140 .metric .legend { 141 font-size: 0.8em; 142 } 143 .metric .number { 144 font-size: 2em; 145 padding: 5px; 146 } -
wonderpush-web-push-notifications/trunk/wonderpush-admin.php
r3306411 r3313743 3 3 4 4 class WonderPushAdmin { 5 const RESOURCES_VERSION = '1.1 1.6';5 const RESOURCES_VERSION = '1.12.0'; 6 6 const MENU_SLUG = 'wonderpush'; 7 7 const META_BOX_ID = 'wonderpush_meta_box'; -
wonderpush-web-push-notifications/trunk/wonderpush-public.php
r3306411 r3313743 6 6 static function init() { 7 7 add_action('wp_head', array(__CLASS__, 'wonderpush_snippet'), 10); 8 // For AMP9 8 add_filter( 'the_content', array(__CLASS__, 'the_content'), 10); 10 9 if (WonderPushUtils::get_woocommerce() -
wonderpush-web-push-notifications/trunk/wonderpush.php
r3306411 r3313743 8 8 Author: WonderPush 9 9 Author URI: https://www.wonderpush.com/ 10 Version: 1.1 1.610 Version: 1.12.0 11 11 License: GPLv2 or later 12 12 */
Note: See TracChangeset
for help on using the changeset viewer.