PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / trunk
Brevo – Email, SMS, Web Push, Chat, and more. vtrunk
2.9.13 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.2 3.1.20 3.1.21 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.1.29 3.1.3 3.1.30 3.1.31 3.1.32 3.1.33 3.1.34 3.1.35 3.1.36 3.1.37 3.1.38 3.1.39 3.1.4 3.1.40 3.1.41 3.1.42 3.1.43 3.1.44 3.1.45 3.1.46 3.1.47 3.1.48 3.1.49 3.1.5 3.1.50 3.1.51 3.1.52 3.1.53 3.1.54 3.1.55 3.1.56 3.1.57 3.1.58 3.1.59 3.1.6 3.1.60 3.1.61 3.1.62 3.1.63 3.1.64 3.1.65 3.1.66 3.1.67 3.1.68 3.1.69 3.1.7 3.1.70 3.1.71 3.1.72 3.1.73 3.1.74 3.1.75 3.1.76 3.1.77 3.1.78 3.1.79 3.1.8 3.1.80 3.1.81 3.1.82 3.1.83 3.1.84 3.1.85 3.1.86 3.1.87 3.1.88 3.1.89 3.1.9 3.1.90 3.1.91 3.1.92 3.1.93 3.1.94 3.1.95 3.1.96 3.1.97 3.1.98 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 trunk 1.0 1.5 2.0.8 2.9.10 2.9.11 2.9.12
mailin / inc / push-api.php
mailin / inc Last commit date
templates 1 year ago SendinblueAccount.php 1 year ago SendinblueApiClient.php 1 week ago function.wp_mail.php 8 years ago http-build-url.php 1 year ago index.php 8 years ago mailin.php 3 years ago push-admin.php 5 months ago push-amp.php 1 year ago push-api.php 3 months ago push-httpclient.php 1 year ago push-public.php 1 year ago push-settings.php 3 months ago push-utils.php 5 months ago push-woocommerce.php 11 months ago sendinblue.php 3 years ago sib-api-manager.php 1 year ago sib-form-preview.php 2 years ago sib-sms-code.php 5 months ago table-forms.php 1 year ago
push-api.php
535 lines
1 <?php
2 if (!defined( 'ABSPATH' )) { http_response_code(403); exit(); }
3
4 if ( ! class_exists( 'SIB_Push_API' ) ) {
5 class SIB_Push_API {
6
7 const NONCE_ACTION = 'ajax_sib_admin_nonce';
8 const ADMIN_ACCESS = 'admin';
9 const EDITOR_ACCESS = 'editor';
10 private static $nonce = null;
11
12 public static function init() {
13 add_action( 'wp_ajax_sib_get_push_configuration', array( 'SIB_Push_API', 'ajax_get_push_configuration' ) );
14 add_action( 'wp_ajax_sib_update_push_configuration', array( 'SIB_Push_API', 'ajax_update_push_configuration' ) );
15 add_action( 'wp_ajax_sib_push_get_post_metadata', array('SIB_Push_API', 'ajax_get_post_metadata'));
16 add_action( 'wp_ajax_sib_push_set_push_activated', array('SIB_Push_API', 'ajax_set_push_activated'));
17 add_action( 'wp_ajax_sib_push_management_api', array('SIB_Push_API', 'ajax_management_api'));
18 add_action( 'wp_ajax_sib_push_upload', array('SIB_Push_API', 'ajax_upload'));
19 add_action( 'wp_ajax_sib_push_force_create_cart_reminder_campaign', array('SIB_Push_API', 'ajax_force_create_cart_reminder_campaign'));
20 add_action('updated_option', array('SIB_Push_API', 'updated_option'), 10, 3);
21 self::prepare();
22 }
23
24 private static function prepare_cache_key() {
25 return 'sib_push_prepare_' . md5( SIB_Manager::$access_key );
26 }
27
28 private static function prepare() {
29 $settings = SIB_Push_Settings::getSettings();
30 $credentials = $settings->getWonderPushCredentials();
31 if (!$credentials) return;
32 try {
33 if ( !$settings->getShowPush() ) {
34 $settings->setShowPush ( SIB_Push_Utils::get_show_push() );
35 if ( $settings->getShowPush() ) $settings->save();
36 }
37 if ( get_transient( self::prepare_cache_key() ) === 'prepared' ) {
38 return;
39 }
40 set_transient( self::prepare_cache_key(), 'prepared', 86400 );
41 if ( SIB_Push_Utils::get_push_application() ) {
42 SIB_Push_Utils::update_settings();
43 return;
44 }
45 SIB_Push_Utils::create_push_application( 'prepare' );
46 $settings->save();
47 } catch ( \WonderPush\Errors\Server $e ) {
48 $code = $e->getResponse() ? $e->getResponse()->getStatusCode() : null;
49 if ( $code !== 429 ) {
50 SIB_Push_Utils::log_warn( 'Error creating application', $e );
51 } else {
52 // SIB_Push_Utils::log_debug( 'Refusing to create application', $e );
53 }
54 } catch ( SIB_Push_MissingCredentialsException $e) {
55 // Ignore
56 } catch ( Exception $e ) {
57 SIB_Push_Utils::log_debug('Error creating application', $e);
58 }
59 }
60
61 public static function updated_option($option, $old_value, $value) {
62 if ( $option === 'siteurl' && SIB_Push_Utils::get_push_application() ) {
63 // Site url's changed, bust prepare cache hoping that the next request will get the right plugin url
64 delete_transient( self::prepare_cache_key() );
65 }
66 }
67
68 public static function get_nonce() {
69 if (self::$nonce === null) self::$nonce = wp_create_nonce(self::NONCE_ACTION);
70 return self::$nonce;
71 }
72
73 private static function verify_nonce() {
74 $nonce = '';
75 if ($_SERVER['REQUEST_METHOD'] === 'POST') {
76 $nonce = $_POST['nonce'];
77 } else if ($_SERVER['REQUEST_METHOD'] === 'GET') {
78 $nonce = $_GET['nonce'];
79 }
80 if (!$nonce || !wp_verify_nonce($nonce, self::NONCE_ACTION)) {
81 wp_die('Forbidden', 403);
82 }
83 }
84
85 private static function verify_access($access_type = SIB_Push_API::ADMIN_ACCESS) {
86 self::verify_nonce();
87 if ($access_type === SIB_Push_API::EDITOR_ACCESS) {
88 if (!SIB_Push_Utils::can_send_notifications()) {
89 wp_die('Forbidden', 403);
90 }
91 } else {
92 if (!SIB_Push_Utils::can_modify_settings()) {
93 wp_die('Forbidden', 403);
94 }
95 }
96 }
97
98 private static function returnResult($result) {
99 header('Content-Type: application/json');
100 $json = json_encode($result);
101 echo $json;
102 wp_die();
103 }
104
105 private static function returnError($msg, $statusCode) {
106 header('Content-Type: application/json');
107 wp_die(json_encode(array(
108 'error' => array(
109 'message' => $msg,
110 'code' => $statusCode,
111 ),
112 )), $statusCode);
113 }
114
115 public static function ajax_upload() {
116 self::verify_access();
117 $settings = SIB_Push_Settings::getSettings();
118 $credentials = $settings->getWonderPushCredentials();
119 try {
120 $app = SIB_Push_Utils::get_push_application(SIB_Push_Utils::DEFAULT_CACHE_TTL);
121 } catch (Exception $e) {
122 SIB_Push_Utils::log_warn('Could not get application', $e);
123 self::returnError('Could not get application', 500);
124 }
125 $wp = SIB_Push_Utils::management_api_client($credentials);
126 $request = $wp->rest()->request('POST', 'applications/' . urlencode($app->getId()) . '/upload');
127 $image = $_FILES['image'];
128 if (!$image) {
129 self::returnError('Missing image', 400);
130 }
131 $request->addFile('image', $image['name'], $image['tmp_name'], $image['type']);
132 $response = $wp->rest()->execute($request);
133 $responseHeaders = $response->getHeaders();
134 if (isset($responseHeaders['content-type'])) {
135 header('Content-Type: ' . $responseHeaders['content-type']);
136 }
137 wp_die($response->getRawBody(), $response->getStatusCode());
138 }
139
140 public static function ajax_management_api() {
141 self::verify_access();
142 $method = isset($_POST['method']) ? $_POST['method'] : null;
143 $url = isset($_POST['url']) ? $_POST['url'] : null;
144 $body = isset($_POST['body']) ? wp_unslash($_POST['body']) : null;
145
146 switch ($method) {
147 case \WonderPush\Net\Request::GET:
148 case \WonderPush\Net\Request::PUT:
149 case \WonderPush\Net\Request::POST:
150 case \WonderPush\Net\Request::PATCH:
151 case \WonderPush\Net\Request::DELETE:
152 break;
153 default:
154 $method = null;
155 }
156 if (!$method || !$url) {
157 self::returnError('Missing method or url', 400);
158 }
159 $params = $body !== null ? json_decode($body, false) : array();
160 if (json_last_error()) {
161 self::returnError('Invalid JSON body', 400);
162 }
163
164 $settings = SIB_Push_Settings::getSettings();
165 $credentials = $settings->getWonderPushCredentials();
166
167 $wp = SIB_Push_Utils::management_api_client($credentials);
168
169 $request = $wp->rest()->request($method, '../../' . $url, $params);
170 $response = $wp->rest()->execute($request);
171 $responseHeaders = $response->getHeaders();
172 if (isset($responseHeaders['content-type'])) {
173 header('Content-Type: ' . $responseHeaders['content-type']);
174 }
175
176 // Intercept certain calls. We'll have to treat the special wonderpush/v1/batch as well
177 $reqsToCheck = array();
178 if ($method === 'POST' && $url === 'wonderpush/v1/batch' && isset($params->requests)) {
179 $reqsToCheck = array_map(function ($req) { return array($req->method, 'wonderpush'.$req->path); }, $params->requests);
180 } else {
181 $reqsToCheck = array(array($method, $url));
182 }
183
184 foreach ($reqsToCheck as $req) {
185 $reqMethod = $req[0];
186 $reqUrl = $req[1];
187 // Intercept cart reminder campaign update to clear the cache
188 // NOTE: deactivate woocommerce
189 $cartReminderCampaign = null;
190 // $cartReminderCampaign = SIB_Push_WooCommerce::ensure_cart_reminder_campaign_exists();
191 if ($cartReminderCampaign && ($reqMethod === 'PATCH' || $reqMethod === 'DELETE') && str_starts_with($reqUrl, 'wonderpush/v1/campaigns/'.$cartReminderCampaign->getId())) {
192 try {
193 // SIB_Push_Utils::log_debug('Clearing cart reminder cache');
194 SIB_Push_WooCommerce::clear_cart_reminder_campaign_cache();
195 } catch ( Exception $e ) {
196 SIB_Push_Utils::log_warn('Could not clear cart reminder cache', $e);
197 }
198 }
199
200 // Intercept application updates to clear the cache
201 if ($reqMethod === 'PATCH' && str_starts_with($reqUrl, 'wonderpush/v1/applications/')) {
202 $app = SIB_Push_Utils::get_push_application();
203 if ($app && $reqUrl === 'wonderpush/v1/applications/' . $app->getId()) {
204 try {
205 // SIB_Push_Utils::log_debug('Clearing application cache');
206 SIB_Push_Utils::clear_push_application_cache();
207 } catch ( Exception $e ) {
208 SIB_Push_Utils::log_warn('Could not clear application cache', $e);
209 }
210 }
211 }
212 }
213
214 wp_die($response->getRawBody(), $response->getStatusCode());
215 }
216
217 public static function ajax_set_push_activated() {
218 self::verify_access();
219 if (array_key_exists('activated', $_POST)) {
220 try {
221 $app = null;
222 if ($_POST['activated'] === 'true') {
223 $app = SIB_Push_Utils::activate_push();
224 if ($app && $app->getStatus() === 'creation') {
225 $app = SIB_Push_Utils::pollApplicationCreation();
226 }
227 } else {
228 SIB_Push_Utils::deactivate_push();
229 }
230 self::returnResult(array('application' => $app, 'configuration' => self::get_push_configuration()));
231 } catch (Exception $e) {
232 self::returnError($e->getMessage(), 500);
233 }
234 }
235 }
236
237 public static function get_push_configuration() {
238 $settings = SIB_Push_Settings::getSettings();
239 $app = SIB_Push_Utils::get_push_application();
240 return (object)array(
241 'applicationId' => $app && $app->getId() ? $app->getId() : null,
242 'websiteUrl' => get_site_url(),
243 'websiteName' => get_bloginfo('name'),
244 'pushOptions' => SIB_Push_Utils::wonderpush_init_options(),
245 'imgUrl' => plugins_url('img', dirname(__FILE__)),
246 'bypassWordPressHttpClient' => $settings->getBypassWordPressHttpClient(),
247 'curlInstalled' => function_exists('\curl_exec'),
248 'deliveryTimeSeconds' => $settings->getDeliveryTimeSeconds(),
249 'notificationTitle' => $settings->getNotificationTitle(),
250 'defaultTargetSegmentId' => (int)$settings->getDefaultTargetSegmentId() ?: null,
251 'defaultTargetListId' => (int)$settings->getDefaultTargetListId() ?: null,
252 'additionalCustomPostTypes' => $settings->getAdditionalCustomPostTypes(),
253 'disableSendOnPublish' => $settings->getDisableSendOnPublish(),
254 'disableSendByDefaultOnPublish' => $settings->getDisableSendByDefaultOnPublish(),
255 'sendOnThirdPartyPublish' => $settings->getSendOnThirdPartyPublish(),
256 'disableFeedbackOnPublish' => $settings->getDisableFeedbackOnPublish(),
257 'disableUsePostImageForNotification' => $settings->getDisableUsePostImageForNotification(),
258 'preferLargeImageForNotification' => $settings->getPreferLargeImageForNotification(),
259 'cartReminderCampaignId' => $settings->getCartReminderCampaignId(),
260 'enableOrderCompleteNotifications' => $settings->getEnableOrderCompleteNotifications(),
261 'orderCompleteNotificationsMessage' => $settings->getOrderCompleteNotificationsMessage(),
262 'enableOrderProcessingNotifications' => $settings->getEnableOrderProcessingNotifications(),
263 'orderProcessingNotificationsMessage' => $settings->getOrderProcessingNotificationsMessage(),
264 'disableThankYouEvent' => $settings->getDisableThankYouEvent(),
265 'thankYouEventName' => $settings->getThankYouEventName(),
266 'disableAmpUnsubscribe' => $settings->getDisableAmpUnsubscribe(),
267 'ampSubscribeButtonLabel' => $settings->getAmpSubscribeButtonLabel(),
268 'ampUnsubscribeButtonLabel' => $settings->getAmpUnsubscribeButtonLabel(),
269 'disableAmpBottomSubscribeButton' => $settings->getDisableAmpBottomSubscribeButton(),
270 'disableAmpTopSubscribeButton' => $settings->getDisableAmpTopSubscribeButton(),
271 'ampButtonWidth' => (int)$settings->getAmpButtonWidth(),
272 'ampButtonHeight' => (int)$settings->getAmpButtonHeight(),
273 'additionalInitOptionsJson' => $settings->getAdditionalInitOptionsJson(),
274 'hideAdminBarShortcut' => $settings->getHideAdminBarShortcut(),
275 'sendOnlyToThisDomain' => $settings->getSendOnlyToThisDomain(),
276 );
277 }
278
279 public static function ajax_get_push_configuration() {
280 self::verify_access();
281 self::returnResult(self::get_push_configuration());
282 }
283
284 public static function ajax_update_push_configuration() {
285 self::verify_access();
286 $settings = SIB_Push_Settings::getSettings();
287 $save = false;
288 // Boolean props
289 foreach (array(
290 'bypassWordPressHttpClient',
291 'disableSendOnPublish',
292 'disableSendByDefaultOnPublish',
293 'sendOnThirdPartyPublish',
294 'disableFeedbackOnPublish',
295 'disableUsePostImageForNotification',
296 'preferLargeImageForNotification',
297 'enableOrderCompleteNotifications',
298 'enableOrderProcessingNotifications',
299 'disableAmpUnsubscribe',
300 'disableAmpBottomSubscribeButton',
301 'disableAmpTopSubscribeButton',
302 'disableThankYouEvent',
303 'hideAdminBarShortcut',
304 'sendOnlyToThisDomain',
305 ) as $key) {
306 if (array_key_exists($key, $_POST)) {
307 $settings->{"set" . ucfirst($key)}($_POST[$key] === 'true');
308 $save = true;
309 }
310 }
311 // Notification title
312 if (array_key_exists('notificationTitle', $_POST)) {
313
314 // Sanitize user input
315 $value = $_POST['notificationTitle']
316 ? stripslashes(trim(sanitize_text_field($_POST['notificationTitle']))) : '';
317
318 // Validate user input
319 $value = $value && strlen($value) > 1024 ? substr($value, 0, 1024) : $value;
320
321 $settings->setNotificationTitle($value);
322 $save = true;
323 }
324 // Default target segment ID
325 if (array_key_exists('defaultTargetSegmentId', $_POST)) {
326
327 // Sanitize user input
328 $value = $_POST['defaultTargetSegmentId']
329 ? (int)trim(sanitize_text_field($_POST['defaultTargetSegmentId'])) : null;
330
331 // Validate
332 $value = is_int($value) ? $value : null;
333
334 $settings->setDefaultTargetSegmentId($value);
335 $save = true;
336 }
337 // Default target list ID
338 if (array_key_exists('defaultTargetListId', $_POST)) {
339
340 // Sanitize user input
341 $value = $_POST['defaultTargetListId']
342 ? (int)trim(sanitize_text_field($_POST['defaultTargetListId'])) : null;
343
344 // Validate
345 $value = is_int($value) ? $value : null;
346
347 $settings->setDefaultTargetListId($value);
348 $save = true;
349 }
350 // Additional custom post types
351 if (array_key_exists('additionalCustomPostTypes', $_POST)) {
352
353 // Sanitize user input
354 $value = $_POST['additionalCustomPostTypes']
355 ? stripslashes(trim(sanitize_text_field($_POST['additionalCustomPostTypes']))) : '';
356
357 // Validate user input
358 $value = $value && strlen($value) > 1024 ? substr($value, 0, 1024) : $value;
359
360 $settings->setAdditionalCustomPostTypes($value);
361 $save = true;
362 }
363 // Order confirmation notifications message
364 if (array_key_exists('orderCompleteNotificationsMessage', $_POST)) {
365
366 // Sanitize user input
367 $value = $_POST['orderCompleteNotificationsMessage']
368 ? stripslashes(trim(sanitize_text_field($_POST['orderCompleteNotificationsMessage']))) : '';
369
370 // Validate user input
371 $value = $value && strlen($value) > 1024 ? substr($value, 0, 1024) : $value;
372
373 $settings->setOrderCompleteNotificationsMessage($value);
374 $save = true;
375 }
376 // Order confirmation notifications message
377 if (array_key_exists('orderProcessingNotificationsMessage', $_POST)) {
378 // Sanitize user input
379 $value = $_POST['orderProcessingNotificationsMessage']
380 ? stripslashes(trim(sanitize_text_field($_POST['orderProcessingNotificationsMessage']))) : '';
381
382 // Validate user input
383 $value = $value && strlen($value) > 1024 ? substr($value, 0, 1024) : $value;
384
385 $settings->setOrderProcessingNotificationsMessage($value);
386 $save = true;
387 }
388
389 // Thank you event name
390 if (array_key_exists('thankYouEventName', $_POST)) {
391 // Sanitize user input
392 $value = $_POST['thankYouEventName']
393 ? trim(sanitize_text_field($_POST['thankYouEventName'])) : '';
394
395 // Validate user input
396 $value = $value && strlen($value) > 256 ? substr($value, 0, 256) : $value;
397
398 $settings->setThankYouEventName($value);
399 $save = true;
400 }
401
402 // Additional init options
403 if (array_key_exists('additionalInitOptionsJson', $_POST)) {
404 // Sanitize user input
405 $value = $_POST['additionalInitOptionsJson']
406 ? stripslashes(trim(sanitize_text_field($_POST['additionalInitOptionsJson']))) : null;
407
408 // Validate user input
409 if ($value && strlen($value) > 2048) {
410 self::returnError(__('Additional init options JSON cannot be larger than 2048 bytes.'), 400);
411 return;
412 }
413 // Validate JSON
414 if ($value) {
415 $jsonValue = json_decode($value);
416 if (json_last_error()) {
417 self::returnError(__('Additional init options JSON must be valid JSON: ' + json_last_error_msg()), 400);
418
419 }
420 if (!is_object($jsonValue) && $jsonValue !== null) {
421 self::returnError(__('Additional init options JSON must be an object or null.'), 400);
422 return;
423 }
424 }
425 $value = $value ?: '';
426
427 $settings->setAdditionalInitOptionsJson($value);
428 $save = true;
429 }
430 // AMP Subscribe button label
431 if (array_key_exists('ampSubscribeButtonLabel', $_POST)) {
432 // Sanitize user input
433 $value = $_POST['ampSubscribeButtonLabel']
434 ? trim(sanitize_text_field($_POST['ampSubscribeButtonLabel'])) : '';
435
436 // Validate user input
437 $value = $value && strlen($value) > 1024 ? substr($value, 0, 1024) : $value;
438
439 $settings->setAmpSubscribeButtonLabel($value);
440 $save = true;
441 }
442 // AMP Unsubscribe button label
443 if (array_key_exists('ampUnsubscribeButtonLabel', $_POST)) {
444 // Sanitize user input
445 $value = $_POST['ampUnsubscribeButtonLabel']
446 ? trim(sanitize_text_field($_POST['ampUnsubscribeButtonLabel'])) : '';
447
448 // Validate user input
449 $value = $value && strlen($value) > 1024 ? substr($value, 0, 1024) : $value;
450
451 $settings->setAmpUnsubscribeButtonLabel($value);
452 $save = true;
453 }
454 // AMP Button width
455 if (array_key_exists('ampButtonWidth', $_POST)) {
456
457 // Sanitize
458 $value = $_POST['ampButtonWidth']
459 ? (int)trim(sanitize_text_field($_POST['ampButtonWidth'])) : null;
460
461 // Validate
462 $value = is_int($value) ? $value : null;
463
464 $settings->setAmpButtonWidth($value);
465 $save = true;
466 }
467 // AMP Button height
468 if (array_key_exists('ampButtonHeight', $_POST)) {
469
470 // Sanitize
471 $value = $_POST['ampButtonHeight']
472 ? (int)trim(sanitize_text_field($_POST['ampButtonHeight'])) : null;
473
474 // Validate
475 $value = is_int($value) ? $value : null;
476
477 $settings->setAmpButtonHeight($value);
478 $save = true;
479 }
480 // Delivery time seconds
481 if (array_key_exists('deliveryTimeSeconds', $_POST)) {
482
483 // Sanitize
484 $value = $_POST['deliveryTimeSeconds']
485 ? (int)trim(sanitize_text_field($_POST['deliveryTimeSeconds'])) : null;
486
487 // Validate
488 $value = is_int($value) ? $value : null;
489
490 $settings->setDeliveryTimeSeconds($value);
491 $save = true;
492 }
493 if ($save) $settings->save();
494 // NOTE: deactivate woocommerce
495 // SIB_Push_WooCommerce::ensure_cart_reminder_campaign_exists();
496 self::ajax_get_push_configuration();
497 }
498
499 public static function ajax_get_post_metadata() {
500 self::verify_access(SIB_Push_API::EDITOR_ACCESS);
501 $post_id = intval($_GET['post_id']);
502
503 if(is_null($post_id)){
504 self::returnError('Provide post_id query paramter', 400);
505 return;
506 }
507
508 $info = get_post_meta($post_id, SIB_Push_Admin::POST_META_INFO_MESSAGE);
509 if(is_array($info)){
510 $info = $info ? $info[0] : null;
511 }
512
513 $error = get_post_meta($post_id, SIB_Push_Admin::POST_META_ERROR_MESSAGE);
514 if(is_array($error)){
515 $error = $error ? $error[0] : null;
516 }
517
518 // reset meta
519 delete_post_meta($post_id, SIB_Push_Admin::POST_META_INFO_MESSAGE);
520 delete_post_meta($post_id, SIB_Push_Admin::POST_META_ERROR_MESSAGE);
521
522 self::returnResult((object)array('error_message' => $error, 'info_message' => $info));
523 }
524
525 public static function ajax_force_create_cart_reminder_campaign() {
526 self::verify_access();
527 if ($_SERVER['REQUEST_METHOD'] !== 'POST') self::returnError('Method not allowed', 405);
528 $campaign = SIB_Push_WooCommerce::ensure_cart_reminder_campaign_exists(true);
529 self::returnResult(array('success' => true, 'campaign' => $campaign->toData()));
530 }
531
532 }
533
534 }
535