OneSignal – Free Web Push Notifications - Version 2.0.0

Version Description

  • Wordpress VIP support, general refactoring, bug fixes
Download this release

Release Info

Developer OneSignal
Plugin Icon 128x128 OneSignal – Free Web Push Notifications
Version 2.0.0
Comparing to
See all releases

Code changes from version 1.17.9 to 2.0.0

onesignal-admin.php CHANGED
@@ -24,10 +24,11 @@ function load_javascript()
24
  add_action('wp_ajax_has_metadata', 'has_metadata');
25
  function has_metadata()
26
  {
27
- $post_id = $_GET['post_id'];
28
-
 
 
29
  if (is_null($post_id)) {
30
- error_log('OneSignal: could not get post_id');
31
  $data = array('error' => 'could not get post id');
32
  } else {
33
  $recipients = get_post_meta($post_id, 'recipients');
@@ -53,7 +54,7 @@ function has_metadata()
53
  $data = array('recipients' => $recipients, 'status_code' => $status, 'response_body' => $response_body);
54
  }
55
 
56
- echo json_encode($data);
57
 
58
  exit;
59
  }
@@ -83,24 +84,19 @@ class OneSignal_Admin
83
  try {
84
  switch ($errno) {
85
  case E_USER_ERROR:
86
- onesignal_debug('[ERROR]', $errstr.' @ '.$errfile.':'.$errline);
87
  exit(1);
88
  break;
89
 
90
  case E_USER_WARNING:
91
- onesignal_debug('[WARNING]', $errstr.' @ '.$errfile.':'.$errline);
92
  break;
93
 
94
  case E_USER_NOTICE || E_NOTICE:
95
- //onesignal_debug('NOTICE: ' . $errstr . ' @ ' . $errfile . ':' . $errline);
96
  break;
97
 
98
  case E_STRICT:
99
- //onesignal_debug('DEPRECATED: ' . $errstr . ' @ ' . $errfile . ':' . $errline);
100
  break;
101
 
102
  default:
103
- onesignal_debug('[UNKNOWN ERROR]', '('.$errno.'): '.$errstr.' @ '.$errfile.':'.$errline);
104
  break;
105
  }
106
 
@@ -110,8 +106,6 @@ class OneSignal_Admin
110
  }
111
  }
112
 
113
- set_error_handler('exception_error_handler');
114
-
115
  function fatal_exception_error_handler()
116
  {
117
  $error = error_get_last();
@@ -125,8 +119,8 @@ class OneSignal_Admin
125
  case E_CORE_WARNING:
126
  case E_COMPILE_WARNING:
127
  case E_PARSE:
128
- onesignal_debug('[CRITICAL ERROR]', '('.$error['type'].') '.$error['message'].' @ '.$error['file'].':'.$error['line']);
129
- }
130
  } catch (Exception $ex) {
131
  return true;
132
  }
@@ -161,7 +155,7 @@ class OneSignal_Admin
161
  */
162
  public static function on_save_post($post_id, $post, $updated)
163
  {
164
- if ($post->post_type == 'wdslp-wds-log') {
165
  // Prevent recursive post logging
166
  return;
167
  }
@@ -170,18 +164,15 @@ class OneSignal_Admin
170
  * because save_post can be triggered at other times.
171
  */
172
  // Check if our nonce is set.
173
- if (!isset($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY])) {
174
  // This is called on every new post ... not necessary to log it.
175
- // onesignal_debug('Nonce is not set for post ' . $post->post_title . ' (ID ' . $post_id . ')');
176
  return $post_id;
177
  }
178
 
179
- $nonce = $_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY];
180
 
181
  // Verify that the nonce is valid.
182
  if (!wp_verify_nonce($nonce, OneSignal_Admin::$SAVE_POST_NONCE_ACTION)) {
183
- onesignal_debug('Nonce is not valid for '.$post->post_title.' (ID '.$post_id.')');
184
-
185
  return $post_id;
186
  }
187
 
@@ -198,31 +189,26 @@ class OneSignal_Admin
198
  /* Some WordPress environments seem to be inconsistent about whether on_save_post is called before transition_post_status
199
  * Check flag in case we just sent a notification for this post (this on_save_post is called after a successful send)
200
  */
201
- $just_sent_notification = (get_post_meta($post_id, 'onesignal_notification_already_sent', true) == true);
202
 
203
  if ($just_sent_notification) {
204
  // Reset our flag
205
  update_post_meta($post_id, 'onesignal_notification_already_sent', false);
206
- onesignal_debug('A notification was just sent, so ignoring on_save_post. Resetting check flag.');
207
 
208
  return;
209
  }
210
 
211
  if (array_key_exists('onesignal_meta_box_present', $_POST)) {
212
  update_post_meta($post_id, 'onesignal_meta_box_present', true);
213
- onesignal_debug('Set post metadata "onesignal_meta_box_present" to true.');
214
  } else {
215
  update_post_meta($post_id, 'onesignal_meta_box_present', false);
216
- onesignal_debug('Set post metadata "onesignal_meta_box_present" to false.');
217
  }
218
 
219
  /* Even though the meta box always contains the checkbox, if an HTML checkbox is not checked, it is not POSTed to the server */
220
  if (array_key_exists('send_onesignal_notification', $_POST)) {
221
  update_post_meta($post_id, 'onesignal_send_notification', true);
222
- onesignal_debug('Set post metadata "onesignal_send_notification" to true.');
223
  } else {
224
  update_post_meta($post_id, 'onesignal_send_notification', false);
225
- onesignal_debug('Set post metadata "onesignal_send_notification" to false.');
226
  }
227
  }
228
 
@@ -230,17 +216,26 @@ class OneSignal_Admin
230
  {
231
  // If there is an error or success message we should display, display it now
232
  function admin_notice_error()
233
- {
 
 
 
 
 
 
 
 
 
234
  $onesignal_transient_error = get_transient('onesignal_transient_error');
235
  if (!empty($onesignal_transient_error)) {
236
  delete_transient('onesignal_transient_error');
237
- echo $onesignal_transient_error;
238
  }
239
 
240
  $onesignal_transient_success = get_transient('onesignal_transient_success');
241
  if (!empty($onesignal_transient_success)) {
242
  delete_transient('onesignal_transient_success');
243
- echo $onesignal_transient_success;
244
  }
245
  }
246
  add_action('admin_notices', 'admin_notice_error');
@@ -290,34 +285,28 @@ class OneSignal_Admin
290
  $settings_send_notification_on_wp_editor_post = $onesignal_wp_settings['notification_on_post'];
291
 
292
  /* This is a scheduled post and the user checked "Send a notification on post publish/update". */
293
- $post_metadata_was_send_notification_checked = (get_post_meta($post->ID, 'onesignal_send_notification', true) == true);
294
 
295
  // We check the checkbox if: setting is enabled on Config page, post type is ONLY "post", and the post has not been published (new posts are status "auto-draft")
296
- $meta_box_checkbox_send_notification = ($settings_send_notification_on_wp_editor_post && // If setting is enabled
297
- $post->post_type == 'post' && // Post type must be type post for checkbox to be auto-checked
298
- in_array($post->post_status, array('future', 'draft', 'auto-draft', 'pending'))) || // Post is scheduled, incomplete, being edited, or is awaiting publication
299
  ($post_metadata_was_send_notification_checked);
300
 
301
  if (has_filter('onesignal_meta_box_send_notification_checkbox_state')) {
302
  $meta_box_checkbox_send_notification = apply_filters('onesignal_meta_box_send_notification_checkbox_state', $post, $onesignal_wp_settings);
303
  }
304
- onesignal_debug('$meta_box_checkbox_send_notification:', $meta_box_checkbox_send_notification);
305
- onesignal_debug(' [$meta_box_checkbox_send_notification]', 'has_filter(onesignal_meta_box_send_notification_checkbox_state):', has_filter('onesignal_meta_box_send_notification_checkbox_state'));
306
- onesignal_debug(' [$meta_box_checkbox_send_notification]', 'onesignal_meta_box_send_notification_checkbox_state filter result:', apply_filters('onesignal_meta_box_send_notification_checkbox_state', $post, $onesignal_wp_settings));
307
- onesignal_debug(' [$meta_box_checkbox_send_notification]', '$settings_send_notification_on_wp_editor_post:', $settings_send_notification_on_wp_editor_post);
308
- onesignal_debug(' [$meta_box_checkbox_send_notification]', '$settings_send_notification_on_wp_editor_post:', $settings_send_notification_on_wp_editor_post);
309
- onesignal_debug(' [$meta_box_checkbox_send_notification]', '$post->post_type == "post":', $post->post_type == 'post', '('.$post->post_type.')');
310
- onesignal_debug(' [$meta_box_checkbox_send_notification]', 'in_array($post->post_status, array("future", "draft", "auto-draft", "pending"):', in_array($post->post_status, array('future', 'draft', 'auto-draft', 'pending')), '('.$post->post_status.')'); ?>
311
 
312
  <input type="hidden" name="onesignal_meta_box_present" value="true"></input>
313
- <input type="checkbox" name="send_onesignal_notification" value="true" <?php if ($meta_box_checkbox_send_notification) {
314
- echo 'checked';
315
- } ?>></input>
316
- <label>
317
- <?php if ($post->post_status == 'publish') {
318
- echo 'Send notification on '.$post_type.' update';
319
  } else {
320
- echo 'Send notification on '.$post_type.' publish';
321
  } ?>
322
  </label>
323
  <?php
@@ -326,7 +315,6 @@ class OneSignal_Admin
326
  public static function save_config_page($config)
327
  {
328
  if (!OneSignalUtils::can_modify_plugin_settings()) {
329
- onesignal_debug('Not saving plugin settings because the current user is not an administrator.');
330
  set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
331
  <p><strong>OneSignal Push:</strong><em> Only administrators are allowed to save plugin settings.</em></p>
332
  </div>', 86400);
@@ -334,7 +322,6 @@ class OneSignal_Admin
334
  return;
335
  }
336
 
337
- $sdk_dir = plugin_dir_path(__FILE__).'sdk_files/';
338
  $onesignal_wp_settings = OneSignal::get_onesignal_settings();
339
  $new_app_id = $config['app_id'];
340
 
@@ -369,7 +356,6 @@ class OneSignal_Admin
369
  'prompt_customize_enable',
370
  'notifyButton_showAfterSubscribed',
371
  'notifyButton_enable',
372
- 'notifyButton_prenotify',
373
  'notifyButton_showcredit',
374
  'notifyButton_customize_enable',
375
  'notifyButton_customize_colors_enable',
@@ -417,7 +403,6 @@ class OneSignal_Admin
417
  'notifyButton_offset_bottom',
418
  'notifyButton_offset_left',
419
  'notifyButton_offset_right',
420
- 'notifyButton_message_prenotify',
421
  'notifyButton_tip_state_unsubscribed',
422
  'notifyButton_tip_state_subscribed',
423
  'notifyButton_tip_state_blocked',
@@ -442,7 +427,7 @@ class OneSignal_Admin
442
 
443
  OneSignal::save_onesignal_settings($onesignal_wp_settings);
444
 
445
- return $onesignal_wp_settings;
446
  }
447
 
448
  public static function saveBooleanSettings(&$onesignal_wp_settings, &$config, $settings)
@@ -461,7 +446,7 @@ class OneSignal_Admin
461
  foreach ($settings as $setting) {
462
  if (array_key_exists($setting, $config)) {
463
  $value = $config[$setting];
464
- $value = OneSignalUtils::normalize($value);
465
  $onesignal_wp_settings[$setting] = $value;
466
  }
467
  }
@@ -487,7 +472,7 @@ class OneSignal_Admin
487
  if (array_key_exists('app_id', $_POST)) {
488
  // check_admin_referer dies if not valid; no if statement necessary
489
  check_admin_referer(OneSignal_Admin::$SAVE_CONFIG_NONCE_ACTION, OneSignal_Admin::$SAVE_CONFIG_NONCE_KEY);
490
- $onesignal_wp_settings = OneSignal_Admin::save_config_page($_POST);
491
  }
492
  }
493
 
@@ -502,8 +487,8 @@ class OneSignal_Admin
502
 
503
  $onesignal_wp_settings = OneSignal::get_onesignal_settings();
504
  if (
505
- $onesignal_wp_settings['app_id'] == '' ||
506
- $onesignal_wp_settings['app_rest_api_key'] == ''
507
  ) {
508
  function admin_notice_setup_not_complete()
509
  {
@@ -543,10 +528,8 @@ class OneSignal_Admin
543
  wp_enqueue_style('semantic-ui', plugin_dir_url(__FILE__).'views/css/semantic-ui.css', false, OneSignal_Admin::$RESOURCES_VERSION);
544
  wp_enqueue_style('site', plugin_dir_url(__FILE__).'views/css/site.css', false, OneSignal_Admin::$RESOURCES_VERSION);
545
 
546
- wp_enqueue_script('jquery.min', plugin_dir_url(__FILE__).'views/javascript/jquery.min.js', false, OneSignal_Admin::$RESOURCES_VERSION);
547
- wp_enqueue_script('semantic-ui', plugin_dir_url(__FILE__).'views/javascript/semantic-ui.js', false, OneSignal_Admin::$RESOURCES_VERSION);
548
- wp_enqueue_script('jquery.cookie', plugin_dir_url(__FILE__).'views/javascript/jquery.cookie.js', false, OneSignal_Admin::$RESOURCES_VERSION);
549
- wp_enqueue_script('site', plugin_dir_url(__FILE__).'views/javascript/site-admin.js', false, OneSignal_Admin::$RESOURCES_VERSION);
550
  }
551
 
552
  /**
@@ -554,14 +537,10 @@ class OneSignal_Admin
554
  */
555
  public static function get_sending_rate_limit_wait_time()
556
  {
557
- onesignal_debug('Called is_over_sending_rate_limit()');
558
  $last_send_time = get_option('onesignal.last_send_time');
559
- onesignal_debug(' [is_over_sending_rate_limit] Last send time:', $last_send_time);
560
  if ($last_send_time) {
561
  $time_elapsed_since_last_send = ONESIGNAL_API_RATE_LIMIT_SECONDS - (current_time('timestamp') - intval($last_send_time));
562
  if ($time_elapsed_since_last_send > 0) {
563
- onesignal_debug(' [is_over_sending_rate_limit] Current send time ('.current_time('timestamp').') is less than rate limit time after the last send time.');
564
-
565
  return $time_elapsed_since_last_send;
566
  }
567
  }
@@ -586,40 +565,54 @@ class OneSignal_Admin
586
  */
587
  public static function uuid($title)
588
  {
589
- $now = explode(':', date('z:H:i'));
590
- $now_minutes = $now[0] * 60 * 24 + $now[1] * 60 + $now[2];
591
  $prev_minutes = get_option('TimeLastUpdated');
592
  $prehash = (string) $title;
 
593
 
594
- if ($prev_minutes !== false && ($now_minutes - $prev_minutes) > 0) {
595
  update_option('TimeLastUpdated', $now_minutes);
596
  $timestamp = $now_minutes;
597
- } elseif ($prev_minutes == false) {
598
- add_option('TimeLastUpdated', $now_minutes);
599
- $timestamp = $now_minutes;
600
  } else {
601
  $timestamp = $prev_minutes;
602
  }
603
 
604
  $prehash = $prehash.$timestamp;
605
-
606
  $sha1 = substr(sha1($prehash), 0, 32);
607
-
608
  return substr($sha1, 0, 8).'-'.substr($sha1, 8, 4).'-'.substr($sha1, 12, 4).'-'.substr($sha1, 16, 4).'-'.substr($sha1, 20, 12);
609
  }
610
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  /**
612
  * The main function that actually sends a notification to OneSignal.
613
  */
614
  public static function send_notification_on_wp_post($new_status, $old_status, $post)
615
  {
616
  try {
617
- if (!function_exists('curl_init')) {
618
- onesignal_debug('Canceling send_notification_on_wp_post because curl_init() is not a defined function.');
619
-
620
- return;
621
- }
622
-
 
 
 
 
 
623
  $time_to_wait = self::get_sending_rate_limit_wait_time();
624
  if ($time_to_wait > 0) {
625
  set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
@@ -635,19 +628,18 @@ class OneSignal_Admin
635
 
636
  /* Settings related to creating a post involving the WordPress editor displaying the OneSignal meta box
637
  **********************************************************************************************************/
638
-
639
  /* Returns true if there is POST data */
640
  $was_posted = !empty($_POST);
641
 
642
  /* When this post was created or updated, the OneSignal meta box in the WordPress post editor screen was visible */
643
- $onesignal_meta_box_present = $was_posted && array_key_exists('onesignal_meta_box_present', $_POST) && $_POST['onesignal_meta_box_present'] == 'true';
644
  /* The checkbox "Send notification on post publish/update" on the OneSignal meta box is checked */
645
- $onesignal_meta_box_send_notification_checked = $was_posted && array_key_exists('send_onesignal_notification', $_POST) && $_POST['send_onesignal_notification'] == 'true';
646
 
647
  /* This is a scheduled post and the OneSignal meta box was present. */
648
- $post_metadata_was_onesignal_meta_box_present = (get_post_meta($post->ID, 'onesignal_meta_box_present', true) == true);
649
  /* This is a scheduled post and the user checked "Send a notification on post publish/update". */
650
- $post_metadata_was_send_notification_checked = (get_post_meta($post->ID, 'onesignal_send_notification', true) == true);
651
 
652
  /* Either we were just posted from the WordPress post editor form, or this is a scheduled notification and it was previously submitted from the post editor form */
653
  $posted_from_wordpress_editor = $onesignal_meta_box_present || $post_metadata_was_onesignal_meta_box_present;
@@ -663,9 +655,8 @@ class OneSignal_Admin
663
  $settings_send_notification_on_non_editor_post_publish = $onesignal_wp_settings['notification_on_post_from_plugin'];
664
  $additional_custom_post_types_string = str_replace(' ', '', $onesignal_wp_settings['allowed_custom_post_types']);
665
  $additional_custom_post_types_array = array_filter(explode(',', $additional_custom_post_types_string));
666
- onesignal_debug('Additional allowed custom post types:', $additional_custom_post_types_string);
667
  $non_editor_post_publish_do_send_notification = $settings_send_notification_on_non_editor_post_publish &&
668
- ($post->post_type == 'post' || in_array($post->post_type, $additional_custom_post_types_array)) &&
669
  $old_status !== 'publish';
670
  /* ********************************************************************************************************* */
671
 
@@ -683,29 +674,10 @@ class OneSignal_Admin
683
 
684
  if (has_filter('onesignal_include_post')) {
685
  if (apply_filters('onesignal_include_post', $new_status, $old_status, $post)) {
686
- onesignal_debug('Will actually send a notification for this post because the filter opted to include the post.');
687
  $do_send_notification = true;
688
  }
689
  }
690
 
691
- onesignal_debug('Post Status:', $old_status, '-->', $new_status);
692
- onesignal_debug_post($post);
693
- onesignal_debug('Has onesignal_include_post filter:', has_filter('onesignal_include_post'));
694
- onesignal_debug(' [onesignal_include_post Filter]', 'Filter Result:', apply_filters('onesignal_include_post', $new_status, $old_status, $post));
695
- onesignal_debug('Has onesignal_exclude_post filter:', has_filter('onesignal_exclude_post'));
696
- onesignal_debug(' [onesignal_exclude_post Filter]', 'Filter Result:', apply_filters('onesignal_exclude_post', $new_status, $old_status, $post));
697
- onesignal_debug('Posted from WordPress editor:', $posted_from_wordpress_editor);
698
- onesignal_debug(' [Posted from WordPress editor]', 'Just Posted Meta Box Present:', $onesignal_meta_box_present);
699
- onesignal_debug(' [Posted from WordPress editor]', 'Was Meta Box Ever Present:', $post_metadata_was_onesignal_meta_box_present);
700
- onesignal_debug('Editor Post Send:', $posted_from_wordpress_editor && $do_send_notification);
701
- onesignal_debug(' [Editor Post Send]', 'Meta Box Send Notification Just Checked:', $onesignal_meta_box_send_notification_checked);
702
- onesignal_debug(' [Editor Post Send]', 'Meta Box Send Notification Previously Checked:', $post_metadata_was_send_notification_checked);
703
- onesignal_debug('Non-Editor Post Send:', $non_editor_post_publish_do_send_notification);
704
- onesignal_debug(' [Non-Editor Post Send]', 'Auto Send Config Setting:', $settings_send_notification_on_non_editor_post_publish);
705
- onesignal_debug(' [Non-Editor Post Send]', 'Post Type:', ($post->post_type == 'post' || in_array($post->post_type, $additional_custom_post_types_array)), '('.$post->post_type.')');
706
- onesignal_debug(' [Non-Editor Post Send]', 'Old Post Status:', ($old_status !== 'publish'), '('.$old_status.')');
707
- onesignal_debug('Actually Sending Notification:', $do_send_notification);
708
-
709
  if ($do_send_notification) {
710
  /* Now that all settings are retrieved, and we are actually sending the notification, reset the post's metadata
711
  * If this post is sent through a plugin in the future, existing metadata will interfere with the send condition logic
@@ -713,7 +685,6 @@ class OneSignal_Admin
713
  */
714
  update_post_meta($post->ID, 'onesignal_meta_box_present', false);
715
  update_post_meta($post->ID, 'onesignal_send_notification', false);
716
- onesignal_debug('Removed OneSignal metadata from post.');
717
 
718
  /* Some WordPress environments seem to be inconsistent about whether on_save_post is called before transition_post_status
719
  * This sets the metadata back to true, and will cause a post to be sent even if the checkbox is not checked the next time
@@ -722,18 +693,16 @@ class OneSignal_Admin
722
  if ($was_posted) {
723
  if (array_key_exists('onesignal_meta_box_present', $_POST)) {
724
  unset($_POST['onesignal_meta_box_present']);
725
- onesignal_debug('Unset $_POST[\'onesignal_meta_box_present\']');
726
  }
727
  if (array_key_exists('send_onesignal_notification', $_POST)) {
728
  unset($_POST['send_onesignal_notification']);
729
- onesignal_debug('Unset $_POST[\'send_onesignal_notification\']');
730
  }
731
  }
732
 
733
  $notif_content = OneSignalUtils::decode_entities(get_the_title($post->ID));
734
 
735
  $site_title = '';
736
- if ($onesignal_wp_settings['notification_title'] != '') {
737
  $site_title = OneSignalUtils::decode_entities($onesignal_wp_settings['notification_title']);
738
  } else {
739
  $site_title = OneSignalUtils::decode_entities(get_bloginfo('name'));
@@ -745,22 +714,22 @@ class OneSignal_Admin
745
  $site_title = qtrans_use($qtransLang, $site_title, false);
746
  $notif_content = qtrans_use($qtransLang, $notif_content, false);
747
  } catch (Exception $e) {
748
- onesignal_debug('Caught qTrans exception:', $e->getMessage());
749
  }
750
  }
751
 
752
  $fields = array(
753
- 'external_id' => self::uuid($notif_content),
754
- 'app_id' => $onesignal_wp_settings['app_id'],
755
- 'headings' => array('en' => $site_title),
756
- 'included_segments' => array('All'),
757
- 'isAnyWeb' => true,
758
- 'url' => get_permalink($post->ID),
759
- 'contents' => array('en' => $notif_content),
760
- );
761
 
762
  $send_to_mobile_platforms = $onesignal_wp_settings['send_to_mobile_platforms'];
763
- if ($send_to_mobile_platforms == true) {
764
  $fields['isIos'] = true;
765
  $fields['isAndroid'] = true;
766
  }
@@ -771,43 +740,33 @@ class OneSignal_Admin
771
  }
772
 
773
  if (has_post_thumbnail($post->ID)) {
774
- onesignal_debug('Post has featured image.');
775
-
776
  $post_thumbnail_id = get_post_thumbnail_id($post->ID);
777
  // Higher resolution (2x retina, + a little more) for the notification small icon
778
  $thumbnail_sized_images_array = wp_get_attachment_image_src($post_thumbnail_id, array(192, 192), true);
779
  // Much higher resolution for the notification large image
780
  $large_sized_images_array = wp_get_attachment_image_src($post_thumbnail_id, 'large', true);
781
 
782
- $config_use_featured_image_as_icon = $onesignal_wp_settings['showNotificationIconFromPostThumbnail'] == '1';
783
- onesignal_debug('Post should use featured image for notification icon (small):', $config_use_featured_image_as_icon);
784
- $config_use_featured_image_as_image = $onesignal_wp_settings['showNotificationImageFromPostThumbnail'] == '1';
785
- onesignal_debug('Post should use featured image for notification image (large):', $config_use_featured_image_as_image);
786
 
787
  // get the icon image from wordpress if it exists
788
  if ($config_use_featured_image_as_icon) {
789
- onesignal_debug('Featured post image thumbnail-sized array:', $thumbnail_sized_images_array);
790
  $thumbnail_image = $thumbnail_sized_images_array[0];
791
  // set the icon image for both chrome and firefox-1
792
  $fields['chrome_web_icon'] = $thumbnail_image;
793
  $fields['firefox_icon'] = $thumbnail_image;
794
- onesignal_debug('Setting Chrome and Firefox notification icon to:', $thumbnail_image);
795
  }
796
  if ($config_use_featured_image_as_image) {
797
- onesignal_debug('Featured post image large-sized array:', $large_sized_images_array);
798
  $large_image = $large_sized_images_array[0];
799
  $fields['chrome_web_image'] = $large_image;
800
- onesignal_debug('Setting Chrome notification large image to:', $large_image);
801
  }
802
  }
803
 
804
  if (has_filter('onesignal_send_notification')) {
805
- onesignal_debug('Applying onesignal_send_notification filter.');
806
  $fields = apply_filters('onesignal_send_notification', $fields, $new_status, $old_status, $post);
807
- onesignal_debug('onesignal_send_notification filter $fields result:', $fields);
808
 
809
  // If the filter adds "do_send_notification: false", do not send a notification
810
- if (array_key_exists('do_send_notification', $fields) && $fields['do_send_notification'] == false) {
811
  return;
812
  }
813
  }
@@ -827,25 +786,24 @@ class OneSignal_Admin
827
  $onesignal_auth_key = $onesignal_wp_settings['app_rest_api_key'];
828
 
829
  $request = array(
830
- 'headers' => array(
831
- 'content-type' => 'application/json;charset=utf-8',
832
- 'Authorization' => 'Basic '.$onesignal_auth_key,
833
- ),
834
- 'body' => json_encode($fields),
835
- 'timeout' => 60,
836
- );
837
-
838
- $response = wp_remote_post($onesignal_post_url, $request);
839
-
840
- if (is_wp_error($response) || !is_array($response) || !isset($response['body'])) {
841
- $status = $response->get_error_code(); // custom code for WP_ERROR
842
- $error_message = $response->get_error_message();
843
- error_log('There was a '.$status.' error returned from OneSignal: '.$error_message);
844
-
845
- return;
846
- }
847
-
848
- if (isset($response['body'])) {
849
  $response_body = json_decode($response['body'], true);
850
  }
851
 
@@ -853,13 +811,11 @@ class OneSignal_Admin
853
  $status = $response['response']['code'];
854
  }
855
 
856
- update_post_meta($post->ID, 'response_body', json_encode($response_body));
857
  update_post_meta($post->ID, 'status', $status);
858
 
859
- if ($status != 200) {
860
- error_log('There was a '.$status.' error sending your notification.');
861
- error_log('Response from OneSignal:', json_encode($response));
862
- if ($status != 0) {
863
  set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
864
  <p><strong>OneSignal Push:</strong><em> There was a '.$status.' error sending your notification.</em></p>
865
  </div>', 86400);
@@ -871,30 +827,25 @@ class OneSignal_Admin
871
  }
872
  } else {
873
  if (!empty($response)) {
874
- onesignal_debug('OneSignal API Raw Response:', $response);
875
 
876
  // API can send a 200 OK even if the notification failed to send
877
  if (isset($response['body'])) {
878
  $response_body = json_decode($response['body'], true);
879
  if (isset($response_body['recipients'])) {
880
  $recipient_count = $response_body['recipients'];
881
- } else {
882
- error_log('OneSignal: recipients not set in response body');
883
  }
884
- } else {
885
- error_log('OneSignal: body not set in HTTP response');
886
  }
887
 
888
  // updates meta so that recipient count is available for GET request from client
889
  update_post_meta($post->ID, 'recipients', $recipient_count);
890
 
891
  $sent_or_scheduled = array_key_exists('send_after', $fields) ? 'scheduled' : 'sent';
892
- $config_show_notification_send_status_message = $onesignal_wp_settings['show_notification_send_status_message'] == '1';
893
 
894
  if ($config_show_notification_send_status_message) {
895
- if ($recipient_count != 0) {
896
- $delivery_link_text = $sent_or_scheduled == 'sent' ? ' Go to your app\'s "Delivery" tab to check sent messages: <a target="_blank" href="https://app.onesignal.com/apps/">https://app.onesignal.com/apps/</a>' : '';
897
- set_transient('onesignal_transient_success', '<div class="components-notice is-success is-dismissible">
898
  <div class="components-notice__content">
899
  <p><strong>OneSignal Push:</strong><em> Successfully '.$sent_or_scheduled.' a notification to '.$recipient_count.' recipients.'.$delivery_link_text.'</em></p>
900
  </div>
@@ -910,17 +861,14 @@ class OneSignal_Admin
910
 
911
  if (defined('ONESIGNAL_DEBUG') || class_exists('WDS_Log_Post')) {
912
  fclose($out);
913
- $debug_output = ob_get_clean();
914
  }
915
 
916
  self::update_last_sent_timestamp();
917
-
918
  return $response;
919
  }
920
  } catch (Exception $e) {
921
- onesignal_debug('Caught Exception:', $e->getMessage());
922
- }
923
- }
924
 
925
  public static function was_post_restored_from_trash($old_status, $new_status)
926
  {
@@ -929,36 +877,31 @@ class OneSignal_Admin
929
 
930
  public static function on_transition_post_status($new_status, $old_status, $post)
931
  {
932
- if ($post->post_type == 'wdslp-wds-log' ||
933
  self::was_post_restored_from_trash($old_status, $new_status)) {
934
  // It's important not to call onesignal_debug() on posts of type wdslp-wds-log, otherwise each post will recursively generate 4 more posts
935
  return;
936
  }
937
  if (has_filter('onesignal_include_post')) {
938
- onesignal_debug('Applying onesignal_include_post filter.');
939
  if (apply_filters('onesignal_include_post', $new_status, $old_status, $post)) {
940
  // If the filter returns "$do_include_post: true", always process this post
941
- onesignal_debug('Processing post because the filter opted to include the post.');
942
  self::send_notification_on_wp_post($new_status, $old_status, $post);
943
 
944
  return;
945
  }
946
  }
947
  if (has_filter('onesignal_exclude_post')) {
948
- onesignal_debug('Applying onesignal_exclude_post filter.');
949
  if (apply_filters('onesignal_exclude_post', $new_status, $old_status, $post)) {
950
  // If the filter returns "$do_exclude_post: false", do not process this post at all
951
- onesignal_debug('Not processing post because the filter opted to exclude the post.');
952
 
953
  return;
954
  }
955
  }
956
  if (!(empty($post) ||
957
  $new_status !== 'publish' ||
958
- $post->post_type == 'page')) {
959
  self::send_notification_on_wp_post($new_status, $old_status, $post);
960
  }
961
  }
962
  }
963
-
964
  ?>
24
  add_action('wp_ajax_has_metadata', 'has_metadata');
25
  function has_metadata()
26
  {
27
+ $post_id = isset($_GET['post_id']) ?
28
+ (filter_var($_GET['post_id'], FILTER_SANITIZE_NUMBER_INT))
29
+ : '';
30
+
31
  if (is_null($post_id)) {
 
32
  $data = array('error' => 'could not get post id');
33
  } else {
34
  $recipients = get_post_meta($post_id, 'recipients');
54
  $data = array('recipients' => $recipients, 'status_code' => $status, 'response_body' => $response_body);
55
  }
56
 
57
+ echo wp_json_encode($data);
58
 
59
  exit;
60
  }
84
  try {
85
  switch ($errno) {
86
  case E_USER_ERROR:
 
87
  exit(1);
88
  break;
89
 
90
  case E_USER_WARNING:
 
91
  break;
92
 
93
  case E_USER_NOTICE || E_NOTICE:
 
94
  break;
95
 
96
  case E_STRICT:
 
97
  break;
98
 
99
  default:
 
100
  break;
101
  }
102
 
106
  }
107
  }
108
 
 
 
109
  function fatal_exception_error_handler()
110
  {
111
  $error = error_get_last();
119
  case E_CORE_WARNING:
120
  case E_COMPILE_WARNING:
121
  case E_PARSE:
122
+ return false;
123
+ }
124
  } catch (Exception $ex) {
125
  return true;
126
  }
155
  */
156
  public static function on_save_post($post_id, $post, $updated)
157
  {
158
+ if ($post->post_type === 'wdslp-wds-log') {
159
  // Prevent recursive post logging
160
  return;
161
  }
164
  * because save_post can be triggered at other times.
165
  */
166
  // Check if our nonce is set.
167
+ if (isset($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY])) {
168
  // This is called on every new post ... not necessary to log it.
 
169
  return $post_id;
170
  }
171
 
172
+ $nonce = (isset($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY]) ? filter_var(isset($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY]), FILTER_SANITIZE_STRING) : '');
173
 
174
  // Verify that the nonce is valid.
175
  if (!wp_verify_nonce($nonce, OneSignal_Admin::$SAVE_POST_NONCE_ACTION)) {
 
 
176
  return $post_id;
177
  }
178
 
189
  /* Some WordPress environments seem to be inconsistent about whether on_save_post is called before transition_post_status
190
  * Check flag in case we just sent a notification for this post (this on_save_post is called after a successful send)
191
  */
192
+ $just_sent_notification = (get_post_meta($post_id, 'onesignal_notification_already_sent') === true);
193
 
194
  if ($just_sent_notification) {
195
  // Reset our flag
196
  update_post_meta($post_id, 'onesignal_notification_already_sent', false);
 
197
 
198
  return;
199
  }
200
 
201
  if (array_key_exists('onesignal_meta_box_present', $_POST)) {
202
  update_post_meta($post_id, 'onesignal_meta_box_present', true);
 
203
  } else {
204
  update_post_meta($post_id, 'onesignal_meta_box_present', false);
 
205
  }
206
 
207
  /* Even though the meta box always contains the checkbox, if an HTML checkbox is not checked, it is not POSTed to the server */
208
  if (array_key_exists('send_onesignal_notification', $_POST)) {
209
  update_post_meta($post_id, 'onesignal_send_notification', true);
 
210
  } else {
211
  update_post_meta($post_id, 'onesignal_send_notification', false);
 
212
  }
213
  }
214
 
216
  {
217
  // If there is an error or success message we should display, display it now
218
  function admin_notice_error()
219
+ {
220
+ $allowed_html = [
221
+ 'div' => [
222
+ 'class' => []
223
+ ],
224
+ 'strong' => [],
225
+ 'a' => [],
226
+ 'p' => [],
227
+ 'em' => []
228
+ ];
229
  $onesignal_transient_error = get_transient('onesignal_transient_error');
230
  if (!empty($onesignal_transient_error)) {
231
  delete_transient('onesignal_transient_error');
232
+ echo wp_kses($onesignal_transient_error, $allowed_html);
233
  }
234
 
235
  $onesignal_transient_success = get_transient('onesignal_transient_success');
236
  if (!empty($onesignal_transient_success)) {
237
  delete_transient('onesignal_transient_success');
238
+ echo wp_kses($onesignal_transient_success, $allowed_html);
239
  }
240
  }
241
  add_action('admin_notices', 'admin_notice_error');
285
  $settings_send_notification_on_wp_editor_post = $onesignal_wp_settings['notification_on_post'];
286
 
287
  /* This is a scheduled post and the user checked "Send a notification on post publish/update". */
288
+ $post_metadata_was_send_notification_checked = (get_post_meta($post->ID, 'onesignal_send_notification') === true);
289
 
290
  // We check the checkbox if: setting is enabled on Config page, post type is ONLY "post", and the post has not been published (new posts are status "auto-draft")
291
+ $meta_box_checkbox_send_notification = ($settings_send_notification_on_wp_editor_post && // If setting is enabled
292
+ $post->post_type === 'post' && // Post type must be type post for checkbox to be auto-checked
293
+ in_array($post->post_status, array('future', 'draft', 'auto-draft', 'pending'), true)) || // Post is scheduled, incomplete, being edited, or is awaiting publication
294
  ($post_metadata_was_send_notification_checked);
295
 
296
  if (has_filter('onesignal_meta_box_send_notification_checkbox_state')) {
297
  $meta_box_checkbox_send_notification = apply_filters('onesignal_meta_box_send_notification_checkbox_state', $post, $onesignal_wp_settings);
298
  }
299
+ ?>
 
 
 
 
 
 
300
 
301
  <input type="hidden" name="onesignal_meta_box_present" value="true"></input>
302
+ <input type="checkbox" name="send_onesignal_notification" value="true" <?php if ($meta_box_checkbox_send_notification) {
303
+ echo 'checked';
304
+ } ?>></input>
305
+ <label>
306
+ <?php if ($post->post_status === 'publish') {
307
+ echo esc_attr('Send notification on '.$post_type.' update');
308
  } else {
309
+ echo esc_attr('Send notification on '.$post_type.' publish');
310
  } ?>
311
  </label>
312
  <?php
315
  public static function save_config_page($config)
316
  {
317
  if (!OneSignalUtils::can_modify_plugin_settings()) {
 
318
  set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
319
  <p><strong>OneSignal Push:</strong><em> Only administrators are allowed to save plugin settings.</em></p>
320
  </div>', 86400);
322
  return;
323
  }
324
 
 
325
  $onesignal_wp_settings = OneSignal::get_onesignal_settings();
326
  $new_app_id = $config['app_id'];
327
 
356
  'prompt_customize_enable',
357
  'notifyButton_showAfterSubscribed',
358
  'notifyButton_enable',
 
359
  'notifyButton_showcredit',
360
  'notifyButton_customize_enable',
361
  'notifyButton_customize_colors_enable',
403
  'notifyButton_offset_bottom',
404
  'notifyButton_offset_left',
405
  'notifyButton_offset_right',
 
406
  'notifyButton_tip_state_unsubscribed',
407
  'notifyButton_tip_state_subscribed',
408
  'notifyButton_tip_state_blocked',
427
 
428
  OneSignal::save_onesignal_settings($onesignal_wp_settings);
429
 
430
+ return;
431
  }
432
 
433
  public static function saveBooleanSettings(&$onesignal_wp_settings, &$config, $settings)
446
  foreach ($settings as $setting) {
447
  if (array_key_exists($setting, $config)) {
448
  $value = $config[$setting];
449
+ $value = sanitize_text_field($value);
450
  $onesignal_wp_settings[$setting] = $value;
451
  }
452
  }
472
  if (array_key_exists('app_id', $_POST)) {
473
  // check_admin_referer dies if not valid; no if statement necessary
474
  check_admin_referer(OneSignal_Admin::$SAVE_CONFIG_NONCE_ACTION, OneSignal_Admin::$SAVE_CONFIG_NONCE_KEY);
475
+ OneSignal_Admin::save_config_page($_POST);
476
  }
477
  }
478
 
487
 
488
  $onesignal_wp_settings = OneSignal::get_onesignal_settings();
489
  if (
490
+ $onesignal_wp_settings['app_id'] === '' ||
491
+ $onesignal_wp_settings['app_rest_api_key'] === ''
492
  ) {
493
  function admin_notice_setup_not_complete()
494
  {
528
  wp_enqueue_style('semantic-ui', plugin_dir_url(__FILE__).'views/css/semantic-ui.css', false, OneSignal_Admin::$RESOURCES_VERSION);
529
  wp_enqueue_style('site', plugin_dir_url(__FILE__).'views/css/site.css', false, OneSignal_Admin::$RESOURCES_VERSION);
530
 
531
+ wp_enqueue_script('semantic-ui', plugin_dir_url(__FILE__).'views/javascript/semantic-ui.js', array('jquery'), OneSignal_Admin::$RESOURCES_VERSION);
532
+ wp_enqueue_script('site', plugin_dir_url(__FILE__).'views/javascript/site-admin.js', array('jquery'), OneSignal_Admin::$RESOURCES_VERSION);
 
 
533
  }
534
 
535
  /**
537
  */
538
  public static function get_sending_rate_limit_wait_time()
539
  {
 
540
  $last_send_time = get_option('onesignal.last_send_time');
 
541
  if ($last_send_time) {
542
  $time_elapsed_since_last_send = ONESIGNAL_API_RATE_LIMIT_SECONDS - (current_time('timestamp') - intval($last_send_time));
543
  if ($time_elapsed_since_last_send > 0) {
 
 
544
  return $time_elapsed_since_last_send;
545
  }
546
  }
565
  */
566
  public static function uuid($title)
567
  {
568
+ $now_minutes = floor(time()/60);
 
569
  $prev_minutes = get_option('TimeLastUpdated');
570
  $prehash = (string) $title;
571
+ $updatedAMinuteOrMoreAgo = $prev_minutes !== false && ($now_minutes - $prev_minutes) > 0;
572
 
573
+ if ($updatedAMinuteOrMoreAgo || $prev_minutes === false) {
574
  update_option('TimeLastUpdated', $now_minutes);
575
  $timestamp = $now_minutes;
 
 
 
576
  } else {
577
  $timestamp = $prev_minutes;
578
  }
579
 
580
  $prehash = $prehash.$timestamp;
 
581
  $sha1 = substr(sha1($prehash), 0, 32);
 
582
  return substr($sha1, 0, 8).'-'.substr($sha1, 8, 4).'-'.substr($sha1, 12, 4).'-'.substr($sha1, 16, 4).'-'.substr($sha1, 20, 12);
583
  }
584
 
585
+ public static function exec_post_request($onesignal_post_url, $request, $retry_count) {
586
+ if ($retry_count === 0) {
587
+ return NULL;
588
+ }
589
+
590
+ $response = wp_remote_post($onesignal_post_url, $request);
591
+
592
+ if (is_wp_error($response) || !is_array($response) || !isset($response['body'])) {
593
+ return self::exec_post_request($onesignal_post_url, $request, $retry_count-1);
594
+ }
595
+
596
+ return $response;
597
+ }
598
+
599
  /**
600
  * The main function that actually sends a notification to OneSignal.
601
  */
602
  public static function send_notification_on_wp_post($new_status, $old_status, $post)
603
  {
604
  try {
605
+ // quirk of Gutenberg editor leads to two passes if meta box is added
606
+ // conditional removes first pass
607
+ if( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
608
+ return;
609
+ }
610
+
611
+ // Verify that the nonce is valid.
612
+ if (!check_admin_referer(OneSignal_Admin::$SAVE_POST_NONCE_ACTION, OneSignal_Admin::$SAVE_POST_NONCE_KEY)) {
613
+ return;
614
+ }
615
+
616
  $time_to_wait = self::get_sending_rate_limit_wait_time();
617
  if ($time_to_wait > 0) {
618
  set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
628
 
629
  /* Settings related to creating a post involving the WordPress editor displaying the OneSignal meta box
630
  **********************************************************************************************************/
 
631
  /* Returns true if there is POST data */
632
  $was_posted = !empty($_POST);
633
 
634
  /* When this post was created or updated, the OneSignal meta box in the WordPress post editor screen was visible */
635
+ $onesignal_meta_box_present = $was_posted && isset($_POST['onesignal_meta_box_present'], $_POST['onesignal_meta_box_present']) && $_POST['onesignal_meta_box_present'] === 'true';
636
  /* The checkbox "Send notification on post publish/update" on the OneSignal meta box is checked */
637
+ $onesignal_meta_box_send_notification_checked = $was_posted && array_key_exists('send_onesignal_notification', $_POST) && $_POST['send_onesignal_notification'] === 'true';
638
 
639
  /* This is a scheduled post and the OneSignal meta box was present. */
640
+ $post_metadata_was_onesignal_meta_box_present = (get_post_meta($post->ID, 'onesignal_meta_box_present') === true);
641
  /* This is a scheduled post and the user checked "Send a notification on post publish/update". */
642
+ $post_metadata_was_send_notification_checked = (get_post_meta($post->ID, 'onesignal_send_notification') === true);
643
 
644
  /* Either we were just posted from the WordPress post editor form, or this is a scheduled notification and it was previously submitted from the post editor form */
645
  $posted_from_wordpress_editor = $onesignal_meta_box_present || $post_metadata_was_onesignal_meta_box_present;
655
  $settings_send_notification_on_non_editor_post_publish = $onesignal_wp_settings['notification_on_post_from_plugin'];
656
  $additional_custom_post_types_string = str_replace(' ', '', $onesignal_wp_settings['allowed_custom_post_types']);
657
  $additional_custom_post_types_array = array_filter(explode(',', $additional_custom_post_types_string));
 
658
  $non_editor_post_publish_do_send_notification = $settings_send_notification_on_non_editor_post_publish &&
659
+ ($post->post_type === 'post' || in_array($post->post_type, $additional_custom_post_types_array, true)) &&
660
  $old_status !== 'publish';
661
  /* ********************************************************************************************************* */
662
 
674
 
675
  if (has_filter('onesignal_include_post')) {
676
  if (apply_filters('onesignal_include_post', $new_status, $old_status, $post)) {
 
677
  $do_send_notification = true;
678
  }
679
  }
680
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
681
  if ($do_send_notification) {
682
  /* Now that all settings are retrieved, and we are actually sending the notification, reset the post's metadata
683
  * If this post is sent through a plugin in the future, existing metadata will interfere with the send condition logic
685
  */
686
  update_post_meta($post->ID, 'onesignal_meta_box_present', false);
687
  update_post_meta($post->ID, 'onesignal_send_notification', false);
 
688
 
689
  /* Some WordPress environments seem to be inconsistent about whether on_save_post is called before transition_post_status
690
  * This sets the metadata back to true, and will cause a post to be sent even if the checkbox is not checked the next time
693
  if ($was_posted) {
694
  if (array_key_exists('onesignal_meta_box_present', $_POST)) {
695
  unset($_POST['onesignal_meta_box_present']);
 
696
  }
697
  if (array_key_exists('send_onesignal_notification', $_POST)) {
698
  unset($_POST['send_onesignal_notification']);
 
699
  }
700
  }
701
 
702
  $notif_content = OneSignalUtils::decode_entities(get_the_title($post->ID));
703
 
704
  $site_title = '';
705
+ if ($onesignal_wp_settings['notification_title'] !== '') {
706
  $site_title = OneSignalUtils::decode_entities($onesignal_wp_settings['notification_title']);
707
  } else {
708
  $site_title = OneSignalUtils::decode_entities(get_bloginfo('name'));
714
  $site_title = qtrans_use($qtransLang, $site_title, false);
715
  $notif_content = qtrans_use($qtransLang, $notif_content, false);
716
  } catch (Exception $e) {
717
+ return new WP_Error('err', __( "OneSignal: There was a problem sending a notification"));
718
  }
719
  }
720
 
721
  $fields = array(
722
+ 'external_id' => self::uuid($notif_content),
723
+ 'app_id' => $onesignal_wp_settings['app_id'],
724
+ 'headings' => array('en' => $site_title),
725
+ 'included_segments' => array('All'),
726
+ 'isAnyWeb' => true,
727
+ 'url' => get_permalink($post->ID),
728
+ 'contents' => array('en' => $notif_content),
729
+ );
730
 
731
  $send_to_mobile_platforms = $onesignal_wp_settings['send_to_mobile_platforms'];
732
+ if ($send_to_mobile_platforms === true) {
733
  $fields['isIos'] = true;
734
  $fields['isAndroid'] = true;
735
  }
740
  }
741
 
742
  if (has_post_thumbnail($post->ID)) {
 
 
743
  $post_thumbnail_id = get_post_thumbnail_id($post->ID);
744
  // Higher resolution (2x retina, + a little more) for the notification small icon
745
  $thumbnail_sized_images_array = wp_get_attachment_image_src($post_thumbnail_id, array(192, 192), true);
746
  // Much higher resolution for the notification large image
747
  $large_sized_images_array = wp_get_attachment_image_src($post_thumbnail_id, 'large', true);
748
 
749
+ $config_use_featured_image_as_icon = $onesignal_wp_settings['showNotificationIconFromPostThumbnail'] === true;
750
+ $config_use_featured_image_as_image = $onesignal_wp_settings['showNotificationImageFromPostThumbnail'] === true;
 
 
751
 
752
  // get the icon image from wordpress if it exists
753
  if ($config_use_featured_image_as_icon) {
 
754
  $thumbnail_image = $thumbnail_sized_images_array[0];
755
  // set the icon image for both chrome and firefox-1
756
  $fields['chrome_web_icon'] = $thumbnail_image;
757
  $fields['firefox_icon'] = $thumbnail_image;
 
758
  }
759
  if ($config_use_featured_image_as_image) {
 
760
  $large_image = $large_sized_images_array[0];
761
  $fields['chrome_web_image'] = $large_image;
 
762
  }
763
  }
764
 
765
  if (has_filter('onesignal_send_notification')) {
 
766
  $fields = apply_filters('onesignal_send_notification', $fields, $new_status, $old_status, $post);
 
767
 
768
  // If the filter adds "do_send_notification: false", do not send a notification
769
+ if (array_key_exists('do_send_notification', $fields) && $fields['do_send_notification'] === false) {
770
  return;
771
  }
772
  }
786
  $onesignal_auth_key = $onesignal_wp_settings['app_rest_api_key'];
787
 
788
  $request = array(
789
+ 'headers' => array(
790
+ 'content-type' => 'application/json;charset=utf-8',
791
+ 'Authorization' => 'Basic '.$onesignal_auth_key,
792
+ ),
793
+ 'body' => wp_json_encode($fields),
794
+ 'timeout' => 3,
795
+ );
796
+
797
+ $response = self::exec_post_request($onesignal_post_url, $request, 20); // try 20 times
798
+
799
+ if (is_null($response)) {
800
+ set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
801
+ <p><strong>OneSignal Push:</strong><em> There was a problem sending your notification.</em></p>
802
+ </div>', 86400);
803
+ return;
804
+ }
805
+
806
+ if (isset($response['body'])) {
 
807
  $response_body = json_decode($response['body'], true);
808
  }
809
 
811
  $status = $response['response']['code'];
812
  }
813
 
814
+ update_post_meta($post->ID, 'response_body', wp_json_encode($response_body));
815
  update_post_meta($post->ID, 'status', $status);
816
 
817
+ if ($status !== 200) {
818
+ if ($status !== 0) {
 
 
819
  set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
820
  <p><strong>OneSignal Push:</strong><em> There was a '.$status.' error sending your notification.</em></p>
821
  </div>', 86400);
827
  }
828
  } else {
829
  if (!empty($response)) {
 
830
 
831
  // API can send a 200 OK even if the notification failed to send
832
  if (isset($response['body'])) {
833
  $response_body = json_decode($response['body'], true);
834
  if (isset($response_body['recipients'])) {
835
  $recipient_count = $response_body['recipients'];
 
 
836
  }
 
 
837
  }
838
 
839
  // updates meta so that recipient count is available for GET request from client
840
  update_post_meta($post->ID, 'recipients', $recipient_count);
841
 
842
  $sent_or_scheduled = array_key_exists('send_after', $fields) ? 'scheduled' : 'sent';
843
+ $config_show_notification_send_status_message = $onesignal_wp_settings['show_notification_send_status_message'] === true;
844
 
845
  if ($config_show_notification_send_status_message) {
846
+ if ($recipient_count !== 0) {
847
+ $delivery_link_text = $sent_or_scheduled === 'sent' ? ' Go to your app\'s "Delivery" tab to check sent messages: <a target="_blank" href="https://app.onesignal.com/apps/">https://app.onesignal.com/apps/</a>' : '';
848
+ set_transient('onesignal_transient_success', '<div class="updated notice notice-success is-dismissible">
849
  <div class="components-notice__content">
850
  <p><strong>OneSignal Push:</strong><em> Successfully '.$sent_or_scheduled.' a notification to '.$recipient_count.' recipients.'.$delivery_link_text.'</em></p>
851
  </div>
861
 
862
  if (defined('ONESIGNAL_DEBUG') || class_exists('WDS_Log_Post')) {
863
  fclose($out);
 
864
  }
865
 
866
  self::update_last_sent_timestamp();
 
867
  return $response;
868
  }
869
  } catch (Exception $e) {
870
+ return new WP_Error('err', __( "OneSignal: There was a problem sending a notification"));
871
+ } }
 
872
 
873
  public static function was_post_restored_from_trash($old_status, $new_status)
874
  {
877
 
878
  public static function on_transition_post_status($new_status, $old_status, $post)
879
  {
880
+ if ($post->post_type === 'wdslp-wds-log' ||
881
  self::was_post_restored_from_trash($old_status, $new_status)) {
882
  // It's important not to call onesignal_debug() on posts of type wdslp-wds-log, otherwise each post will recursively generate 4 more posts
883
  return;
884
  }
885
  if (has_filter('onesignal_include_post')) {
 
886
  if (apply_filters('onesignal_include_post', $new_status, $old_status, $post)) {
887
  // If the filter returns "$do_include_post: true", always process this post
 
888
  self::send_notification_on_wp_post($new_status, $old_status, $post);
889
 
890
  return;
891
  }
892
  }
893
  if (has_filter('onesignal_exclude_post')) {
 
894
  if (apply_filters('onesignal_exclude_post', $new_status, $old_status, $post)) {
895
  // If the filter returns "$do_exclude_post: false", do not process this post at all
 
896
 
897
  return;
898
  }
899
  }
900
  if (!(empty($post) ||
901
  $new_status !== 'publish' ||
902
+ $post->post_type === 'page')) {
903
  self::send_notification_on_wp_post($new_status, $old_status, $post);
904
  }
905
  }
906
  }
 
907
  ?>
onesignal-public.php CHANGED
@@ -2,58 +2,14 @@
2
 
3
  defined('ABSPATH') or die('This page may not be accessed directly.');
4
 
5
- function onesignal_debug()
6
  {
7
- if (!defined('ONESIGNAL_DEBUG') && !class_exists('WDS_Log_Post')) {
8
- return;
9
- }
10
- $numargs = func_num_args();
11
- $arg_list = func_get_args();
12
- $bt = debug_backtrace();
13
- $output = '['.$bt[1]['function'].'] ';
14
- for ($i = 0; $i < $numargs; ++$i) {
15
- $arg = $arg_list[$i];
16
-
17
- if (is_string($arg)) {
18
- $arg_output = $arg;
19
- } else {
20
- $arg_output = var_export($arg, true);
21
- }
22
-
23
- if ($arg === '') {
24
- $arg_output = '""';
25
- } elseif ($arg === null) {
26
- $arg_output = 'null';
27
- }
28
-
29
- $output = $output.$arg_output.' ';
30
- }
31
- $output = substr($output, 0, -1);
32
- $output = substr($output, 0, 1024); // Restrict messages to 1024 characters in length
33
- if (defined('ONESIGNAL_DEBUG')) {
34
- error_log('OneSignal: '.$output);
35
- }
36
- if (class_exists('WDS_Log_Post')) {
37
- $num_log_posts = wp_count_posts('wdslp-wds-log', 'readable');
38
- // Limit the total number of log entries to 500
39
- if ($num_log_posts && property_exists($num_log_posts, 'publish') && $num_log_posts->publish < 500) {
40
- WDS_Log_Post::log_message($output, '', 'general');
41
- }
42
- }
43
- }
44
-
45
- function onesignal_debug_post($post)
46
- {
47
- if (!$post) {
48
- return;
49
- }
50
-
51
- return onesignal_debug('Post:', array('ID' => $post->ID,
52
- 'Post Date' => $post->post_date,
53
- 'Modified Date' => $post->post_modified,
54
- 'Title' => $post->post_title,
55
- 'Status:' => $post->post_status,
56
- 'Type:' => $post->post_type, ));
57
  }
58
 
59
  class OneSignal_Public
@@ -75,11 +31,19 @@ class OneSignal_Public
75
  <?php
76
  }
77
 
 
 
 
 
 
 
 
 
78
  public static function onesignal_header()
79
  {
80
  $onesignal_wp_settings = OneSignal::get_onesignal_settings();
81
 
82
- if ($onesignal_wp_settings['subdomain'] == '') {
83
  if (strpos(ONESIGNAL_PLUGIN_URL, 'http://localhost') === false && strpos(ONESIGNAL_PLUGIN_URL, 'http://127.0.0.1') === false) {
84
  $current_plugin_url = preg_replace("/(http:\/\/)/i", 'https://', ONESIGNAL_PLUGIN_URL);
85
  } else {
@@ -88,10 +52,14 @@ class OneSignal_Public
88
  OneSignal_Public::insert_onesignal_stamp();
89
  } ?>
90
  <?php
 
 
91
  if (defined('ONESIGNAL_DEBUG') && defined('ONESIGNAL_LOCAL')) {
92
- echo '<script src="https://localhost:3001/sdks/OneSignalSDK.js" async></script>';
 
93
  } else {
94
- echo '<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script>';
 
95
  } ?>
96
  <script>
97
 
@@ -103,123 +71,106 @@ class OneSignal_Public
103
  OneSignal.SERVICE_WORKER_PARAM = { scope: '/' };
104
 
105
  <?php
106
-
107
- if ($onesignal_wp_settings['default_icon'] != '') {
108
- echo 'OneSignal.setDefaultIcon("'.OneSignalUtils::decode_entities($onesignal_wp_settings['default_icon'])."\");\n";
109
- }
110
-
111
- if ($onesignal_wp_settings['default_url'] != '') {
112
- echo 'OneSignal.setDefaultNotificationUrl("'.OneSignalUtils::decode_entities($onesignal_wp_settings['default_url']).'");';
113
  } else {
114
- echo 'OneSignal.setDefaultNotificationUrl("'.OneSignalUtils::decode_entities(get_site_url())."\");\n";
115
  } ?>
116
  var oneSignal_options = {};
117
  window._oneSignalInitOptions = oneSignal_options;
118
 
119
  <?php
120
  echo "oneSignal_options['wordpress'] = true;\n";
121
- echo "oneSignal_options['appId'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['app_id'])."';\n";
122
 
123
- if ($onesignal_wp_settings['prompt_auto_register'] == '1') {
124
  echo "oneSignal_options['autoRegister'] = true;\n";
125
  } else {
126
  echo "oneSignal_options['autoRegister'] = false;\n";
127
  }
128
 
129
- if ($onesignal_wp_settings['use_http_permission_request'] == '1') {
130
  echo "oneSignal_options['httpPermissionRequest'] = { };\n";
131
  echo "oneSignal_options['httpPermissionRequest']['enable'] = true;\n";
132
-
133
- if (array_key_exists('customize_http_permission_request', $onesignal_wp_settings) && $onesignal_wp_settings['customize_http_permission_request'] == '1') {
134
- echo "oneSignal_options['httpPermissionRequest']['modalTitle'] = \"".OneSignalUtils::html_safe($onesignal_wp_settings['http_permission_request_modal_title'])."\";\n";
135
- echo "oneSignal_options['httpPermissionRequest']['modalMessage'] = \"".OneSignalUtils::html_safe($onesignal_wp_settings['http_permission_request_modal_message'])."\";\n";
136
- echo "oneSignal_options['httpPermissionRequest']['modalButtonText'] = \"".OneSignalUtils::html_safe($onesignal_wp_settings['http_permission_request_modal_button_text'])."\";\n";
137
- }
138
  }
139
 
140
- if ($onesignal_wp_settings['send_welcome_notification'] == '1') {
141
  echo "oneSignal_options['welcomeNotification'] = { };\n";
142
- echo "oneSignal_options['welcomeNotification']['title'] = \"".OneSignalUtils::html_safe($onesignal_wp_settings['welcome_notification_title'])."\";\n";
143
- echo "oneSignal_options['welcomeNotification']['message'] = \"".OneSignalUtils::html_safe($onesignal_wp_settings['welcome_notification_message'])."\";\n";
144
- if ($onesignal_wp_settings['welcome_notification_url'] != '') {
145
- echo "oneSignal_options['welcomeNotification']['url'] = \"".OneSignalUtils::html_safe($onesignal_wp_settings['welcome_notification_url'])."\";\n";
146
  }
147
  } else {
148
  echo "oneSignal_options['welcomeNotification'] = { };\n";
149
  echo "oneSignal_options['welcomeNotification']['disable'] = true;\n";
150
  }
151
 
152
- if ($onesignal_wp_settings['subdomain'] != '') {
153
- echo "oneSignal_options['subdomainName'] = \"".OneSignalUtils::html_safe($onesignal_wp_settings['subdomain'])."\";\n";
154
  } else {
155
- echo "oneSignal_options['path'] = \"".$current_plugin_url."sdk_files/\";\n";
156
  }
157
 
158
- if (@$onesignal_wp_settings['safari_web_id']) {
159
- echo "oneSignal_options['safari_web_id'] = \"".OneSignalUtils::html_safe($onesignal_wp_settings['safari_web_id'])."\";\n";
160
  }
161
 
162
- if ($onesignal_wp_settings['persist_notifications'] == 'platform-default') {
163
  echo "oneSignal_options['persistNotification'] = false;\n";
164
- } elseif ($onesignal_wp_settings['persist_notifications'] == 'yes-all') {
165
  echo "oneSignal_options['persistNotification'] = true;\n";
166
  }
167
 
168
  echo "oneSignal_options['promptOptions'] = { };\n";
169
- if (array_key_exists('prompt_customize_enable', $onesignal_wp_settings) && $onesignal_wp_settings['prompt_customize_enable'] == '1') {
170
- if ($onesignal_wp_settings['prompt_action_message'] != '') {
171
- echo "oneSignal_options['promptOptions']['actionMessage'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_action_message'])."';\n";
172
  }
173
- if ($onesignal_wp_settings['prompt_example_notification_title_desktop'] != '') {
174
- echo "oneSignal_options['promptOptions']['exampleNotificationTitleDesktop'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_example_notification_title_desktop'])."';\n";
175
  }
176
- if ($onesignal_wp_settings['prompt_example_notification_message_desktop'] != '') {
177
- echo "oneSignal_options['promptOptions']['exampleNotificationMessageDesktop'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_example_notification_message_desktop'])."';\n";
178
  }
179
- if ($onesignal_wp_settings['prompt_example_notification_title_mobile'] != '') {
180
- echo "oneSignal_options['promptOptions']['exampleNotificationTitleMobile'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_example_notification_title_mobile'])."';\n";
181
  }
182
- if ($onesignal_wp_settings['prompt_example_notification_message_mobile'] != '') {
183
- echo "oneSignal_options['promptOptions']['exampleNotificationMessageMobile'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_example_notification_message_mobile'])."';\n";
184
  }
185
- if ($onesignal_wp_settings['prompt_example_notification_caption'] != '') {
186
- echo "oneSignal_options['promptOptions']['exampleNotificationCaption'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_example_notification_caption'])."';\n";
187
  }
188
- if ($onesignal_wp_settings['prompt_accept_button_text'] != '') {
189
- echo "oneSignal_options['promptOptions']['acceptButtonText'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_accept_button_text'])."';\n";
190
  }
191
- if ($onesignal_wp_settings['prompt_cancel_button_text'] != '') {
192
- echo "oneSignal_options['promptOptions']['cancelButtonText'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_cancel_button_text'])."';\n";
193
  }
194
- if ($onesignal_wp_settings['prompt_site_name'] != '') {
195
- echo "oneSignal_options['promptOptions']['siteName'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_site_name'])."';\n";
196
  }
197
- if ($onesignal_wp_settings['prompt_auto_accept_title'] != '') {
198
- echo "oneSignal_options['promptOptions']['autoAcceptTitle'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['prompt_auto_accept_title'])."';\n";
199
  }
200
  }
201
 
202
- if (array_key_exists('notifyButton_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_enable'] == '1') {
203
  echo "oneSignal_options['notifyButton'] = { };\n";
204
  echo "oneSignal_options['notifyButton']['enable'] = true;\n";
205
 
206
- if (array_key_exists('notifyButton_position', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_position'] != '') {
207
- echo "oneSignal_options['notifyButton']['position'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_position'])."';\n";
208
  }
209
- if (array_key_exists('notifyButton_theme', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_theme'] != '') {
210
- echo "oneSignal_options['notifyButton']['theme'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_theme'])."';\n";
211
  }
212
- if (array_key_exists('notifyButton_size', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_size'] != '') {
213
- echo "oneSignal_options['notifyButton']['size'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_size'])."';\n";
214
  }
215
 
216
- if ($onesignal_wp_settings['notifyButton_prenotify'] == '1') {
217
- echo "oneSignal_options['notifyButton']['prenotify'] = true;\n";
218
- } else {
219
- echo "oneSignal_options['notifyButton']['prenotify'] = false;\n";
220
- }
221
-
222
- if ($onesignal_wp_settings['notifyButton_showAfterSubscribed'] !== true) {
223
  echo "oneSignal_options['notifyButton']['displayPredicate'] = function() {
224
  return OneSignal.isPushNotificationsEnabled()
225
  .then(function(isPushEnabled) {
@@ -228,100 +179,97 @@ class OneSignal_Public
228
  };\n";
229
  }
230
 
231
- if ($onesignal_wp_settings['use_modal_prompt'] == '1') {
232
  echo "oneSignal_options['notifyButton']['modalPrompt'] = true;\n";
233
  }
234
 
235
- if ($onesignal_wp_settings['notifyButton_showcredit'] == '1') {
236
  echo "oneSignal_options['notifyButton']['showCredit'] = true;\n";
237
  } else {
238
  echo "oneSignal_options['notifyButton']['showCredit'] = false;\n";
239
  }
240
 
241
- if (array_key_exists('notifyButton_customize_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_customize_enable'] == '1') {
242
  echo "oneSignal_options['notifyButton']['text'] = {};\n";
243
- if ($onesignal_wp_settings['notifyButton_message_prenotify'] != '') {
244
- echo "oneSignal_options['notifyButton']['text']['message.prenotify'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_message_prenotify'])."';\n";
245
- }
246
- if ($onesignal_wp_settings['notifyButton_tip_state_unsubscribed'] != '') {
247
- echo "oneSignal_options['notifyButton']['text']['tip.state.unsubscribed'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_tip_state_unsubscribed'])."';\n";
248
  }
249
- if ($onesignal_wp_settings['notifyButton_tip_state_subscribed'] != '') {
250
- echo "oneSignal_options['notifyButton']['text']['tip.state.subscribed'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_tip_state_subscribed'])."';\n";
251
  }
252
- if ($onesignal_wp_settings['notifyButton_tip_state_blocked'] != '') {
253
- echo "oneSignal_options['notifyButton']['text']['tip.state.blocked'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_tip_state_blocked'])."';\n";
254
  }
255
- if ($onesignal_wp_settings['notifyButton_message_action_subscribed'] != '') {
256
- echo "oneSignal_options['notifyButton']['text']['message.action.subscribed'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_message_action_subscribed'])."';\n";
257
  }
258
- if ($onesignal_wp_settings['notifyButton_message_action_resubscribed'] != '') {
259
- echo "oneSignal_options['notifyButton']['text']['message.action.resubscribed'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_message_action_resubscribed'])."';\n";
260
  }
261
- if ($onesignal_wp_settings['notifyButton_message_action_unsubscribed'] != '') {
262
- echo "oneSignal_options['notifyButton']['text']['message.action.unsubscribed'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_message_action_unsubscribed'])."';\n";
263
  }
264
- if ($onesignal_wp_settings['notifyButton_dialog_main_title'] != '') {
265
- echo "oneSignal_options['notifyButton']['text']['dialog.main.title'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_dialog_main_title'])."';\n";
266
  }
267
- if ($onesignal_wp_settings['notifyButton_dialog_main_button_subscribe'] != '') {
268
- echo "oneSignal_options['notifyButton']['text']['dialog.main.button.subscribe'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_dialog_main_button_subscribe'])."';\n";
269
  }
270
- if ($onesignal_wp_settings['notifyButton_dialog_main_button_unsubscribe'] != '') {
271
- echo "oneSignal_options['notifyButton']['text']['dialog.main.button.unsubscribe'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_dialog_main_button_unsubscribe'])."';\n";
272
  }
273
- if ($onesignal_wp_settings['notifyButton_dialog_blocked_title'] != '') {
274
- echo "oneSignal_options['notifyButton']['text']['dialog.blocked.title'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_dialog_blocked_title'])."';\n";
275
  }
276
- if ($onesignal_wp_settings['notifyButton_dialog_blocked_message'] != '') {
277
- echo "oneSignal_options['notifyButton']['text']['dialog.blocked.message'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_dialog_blocked_message'])."';\n";
278
  }
279
  }
280
 
281
- if (array_key_exists('notifyButton_customize_colors_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_customize_colors_enable'] == '1') {
282
  echo "oneSignal_options['notifyButton']['colors'] = {};\n";
283
- if ($onesignal_wp_settings['notifyButton_color_background'] != '') {
284
- echo "oneSignal_options['notifyButton']['colors']['circle.background'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_background'])."';\n";
285
  }
286
- if ($onesignal_wp_settings['notifyButton_color_foreground'] != '') {
287
- echo "oneSignal_options['notifyButton']['colors']['circle.foreground'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_foreground'])."';\n";
288
  }
289
- if ($onesignal_wp_settings['notifyButton_color_badge_background'] != '') {
290
- echo "oneSignal_options['notifyButton']['colors']['badge.background'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_badge_background'])."';\n";
291
  }
292
- if ($onesignal_wp_settings['notifyButton_color_badge_foreground'] != '') {
293
- echo "oneSignal_options['notifyButton']['colors']['badge.foreground'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_badge_foreground'])."';\n";
294
  }
295
- if ($onesignal_wp_settings['notifyButton_color_badge_border'] != '') {
296
- echo "oneSignal_options['notifyButton']['colors']['badge.bordercolor'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_badge_border'])."';\n";
297
  }
298
- if ($onesignal_wp_settings['notifyButton_color_pulse'] != '') {
299
- echo "oneSignal_options['notifyButton']['colors']['pulse.color'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_pulse'])."';\n";
300
  }
301
- if ($onesignal_wp_settings['notifyButton_color_popup_button_background'] != '') {
302
- echo "oneSignal_options['notifyButton']['colors']['dialog.button.background'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_popup_button_background'])."';\n";
303
  }
304
- if ($onesignal_wp_settings['notifyButton_color_popup_button_background_hover'] != '') {
305
- echo "oneSignal_options['notifyButton']['colors']['dialog.button.background.hovering'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_popup_button_background_hover'])."';\n";
306
  }
307
- if ($onesignal_wp_settings['notifyButton_color_popup_button_background_active'] != '') {
308
- echo "oneSignal_options['notifyButton']['colors']['dialog.button.background.active'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_popup_button_background_active'])."';\n";
309
  }
310
- if ($onesignal_wp_settings['notifyButton_color_popup_button_color'] != '') {
311
- echo "oneSignal_options['notifyButton']['colors']['dialog.button.foreground'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_color_popup_button_color'])."';\n";
312
  }
313
  }
314
 
315
- if (array_key_exists('notifyButton_customize_offset_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_customize_offset_enable'] == '1') {
316
  echo "oneSignal_options['notifyButton']['offset'] = {};\n";
317
- if ($onesignal_wp_settings['notifyButton_offset_bottom'] != '') {
318
- echo "oneSignal_options['notifyButton']['offset']['bottom'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_offset_bottom'])."';\n";
319
  }
320
- if ($onesignal_wp_settings['notifyButton_offset_left'] != '') {
321
- echo "oneSignal_options['notifyButton']['offset']['left'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_offset_left'])."';\n";
322
  }
323
- if ($onesignal_wp_settings['notifyButton_offset_right'] != '') {
324
- echo "oneSignal_options['notifyButton']['offset']['right'] = '".OneSignalUtils::html_safe($onesignal_wp_settings['notifyButton_offset_right'])."';\n";
325
  }
326
  }
327
  }
@@ -341,7 +289,8 @@ class OneSignal_Public
341
  <?php
342
  }
343
  } else {
344
- if (array_key_exists('use_slidedown_permission_message_for_https', $onesignal_wp_settings) && $onesignal_wp_settings['use_slidedown_permission_message_for_https'] == '1') {
 
345
  ?>
346
  oneSignal_options['autoRegister'] = false;
347
  OneSignal.showHttpPrompt();
@@ -364,7 +313,7 @@ class OneSignal_Public
364
  var oneSignal_elements = document.getElementsByClassName("OneSignal-prompt");
365
 
366
  <?php
367
- if ($onesignal_wp_settings['use_modal_prompt'] == '1') {
368
  echo "var oneSignalLinkClickHandler = function(event) { OneSignal.push(['registerForPushNotifications', {modalPrompt: true}]); event.preventDefault(); };";
369
  } else {
370
  echo "var oneSignalLinkClickHandler = function(event) { OneSignal.push(['registerForPushNotifications']); event.preventDefault(); };";
@@ -382,7 +331,6 @@ class OneSignal_Public
382
  });
383
  }
384
  </script>
385
-
386
  <?php
387
  }
388
  }
2
 
3
  defined('ABSPATH') or die('This page may not be accessed directly.');
4
 
5
+ function add_async_for_script($url)
6
  {
7
+ if (strpos($url, '#asyncload') === false)
8
+ return $url;
9
+ else if (is_admin())
10
+ return str_replace('#asyncload', '', $url);
11
+ else
12
+ return str_replace('#asyncload', '', $url)."' async='async";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
 
15
  class OneSignal_Public
31
  <?php
32
  }
33
 
34
+ private static function valid_for_key($key, $array) {
35
+ if(array_key_exists($key, $array) && $array[$key] !== ''){
36
+ return true;
37
+ }
38
+
39
+ return false;
40
+ }
41
+
42
  public static function onesignal_header()
43
  {
44
  $onesignal_wp_settings = OneSignal::get_onesignal_settings();
45
 
46
+ if (array_key_exists('subdomain', $onesignal_wp_settings) && $onesignal_wp_settings['subdomain'] === '') {
47
  if (strpos(ONESIGNAL_PLUGIN_URL, 'http://localhost') === false && strpos(ONESIGNAL_PLUGIN_URL, 'http://127.0.0.1') === false) {
48
  $current_plugin_url = preg_replace("/(http:\/\/)/i", 'https://', ONESIGNAL_PLUGIN_URL);
49
  } else {
52
  OneSignal_Public::insert_onesignal_stamp();
53
  } ?>
54
  <?php
55
+ add_filter('clean_url', 'add_async_for_script', 11, 1);
56
+
57
  if (defined('ONESIGNAL_DEBUG') && defined('ONESIGNAL_LOCAL')) {
58
+ wp_register_script('local_sdk', 'https://localhost:3001/sdks/OneSignalSDK.js#asyncload', array('jquery'), false, true);
59
+ wp_enqueue_script('local_sdk');
60
  } else {
61
+ wp_register_script('remote_sdk', 'https://cdn.onesignal.com/sdks/OneSignalSDK.js#asyncload', array('jquery'), false, true);
62
+ wp_enqueue_script('remote_sdk');
63
  } ?>
64
  <script>
65
 
71
  OneSignal.SERVICE_WORKER_PARAM = { scope: '/' };
72
 
73
  <?php
74
+ if (self::valid_for_key('default_url', $onesignal_wp_settings)) {
75
+ echo 'OneSignal.setDefaultNotificationUrl("'.esc_url($onesignal_wp_settings['default_url']).'");';
 
 
 
 
 
76
  } else {
77
+ echo 'OneSignal.setDefaultNotificationUrl("'.esc_url(get_site_url())."\");\n";
78
  } ?>
79
  var oneSignal_options = {};
80
  window._oneSignalInitOptions = oneSignal_options;
81
 
82
  <?php
83
  echo "oneSignal_options['wordpress'] = true;\n";
84
+ echo "oneSignal_options['appId'] = '".esc_html($onesignal_wp_settings['app_id'])."';\n";
85
 
86
+ if (array_key_exists('prompt_auto_register', $onesignal_wp_settings) && $onesignal_wp_settings['prompt_auto_register'] === true) {
87
  echo "oneSignal_options['autoRegister'] = true;\n";
88
  } else {
89
  echo "oneSignal_options['autoRegister'] = false;\n";
90
  }
91
 
92
+ if (array_key_exists('use_http_permission_request', $onesignal_wp_settings) && $onesignal_wp_settings['use_http_permission_request'] === true) {
93
  echo "oneSignal_options['httpPermissionRequest'] = { };\n";
94
  echo "oneSignal_options['httpPermissionRequest']['enable'] = true;\n";
 
 
 
 
 
 
95
  }
96
 
97
+ if (array_key_exists('send_welcome_notification', $onesignal_wp_settings) && $onesignal_wp_settings['send_welcome_notification'] === true) {
98
  echo "oneSignal_options['welcomeNotification'] = { };\n";
99
+ echo "oneSignal_options['welcomeNotification']['title'] = \"".esc_html($onesignal_wp_settings['welcome_notification_title'])."\";\n";
100
+ echo "oneSignal_options['welcomeNotification']['message'] = \"".esc_html($onesignal_wp_settings['welcome_notification_message'])."\";\n";
101
+ if ($onesignal_wp_settings['welcome_notification_url'] !== '') {
102
+ echo "oneSignal_options['welcomeNotification']['url'] = \"".esc_html($onesignal_wp_settings['welcome_notification_url'])."\";\n";
103
  }
104
  } else {
105
  echo "oneSignal_options['welcomeNotification'] = { };\n";
106
  echo "oneSignal_options['welcomeNotification']['disable'] = true;\n";
107
  }
108
 
109
+ if (self::valid_for_key('subdomain', $onesignal_wp_settings)) {
110
+ echo "oneSignal_options['subdomainName'] = \"".esc_html($onesignal_wp_settings['subdomain'])."\";\n";
111
  } else {
112
+ echo "oneSignal_options['path'] = \"".esc_html($current_plugin_url)."sdk_files/\";\n";
113
  }
114
 
115
+ if ($onesignal_wp_settings['safari_web_id']) {
116
+ echo "oneSignal_options['safari_web_id'] = \"".esc_html($onesignal_wp_settings['safari_web_id'])."\";\n";
117
  }
118
 
119
+ if (array_key_exists('persist_notifications', $onesignal_wp_settings) && $onesignal_wp_settings['persist_notifications'] === 'platform-default') {
120
  echo "oneSignal_options['persistNotification'] = false;\n";
121
+ } elseif (array_key_exists('persist_notifications', $onesignal_wp_settings) && $onesignal_wp_settings['persist_notifications'] === 'yes-all') {
122
  echo "oneSignal_options['persistNotification'] = true;\n";
123
  }
124
 
125
  echo "oneSignal_options['promptOptions'] = { };\n";
126
+ if (array_key_exists('prompt_customize_enable', $onesignal_wp_settings) && $onesignal_wp_settings['prompt_customize_enable'] === true) {
127
+ if (self::valid_for_key('prompt_action_message', $onesignal_wp_settings)) {
128
+ echo "oneSignal_options['promptOptions']['actionMessage'] = '".esc_html($onesignal_wp_settings['prompt_action_message'])."';\n";
129
  }
130
+ if (self::valid_for_key('prompt_example_notification_title_desktop', $onesignal_wp_settings)) {
131
+ echo "oneSignal_options['promptOptions']['exampleNotificationTitleDesktop'] = '".esc_html($onesignal_wp_settings['prompt_example_notification_title_desktop'])."';\n";
132
  }
133
+ if (self::valid_for_key('prompt_example_notification_message_desktop', $onesignal_wp_settings)) {
134
+ echo "oneSignal_options['promptOptions']['exampleNotificationMessageDesktop'] = '".esc_html($onesignal_wp_settings['prompt_example_notification_message_desktop'])."';\n";
135
  }
136
+ if (self::valid_for_key('prompt_example_notification_title_mobile', $onesignal_wp_settings)) {
137
+ echo "oneSignal_options['promptOptions']['exampleNotificationTitleMobile'] = '".esc_html($onesignal_wp_settings['prompt_example_notification_title_mobile'])."';\n";
138
  }
139
+ if (self::valid_for_key('prompt_example_notification_message_mobile', $onesignal_wp_settings)) {
140
+ echo "oneSignal_options['promptOptions']['exampleNotificationMessageMobile'] = '".esc_html($onesignal_wp_settings['prompt_example_notification_message_mobile'])."';\n";
141
  }
142
+ if (self::valid_for_key('prompt_example_notification_caption', $onesignal_wp_settings)) {
143
+ echo "oneSignal_options['promptOptions']['exampleNotificationCaption'] = '".esc_html($onesignal_wp_settings['prompt_example_notification_caption'])."';\n";
144
  }
145
+ if (self::valid_for_key('prompt_accept_button_text', $onesignal_wp_settings)) {
146
+ echo "oneSignal_options['promptOptions']['acceptButtonText'] = '".esc_html($onesignal_wp_settings['prompt_accept_button_text'])."';\n";
147
  }
148
+ if (self::valid_for_key('prompt_cancel_button_text', $onesignal_wp_settings)) {
149
+ echo "oneSignal_options['promptOptions']['cancelButtonText'] = '".esc_html($onesignal_wp_settings['prompt_cancel_button_text'])."';\n";
150
  }
151
+ if (self::valid_for_key('prompt_site_name', $onesignal_wp_settings)) {
152
+ echo "oneSignal_options['promptOptions']['siteName'] = '".esc_html($onesignal_wp_settings['prompt_site_name'])."';\n";
153
  }
154
+ if (self::valid_for_key('prompt_auto_accept_title', $onesignal_wp_settings)) {
155
+ echo "oneSignal_options['promptOptions']['autoAcceptTitle'] = '".esc_html($onesignal_wp_settings['prompt_auto_accept_title'])."';\n";
156
  }
157
  }
158
 
159
+ if (array_key_exists('notifyButton_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_enable'] === true) {
160
  echo "oneSignal_options['notifyButton'] = { };\n";
161
  echo "oneSignal_options['notifyButton']['enable'] = true;\n";
162
 
163
+ if (self::valid_for_key('notifyButton_position', $onesignal_wp_settings)) {
164
+ echo "oneSignal_options['notifyButton']['position'] = '".esc_html($onesignal_wp_settings['notifyButton_position'])."';\n";
165
  }
166
+ if (self::valid_for_key('notifyButton_theme', $onesignal_wp_settings)) {
167
+ echo "oneSignal_options['notifyButton']['theme'] = '".esc_html($onesignal_wp_settings['notifyButton_theme'])."';\n";
168
  }
169
+ if (self::valid_for_key('notifyButton_size', $onesignal_wp_settings)) {
170
+ echo "oneSignal_options['notifyButton']['size'] = '".esc_html($onesignal_wp_settings['notifyButton_size'])."';\n";
171
  }
172
 
173
+ if (array_key_exists('notifyButton_showAfterSubscribed', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_showAfterSubscribed'] !== true) {
 
 
 
 
 
 
174
  echo "oneSignal_options['notifyButton']['displayPredicate'] = function() {
175
  return OneSignal.isPushNotificationsEnabled()
176
  .then(function(isPushEnabled) {
179
  };\n";
180
  }
181
 
182
+ if (array_key_exists('use_modal_prompt', $onesignal_wp_settings) && $onesignal_wp_settings['use_modal_prompt'] === true) {
183
  echo "oneSignal_options['notifyButton']['modalPrompt'] = true;\n";
184
  }
185
 
186
+ if (array_key_exists('notifyButton_showcredit', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_showcredit'] === true) {
187
  echo "oneSignal_options['notifyButton']['showCredit'] = true;\n";
188
  } else {
189
  echo "oneSignal_options['notifyButton']['showCredit'] = false;\n";
190
  }
191
 
192
+ if (array_key_exists('notifyButton_customize_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_customize_enable'] === true) {
193
  echo "oneSignal_options['notifyButton']['text'] = {};\n";
194
+ if (self::valid_for_key('notifyButton_tip_state_unsubscribed', $onesignal_wp_settings)) {
195
+ echo "oneSignal_options['notifyButton']['text']['tip.state.unsubscribed'] = '".esc_html($onesignal_wp_settings['notifyButton_tip_state_unsubscribed'])."';\n";
 
 
 
196
  }
197
+ if (self::valid_for_key('notifyButton_tip_state_subscribed', $onesignal_wp_settings)) {
198
+ echo "oneSignal_options['notifyButton']['text']['tip.state.subscribed'] = '".esc_html($onesignal_wp_settings['notifyButton_tip_state_subscribed'])."';\n";
199
  }
200
+ if (self::valid_for_key('notifyButton_tip_state_blocked', $onesignal_wp_settings)) {
201
+ echo "oneSignal_options['notifyButton']['text']['tip.state.blocked'] = '".esc_html($onesignal_wp_settings['notifyButton_tip_state_blocked'])."';\n";
202
  }
203
+ if (self::valid_for_key('notifyButton_message_action_subscribed', $onesignal_wp_settings)) {
204
+ echo "oneSignal_options['notifyButton']['text']['message.action.subscribed'] = '".esc_html($onesignal_wp_settings['notifyButton_message_action_subscribed'])."';\n";
205
  }
206
+ if (self::valid_for_key('notifyButton_message_action_resubscribed', $onesignal_wp_settings)) {
207
+ echo "oneSignal_options['notifyButton']['text']['message.action.resubscribed'] = '".esc_html($onesignal_wp_settings['notifyButton_message_action_resubscribed'])."';\n";
208
  }
209
+ if (self::valid_for_key('notifyButton_message_action_unsubscribed', $onesignal_wp_settings)) {
210
+ echo "oneSignal_options['notifyButton']['text']['message.action.unsubscribed'] = '".esc_html($onesignal_wp_settings['notifyButton_message_action_unsubscribed'])."';\n";
211
  }
212
+ if (self::valid_for_key('notifyButton_dialog_main_title', $onesignal_wp_settings)) {
213
+ echo "oneSignal_options['notifyButton']['text']['dialog.main.title'] = '".esc_html($onesignal_wp_settings['notifyButton_dialog_main_title'])."';\n";
214
  }
215
+ if (self::valid_for_key('notifyButton_dialog_main_button_subscribe', $onesignal_wp_settings)) {
216
+ echo "oneSignal_options['notifyButton']['text']['dialog.main.button.subscribe'] = '".esc_html($onesignal_wp_settings['notifyButton_dialog_main_button_subscribe'])."';\n";
217
  }
218
+ if (self::valid_for_key('notifyButton_dialog_main_button_unsubscribe', $onesignal_wp_settings)) {
219
+ echo "oneSignal_options['notifyButton']['text']['dialog.main.button.unsubscribe'] = '".esc_html($onesignal_wp_settings['notifyButton_dialog_main_button_unsubscribe'])."';\n";
220
  }
221
+ if (self::valid_for_key('notifyButton_dialog_blocked_title', $onesignal_wp_settings)) {
222
+ echo "oneSignal_options['notifyButton']['text']['dialog.blocked.title'] = '".esc_html($onesignal_wp_settings['notifyButton_dialog_blocked_title'])."';\n";
223
  }
224
+ if (self::valid_for_key('notifyButton_dialog_blocked_message', $onesignal_wp_settings)) {
225
+ echo "oneSignal_options['notifyButton']['text']['dialog.blocked.message'] = '".esc_html($onesignal_wp_settings['notifyButton_dialog_blocked_message'])."';\n";
226
  }
227
  }
228
 
229
+ if (array_key_exists('notifyButton_customize_colors_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_customize_colors_enable']) {
230
  echo "oneSignal_options['notifyButton']['colors'] = {};\n";
231
+ if (self::valid_for_key('notifyButton_color_background', $onesignal_wp_settings)) {
232
+ echo "oneSignal_options['notifyButton']['colors']['circle.background'] = '".esc_html($onesignal_wp_settings['notifyButton_color_background'])."';\n";
233
  }
234
+ if (self::valid_for_key('notifyButton_color_foreground', $onesignal_wp_settings)) {
235
+ echo "oneSignal_options['notifyButton']['colors']['circle.foreground'] = '".esc_html($onesignal_wp_settings['notifyButton_color_foreground'])."';\n";
236
  }
237
+ if (self::valid_for_key('notifyButton_color_badge_background', $onesignal_wp_settings)) {
238
+ echo "oneSignal_options['notifyButton']['colors']['badge.background'] = '".esc_html($onesignal_wp_settings['notifyButton_color_badge_background'])."';\n";
239
  }
240
+ if (self::valid_for_key('notifyButton_color_badge_foreground', $onesignal_wp_settings)) {
241
+ echo "oneSignal_options['notifyButton']['colors']['badge.foreground'] = '".esc_html($onesignal_wp_settings['notifyButton_color_badge_foreground'])."';\n";
242
  }
243
+ if (self::valid_for_key('notifyButton_color_badge_border', $onesignal_wp_settings)) {
244
+ echo "oneSignal_options['notifyButton']['colors']['badge.bordercolor'] = '".esc_html($onesignal_wp_settings['notifyButton_color_badge_border'])."';\n";
245
  }
246
+ if (self::valid_for_key('notifyButton_color_pulse', $onesignal_wp_settings)) {
247
+ echo "oneSignal_options['notifyButton']['colors']['pulse.color'] = '".esc_html($onesignal_wp_settings['notifyButton_color_pulse'])."';\n";
248
  }
249
+ if (self::valid_for_key('notifyButton_color_popup_button_background', $onesignal_wp_settings)) {
250
+ echo "oneSignal_options['notifyButton']['colors']['dialog.button.background'] = '".esc_html($onesignal_wp_settings['notifyButton_color_popup_button_background'])."';\n";
251
  }
252
+ if (self::valid_for_key('notifyButton_color_popup_button_background_hover', $onesignal_wp_settings)) {
253
+ echo "oneSignal_options['notifyButton']['colors']['dialog.button.background.hovering'] = '".esc_html($onesignal_wp_settings['notifyButton_color_popup_button_background_hover'])."';\n";
254
  }
255
+ if (self::valid_for_key('notifyButton_color_popup_button_background_active', $onesignal_wp_settings)) {
256
+ echo "oneSignal_options['notifyButton']['colors']['dialog.button.background.active'] = '".esc_html($onesignal_wp_settings['notifyButton_color_popup_button_background_active'])."';\n";
257
  }
258
+ if (self::valid_for_key('notifyButton_color_popup_button_color', $onesignal_wp_settings)) {
259
+ echo "oneSignal_options['notifyButton']['colors']['dialog.button.foreground'] = '".esc_html($onesignal_wp_settings['notifyButton_color_popup_button_color'])."';\n";
260
  }
261
  }
262
 
263
+ if (array_key_exists('notifyButton_customize_offset_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_customize_offset_enable'] === true) {
264
  echo "oneSignal_options['notifyButton']['offset'] = {};\n";
265
+ if (self::valid_for_key('notifyButton_offset_bottom', $onesignal_wp_settings)) {
266
+ echo "oneSignal_options['notifyButton']['offset']['bottom'] = '".esc_html($onesignal_wp_settings['notifyButton_offset_bottom'])."';\n";
267
  }
268
+ if (self::valid_for_key('notifyButton_offset_left', $onesignal_wp_settings)) {
269
+ echo "oneSignal_options['notifyButton']['offset']['left'] = '".esc_html($onesignal_wp_settings['notifyButton_offset_left'])."';\n";
270
  }
271
+ if (self::valid_for_key('notifyButton_offset_right', $onesignal_wp_settings)) {
272
+ echo "oneSignal_options['notifyButton']['offset']['right'] = '".esc_html($onesignal_wp_settings['notifyButton_offset_right'])."';\n";
273
  }
274
  }
275
  }
289
  <?php
290
  }
291
  } else {
292
+ if (array_key_exists('use_slidedown_permission_message_for_https', $onesignal_wp_settings) &&
293
+ $onesignal_wp_settings['use_slidedown_permission_message_for_https'] === true) {
294
  ?>
295
  oneSignal_options['autoRegister'] = false;
296
  OneSignal.showHttpPrompt();
313
  var oneSignal_elements = document.getElementsByClassName("OneSignal-prompt");
314
 
315
  <?php
316
+ if (array_key_exists('use_modal_prompt', $onesignal_wp_settings) && $onesignal_wp_settings['use_modal_prompt'] === true) {
317
  echo "var oneSignalLinkClickHandler = function(event) { OneSignal.push(['registerForPushNotifications', {modalPrompt: true}]); event.preventDefault(); };";
318
  } else {
319
  echo "var oneSignalLinkClickHandler = function(event) { OneSignal.push(['registerForPushNotifications']); event.preventDefault(); };";
331
  });
332
  }
333
  </script>
 
334
  <?php
335
  }
336
  }
onesignal-settings.php CHANGED
@@ -48,7 +48,6 @@ class OneSignal {
48
  'notifyButton_size' => 'medium',
49
  'notifyButton_theme' => 'default',
50
  'notifyButton_enable' => 'CALCULATE_SPECIAL_VALUE',
51
- 'notifyButton_prenotify' => true,
52
  'notifyButton_customize_enable' => 'CALCULATE_SPECIAL_VALUE',
53
  'notifyButton_customize_colors_enable' => false,
54
  'notifyButton_customize_offset_enable' => false,
@@ -67,7 +66,6 @@ class OneSignal {
67
  'notifyButton_offset_right' => '',
68
  'notifyButton_showcredit' => true,
69
  'notifyButton_showAfterSubscribed' => true,
70
- 'notifyButton_message_prenotify' => '',
71
  'notifyButton_tip_state_unsubscribed' => '',
72
  'notifyButton_tip_state_subscribed' => '',
73
  'notifyButton_tip_state_blocked' => '',
@@ -108,12 +106,10 @@ class OneSignal {
108
  $is_new_user = false;
109
 
110
  // If not set or empty, load a fresh empty array
111
- if (!isset($onesignal_wp_settings)) {
112
- $onesignal_wp_settings = get_option("OneSignalWPSetting");
113
- if (empty( $onesignal_wp_settings )) {
114
- $is_new_user = true;
115
- $onesignal_wp_settings = array();
116
- }
117
  }
118
 
119
  // Assign defaults if the key doesn't exist in $onesignal_wp_settings
@@ -181,7 +177,6 @@ class OneSignal {
181
  $onesignal_wp_settings['notifyButton_customize_enable'] = true;
182
  } else {
183
  $text_customize_settings = array(
184
- 'notifyButton_message_prenotify',
185
  'notifyButton_tip_state_unsubscribed',
186
  'notifyButton_tip_state_subscribed',
187
  'notifyButton_tip_state_blocked',
@@ -250,7 +245,7 @@ class OneSignal {
250
  } else {
251
  // This was the old key name for persist_notifications
252
  if (array_key_exists('chrome_auto_dismiss_notifications', $onesignal_wp_settings)) {
253
- if ($onesignal_wp_settings['chrome_auto_dismiss_notifications'] == "1") {
254
  // The user wants notifications to be dismissed
255
  $onesignal_wp_settings['persist_notifications'] = 'platform-default';
256
  } else {
@@ -270,5 +265,4 @@ class OneSignal {
270
  $onesignal_wp_settings = $settings;
271
  update_option("OneSignalWPSetting", $onesignal_wp_settings);
272
  }
273
- }
274
- ?>
48
  'notifyButton_size' => 'medium',
49
  'notifyButton_theme' => 'default',
50
  'notifyButton_enable' => 'CALCULATE_SPECIAL_VALUE',
 
51
  'notifyButton_customize_enable' => 'CALCULATE_SPECIAL_VALUE',
52
  'notifyButton_customize_colors_enable' => false,
53
  'notifyButton_customize_offset_enable' => false,
66
  'notifyButton_offset_right' => '',
67
  'notifyButton_showcredit' => true,
68
  'notifyButton_showAfterSubscribed' => true,
 
69
  'notifyButton_tip_state_unsubscribed' => '',
70
  'notifyButton_tip_state_subscribed' => '',
71
  'notifyButton_tip_state_blocked' => '',
106
  $is_new_user = false;
107
 
108
  // If not set or empty, load a fresh empty array
109
+ $onesignal_wp_settings = get_option("OneSignalWPSetting");
110
+ if (empty( $onesignal_wp_settings )) {
111
+ $is_new_user = true;
112
+ $onesignal_wp_settings = array();
 
 
113
  }
114
 
115
  // Assign defaults if the key doesn't exist in $onesignal_wp_settings
177
  $onesignal_wp_settings['notifyButton_customize_enable'] = true;
178
  } else {
179
  $text_customize_settings = array(
 
180
  'notifyButton_tip_state_unsubscribed',
181
  'notifyButton_tip_state_subscribed',
182
  'notifyButton_tip_state_blocked',
245
  } else {
246
  // This was the old key name for persist_notifications
247
  if (array_key_exists('chrome_auto_dismiss_notifications', $onesignal_wp_settings)) {
248
+ if ($onesignal_wp_settings['chrome_auto_dismiss_notifications'] === "1") {
249
  // The user wants notifications to be dismissed
250
  $onesignal_wp_settings['persist_notifications'] = 'platform-default';
251
  } else {
265
  $onesignal_wp_settings = $settings;
266
  update_option("OneSignalWPSetting", $onesignal_wp_settings);
267
  }
268
+ }
 
onesignal-utils.php CHANGED
@@ -14,16 +14,9 @@ class OneSignalUtils {
14
  return html_entity_decode(str_replace("&apos;", "'", $string), $HTML_ENTITY_DECODE_FLAGS, 'UTF-8');
15
  }
16
 
17
- public static function normalize($string) {
18
- $string = OneSignalUtils::decode_entities($string);
19
- $string = stripslashes($string);
20
- $string = trim($string);
21
- return $string;
22
- }
23
-
24
  public static function url_contains_parameter($text) {
25
  if (array_key_exists('REQUEST_URI', $_SERVER)) {
26
- return strpos($_SERVER['REQUEST_URI'], $text);
27
  }
28
  }
29
 
@@ -65,5 +58,4 @@ class OneSignalUtils {
65
  // https://codex.wordpress.org/Roles_and_Capabilities#delete_users
66
  return current_user_can('delete_users');
67
  }
68
- }
69
- ?>
14
  return html_entity_decode(str_replace("&apos;", "'", $string), $HTML_ENTITY_DECODE_FLAGS, 'UTF-8');
15
  }
16
 
 
 
 
 
 
 
 
17
  public static function url_contains_parameter($text) {
18
  if (array_key_exists('REQUEST_URI', $_SERVER)) {
19
+ return strpos(sanitize_text_field($_SERVER['REQUEST_URI']), $text);
20
  }
21
  }
22
 
58
  // https://codex.wordpress.org/Roles_and_Capabilities#delete_users
59
  return current_user_can('delete_users');
60
  }
61
+ }
 
onesignal-widget.php CHANGED
@@ -8,38 +8,38 @@ class OneSignalWidget extends WP_Widget {
8
  parent::__construct('OneSignalWidget', 'OneSignal', array( 'description' => 'Subscribe to notifications'));
9
  }
10
 
11
- // Admin editor
12
  function form($instance) {
13
  $title = ! empty( $instance['title'] ) ? $instance['title'] : 'Follow';
14
  $text = ! empty( $instance['text'] ) ? $instance['text'] : 'Subscribe to notifications';
15
  ?>
16
  <p>
17
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
18
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
19
- <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Body:' ); ?></label>
20
- <input class="widefat" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" type="text" value="<?php echo esc_attr( $text ); ?>">
21
  </p>
22
  <?php
23
  }
24
 
25
  function update($new_instance, $old_instance) {
26
  $instance = array();
27
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
28
- $instance['text'] = ( ! empty( $new_instance['text'] ) ) ? strip_tags( $new_instance['text'] ) : '';
29
 
30
  return $instance;
31
  }
32
 
33
  // Public display
34
  function widget($args, $instance) {
35
- echo $args['before_widget'];
36
  if ( ! empty( $instance['title'] ) ) {
37
- echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
38
  }
39
- if ( ! empty( $instance['text'] ) ) {
40
- echo '<a href="#" class="OneSignal-prompt">' . $instance['text'] . '</a>';
41
  }
42
- echo $args['after_widget'];
43
  }
44
  }
45
 
8
  parent::__construct('OneSignalWidget', 'OneSignal', array( 'description' => 'Subscribe to notifications'));
9
  }
10
 
11
+ // Admin editor
12
  function form($instance) {
13
  $title = ! empty( $instance['title'] ) ? $instance['title'] : 'Follow';
14
  $text = ! empty( $instance['text'] ) ? $instance['text'] : 'Subscribe to notifications';
15
  ?>
16
  <p>
17
+ <label for="<?php echo esc_attr($this->get_field_id( 'title' )); ?>"><?php esc_attr_e( 'Title:' ); ?></label>
18
+ <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
19
+ <label for="<?php echo esc_attr($this->get_field_id( 'text' )); ?>"><?php esc_attr_e( 'Body:' ); ?></label>
20
+ <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'text' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'text' )); ?>" type="text" value="<?php echo esc_attr( $text ); ?>">
21
  </p>
22
  <?php
23
  }
24
 
25
  function update($new_instance, $old_instance) {
26
  $instance = array();
27
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
28
+ $instance['text'] = ( ! empty( $new_instance['text'] ) ) ? wp_strip_all_tags( $new_instance['text'] ) : '';
29
 
30
  return $instance;
31
  }
32
 
33
  // Public display
34
  function widget($args, $instance) {
35
+ echo wp_kses_post($args['before_widget']);
36
  if ( ! empty( $instance['title'] ) ) {
37
+ echo wp_kses_post($args['before_title']) . wp_kses_post(apply_filters( 'widget_title', $instance['title'])). wp_kses_post($args['after_title']);
38
  }
39
+ if ( ! empty( $instance['text'] ) ) {
40
+ echo '<a href="#" class="OneSignal-prompt">' . wp_kses_post($instance['text']) . '</a>';
41
  }
42
+ echo wp_kses_post($args['after_widget']);
43
  }
44
  }
45
 
onesignal.php CHANGED
@@ -6,7 +6,7 @@ defined('ABSPATH') or die('This page may not be accessed directly.');
6
  * Plugin Name: OneSignal Push Notifications
7
  * Plugin URI: https://onesignal.com/
8
  * Description: Free web push notifications.
9
- * Version: 1.17.9
10
  * Author: OneSignal
11
  * Author URI: https://onesignal.com
12
  * License: MIT
6
  * Plugin Name: OneSignal Push Notifications
7
  * Plugin URI: https://onesignal.com/
8
  * Description: Free web push notifications.
9
+ * Version: 2.0.0
10
  * Author: OneSignal
11
  * Author URI: https://onesignal.com
12
  * License: MIT
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: OneSignal
3
  Donate link: https://onesignal.com
4
  Tags: chrome, firefox, safari, push, push notifications, push notification, chrome push, safari push, firefox push, notification, notifications, web push, notify, mavericks, android, android push, android notifications, android notification, mobile notification, mobile notifications, mobile, desktop notification, roost, goroost, desktop notifications, gcm, push messages, onesignal
5
  Requires at least: 3.8
6
- Tested up to: 5.2.1
7
- Stable tag: 1.17.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -21,7 +21,7 @@ You can configure notification delivery at preset intervals, create user segment
21
  OneSignal’s free plan allows targeting up to 30,000 subscribers with push notifications. Contact support@onesignal.com if you have any questions. We’d love to hear from you!
22
 
23
  = Company =
24
- OneSignal is trusted by over 708,000 developers and marketing strategists. We power push notifications for everyone from early stage startups to Fortune 500 Companies, sending 4 billion notifications per day. It is the most popular push notification plugin on Wordpress with 90,000+ installations.
25
 
26
  = Features =
27
  * **Supports Chrome** (Desktop & Android), **Safari** (Mac OS X), **Microsoft Edge** (Desktop & Android), **Opera** (Desktop & Android) and **Firefox** (Desktop & Android) on both HTTP and HTTPS sites.
@@ -65,6 +65,10 @@ HTTPS Setup Video: [youtube https://www.youtube.com/watch?v=BeTZ2KgytC0]
65
 
66
  == Changelog ==
67
 
 
 
 
 
68
  = 1.17.9 =
69
 
70
  - Rolled back sending notifications on scheduled posts to be when its status changes to published
3
  Donate link: https://onesignal.com
4
  Tags: chrome, firefox, safari, push, push notifications, push notification, chrome push, safari push, firefox push, notification, notifications, web push, notify, mavericks, android, android push, android notifications, android notification, mobile notification, mobile notifications, mobile, desktop notification, roost, goroost, desktop notifications, gcm, push messages, onesignal
5
  Requires at least: 3.8
6
+ Tested up to: 5.2.2
7
+ Stable tag: 2.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
21
  OneSignal’s free plan allows targeting up to 30,000 subscribers with push notifications. Contact support@onesignal.com if you have any questions. We’d love to hear from you!
22
 
23
  = Company =
24
+ OneSignal is trusted by over 845,000 developers and marketing strategists. We power push notifications for everyone from early stage startups to Fortune 500 Companies, sending 4 billion notifications per day. It is the most popular push notification plugin on Wordpress with 90,000+ installations.
25
 
26
  = Features =
27
  * **Supports Chrome** (Desktop & Android), **Safari** (Mac OS X), **Microsoft Edge** (Desktop & Android), **Opera** (Desktop & Android) and **Firefox** (Desktop & Android) on both HTTP and HTTPS sites.
65
 
66
  == Changelog ==
67
 
68
+ = 2.0.0 =
69
+
70
+ - Wordpress VIP support, general refactoring, bug fixes
71
+
72
  = 1.17.9 =
73
 
74
  - Rolled back sending notifications on scheduled posts to be when its status changes to published
sdk_files/OneSignalSDKUpdaterWorker.js.php CHANGED
@@ -11,5 +11,4 @@
11
  echo "importScripts('https://localhost:3001/dev_sdks/OneSignalSDK.js');";
12
  } else {
13
  echo "importScripts('https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js');";
14
- }
15
- ?>
11
  echo "importScripts('https://localhost:3001/dev_sdks/OneSignalSDK.js');";
12
  } else {
13
  echo "importScripts('https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js');";
14
+ }
 
sdk_files/OneSignalSDKWorker.js.php CHANGED
@@ -11,5 +11,4 @@
11
  echo "importScripts('https://localhost:3001/dev_sdks/OneSignalSDK.js');";
12
  } else {
13
  echo "importScripts('https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js');";
14
- }
15
- ?>
11
  echo "importScripts('https://localhost:3001/dev_sdks/OneSignalSDK.js');";
12
  } else {
13
  echo "importScripts('https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js');";
14
+ }
 
views/config.php CHANGED
@@ -88,10 +88,10 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
88
  <h4>HTTP Sites:</h4>
89
  <div class="relative ui two column middle aligned very relaxed stackable grid" style="margin-bottom: 0 !important; padding-bottom: 0 !important;">
90
  <div class="center aligned column">
91
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/http-prompt.png" ?>" width="100%">
92
  </div>
93
  <div class="center aligned column">
94
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/bell.jpg" ?>" width="60%">
95
  </div>
96
  </div>
97
  <div class="relative ui two column middle aligned very relaxed stackable grid" style="margin-top: 0 !important; padding-top: 0 !important;">
@@ -105,10 +105,10 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
105
  <h4>HTTPS Sites:</h4>
106
  <div class="relative ui two column middle aligned very relaxed stackable grid" style="margin-bottom: 0 !important; padding-bottom: 0 !important;">
107
  <div class="center aligned column">
108
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/https-prompt.png" ?>" width="100%">
109
  </div>
110
  <div class="center aligned column">
111
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/bell.jpg" ?>" width="60%">
112
  </div>
113
  </div>
114
  <div class="relative ui two column middle aligned very relaxed stackable grid" style="margin-top: 0 !important; padding-top: 0 !important;">
@@ -153,7 +153,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
153
  <dd>
154
  <p>Log in to your OneSignal account, and navigate to the <em>App Settings</em> page of the app you configured in this guide.</p>
155
  <p>You should be on this page:</p>
156
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/safari-1.jpg" ?>">
157
  <p>Click <strong>Configure</strong> on the platform <em>Apple Safari</em>.</p>
158
  </dd>
159
  </div>
@@ -161,10 +161,10 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
161
  <dt>2</dt>
162
  <dd>
163
  <p>In this step, we'll focus on filling out the <em>Site Name</em> and <em>Site URL</em> fields.</p>
164
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/safari-2.jpg" ?>">
165
  <p>For the <strong>Site Name</strong>, enter a name you'd like your users to see.</p>
166
  <p>In the following sample image, <em>OneSignal</em> is the site name:</p>
167
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/safari-prompt.jpg" ?>" width="450">
168
  <p>For the <strong>Site URL</strong>, enter the URL to your site's domain. The purpose of this field is to prevent other sites from hijacking your keys to impersonate you and send push notifications on your behalf. Please note:</p>
169
  <ul>
170
  <li>
@@ -189,7 +189,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
189
  <dt>3</dt>
190
  <dd>
191
  <p>In this step, we'll focus on uploading your Safari notification icons.</p>
192
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/safari-3.jpg" ?>">
193
  <p>Please have your icon in the following sizes:</p>
194
  <ul>
195
  <li>16 &times; 16</li>
@@ -212,7 +212,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
212
  <dt>5</dt>
213
  <dd>
214
  <p><strong>Refresh</strong> the page, and then copy the <strong>Safari Web ID</strong> you see to the <em>Configuration</em> tab.</p>
215
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/safari-4.jpg" ?>">
216
  <p>That's it for setting up Safari push!</p>
217
  </dd>
218
  </div>
@@ -225,21 +225,21 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
225
  </div>
226
  <div class="ui tab borderless shadowless segment" style="z-index: 1;" data-tab="setup/3">
227
  <p>This section shows push notifications working for <em>Chrome</em>, <em>Safari</em>, and <em>Firefox</em> in <em>HTTP</em> and <em>HTTPS</em> mode.</p>
228
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/web-push.jpg" ?>">
229
  <p></p>
230
  <dl>
231
  <div class="ui horizontal divider">Subscription Bell</div>
232
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/notify-button.jpg" ?>">
233
  <div class="ui horizontal divider">Chrome (HTTP)</div>
234
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/chrome-http.jpg" ?>">
235
  <div class="ui horizontal divider">Chrome (HTTPS)</div>
236
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/chrome-https.jpg" ?>">
237
  <div class="ui horizontal divider">Safari (HTTP & HTTPS)</div>
238
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/safari-https.jpg" ?>">
239
  <div class="ui horizontal divider">Firefox (HTTP)</div>
240
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/firefox-http.jpg" ?>">
241
  <div class="ui horizontal divider">Firefox (HTTPS)</div>
242
- <img class="img-responsive" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/firefox-https.jpg" ?>">
243
  </dl>
244
  </div>
245
  </div>
@@ -260,8 +260,8 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
260
  <div class="ui borderless shadowless segment">
261
  <div class="field">
262
  <div class="ui toggle checkbox">
263
- <input type="checkbox" name="is_site_https" <?php if (@$onesignal_wp_settings['is_site_https_firsttime'] === 'unset') { echo "data-unset=\"true\""; } if (@$onesignal_wp_settings['is_site_https']) { echo "checked"; } ?>>
264
- <label>My site uses an HTTPS connection (SSL)<i class="tiny circular help icon link" role="popup" data-html="<p>Check this if your site uses HTTPS:</p><img src='<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/https-url.png" ?>' width=619>" data-variation="flowing"></i></label>
265
  </div>
266
  </div>
267
  <div class="ui inline subdomain-http nag">
@@ -298,7 +298,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
298
  </div>
299
  <div class="field">
300
  <label>Safari Web ID<i class="tiny circular help icon link" role="popup" data-title="Safari Web ID" data-content="Your Safari Web ID. You can find this on Setup > Safari Push > Step 5." data-variation="wide"></i></label>
301
- <input type="text" name="safari_web_id" placeholder="web.com.example" value="<?php echo esc_attr(@$onesignal_wp_settings['safari_web_id']); ?>">
302
  </div>
303
  </div>
304
  <div class="ui dividing header">
@@ -347,7 +347,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
347
  value="platform-default"
348
  <?php
349
  if ((array_key_exists('persist_notifications', $onesignal_wp_settings) &&
350
- $onesignal_wp_settings['persist_notifications'] == "platform-default")) {
351
  echo "selected";
352
  }
353
  ?>>Yes
@@ -356,7 +356,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
356
  value="yes-except-notification-manager-platforms"
357
  <?php
358
  if ((array_key_exists('persist_notifications', $onesignal_wp_settings) &&
359
- $onesignal_wp_settings['persist_notifications'] == "yes-except-notification-manager-platforms")) {
360
  echo "selected";
361
  }
362
  ?>>Yes on Mac OS X. No on other platforms.
@@ -365,7 +365,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
365
  value="yes-all"
366
  <?php
367
  if ((array_key_exists('persist_notifications', $onesignal_wp_settings) &&
368
- $onesignal_wp_settings['persist_notifications'] == "yes-all")) {
369
  echo "selected";
370
  }
371
  ?>>No
@@ -374,7 +374,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
374
  </div>
375
  <div class="field">
376
  <label>Notification Title<i class="tiny circular help icon link" role="popup" data-html="The notification title to use for all outgoing notifications. Defaults to your site's title." data-variation="wide"></i></label>
377
- <input type="text" name="notification_title" placeholder="<?php echo OneSignalUtils::decode_entities(get_bloginfo('name')); ?>" value="<?php echo esc_attr(@$onesignal_wp_settings['notification_title']); ?>">
378
  </div>
379
  <div class="field">
380
  <div class="ui toggle checkbox">
@@ -390,7 +390,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
390
  </div>
391
  </div>
392
  <div class="ui borderless shadowless segment">
393
- <img class="img-responsive no-center" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/nb-unsubscribe.png" ?>" width="234">
394
  <div class="explanation">
395
  <p>Control the way visitors are prompted to subscribe. The Subscription Bell is an interactive widget your site visitors can use to manage their push notification subscription status. The Subscription Bell can be used to initially subscribe to push notifications, and to unsubscribe.</p>
396
  </div>
@@ -413,12 +413,12 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
413
  <p>If enabled, your site will automatically present the following without any code required:</p>
414
  <p>HTTPS Sites:
415
  <img
416
- src='<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/chrome-https.jpg" ?>'
417
  width=400>
418
  </p>
419
  <p>HTTP Sites:
420
  <img
421
- src='<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/http-prompt.png" ?>'
422
  width=400>
423
  </p>"
424
  width=450
@@ -442,60 +442,54 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
442
  </div>
443
  <div class="field nb-feature">
444
  <div class="ui toggle checkbox">
445
- <input type="checkbox" name="notifyButton_showAfterSubscribed" value="true" <?php if (array_key_exists('notifyButton_showAfterSubscribed', $onesignal_wp_settings) && @$onesignal_wp_settings['notifyButton_showAfterSubscribed']) { echo "checked"; } ?>>
446
  <label>Show the Subscription Bell after users have subscribed<i class="tiny circular help icon link" role="popup" data-html="<p>If checked, the Subscription Bell will continue to be shown on all pages after the user subscribes.</p><p>If unchecked, the Subscription Bell will be hidden not be shown after the user subscribes and refreshes the page.</p>" data-variation="wide"></i></label>
447
  </div>
448
  </div>
449
  <div class="field nb-feature">
450
  <div class="ui toggle checkbox">
451
- <input type="checkbox" name="notifyButton_prenotify" value="true" <?php if (array_key_exists('notifyButton_prenotify', $onesignal_wp_settings) && @$onesignal_wp_settings['notifyButton_prenotify']) { echo "checked"; } ?>>
452
- <label>Show first-time site visitors an unread message icon<i class="tiny circular help icon link" role="popup" data-html="<p>If checked, a circle indicating 1 unread message will be shown:</p><img src='<?php echo ONESIGNAL_PLUGIN_URL."views/images/bell-prenotify.jpg" ?>' width=56><p>A message will be displayed when they hover over the Subscription Bell. This message can be customized below.</p>" data-variation="wide"></i></label>
453
- </div>
454
- </div>
455
- <div class="field nb-feature">
456
- <div class="ui toggle checkbox">
457
- <input type="checkbox" name="notifyButton_showcredit" value="true" <?php if (array_key_exists('notifyButton_showcredit', $onesignal_wp_settings) && @$onesignal_wp_settings['notifyButton_showcredit']) { echo "checked"; } ?>>
458
  <label>Show the OneSignal logo on the Subscription Bell dialog</label>
459
  </div>
460
  </div>
461
  <div class="field nb-feature">
462
  <div class="ui toggle checkbox">
463
- <input type="checkbox" name="notifyButton_customize_enable" value="true" <?php if (array_key_exists('notifyButton_customize_enable', $onesignal_wp_settings) && @$onesignal_wp_settings['notifyButton_customize_enable']) { echo "checked"; } ?>>
464
  <label>Customize the Subscription Bell text</label>
465
  </div>
466
  </div>
467
  <div class="field nb-feature">
468
  <div class="ui toggle checkbox">
469
- <input type="checkbox" name="notifyButton_customize_offset_enable" value="true" <?php if (array_key_exists('notifyButton_customize_offset_enable', $onesignal_wp_settings) && @$onesignal_wp_settings['notifyButton_customize_offset_enable']) { echo "checked"; } ?>>
470
  <label>Customize the Subscription Bell offset position</label>
471
  </div>
472
  </div>
473
  <div class="field nb-feature">
474
  <div class="ui toggle checkbox">
475
- <input type="checkbox" name="notifyButton_customize_colors_enable" value="true" <?php if (array_key_exists('notifyButton_customize_colors_enable', $onesignal_wp_settings) && @$onesignal_wp_settings['notifyButton_customize_colors_enable']) { echo "checked"; } ?>>
476
  <label>Customize the Subscription Bell theme colors</label>
477
  </div>
478
  </div>
479
  <div class="inline-setting short field nb-feature">
480
  <label class="inline-setting">Size:</label>
481
  <select class="ui dropdown" name="notifyButton_size">
482
- <option value="small" <?php if (array_key_exists('notifyButton_size', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_size'] == "small") { echo "selected"; } ?>>Small</option>
483
- <option value="medium" <?php if ((array_key_exists('notifyButton_size', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_size'] == "medium") || !array_key_exists('notifyButton_theme', $onesignal_wp_settings)) { echo "selected"; } ?>>Medium</option>
484
- <option value="large" <?php if (array_key_exists('notifyButton_size', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_size'] == "large") { echo "selected"; } ?>>Large</option>
485
  </select>
486
  </div>
487
  <div class="inline-setting short field nb-feature">
488
  <label class="inline-setting">Position:</label>
489
  <select class="ui dropdown" name="notifyButton_position">
490
- <option value="bottom-left" <?php if (array_key_exists('notifyButton_position', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_position'] == "bottom-left") { echo "selected"; } ?>>Bottom Left</option>
491
- <option value="bottom-right" <?php if ((array_key_exists('notifyButton_position', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_position'] == "bottom-right") || !array_key_exists('notifyButton_position', $onesignal_wp_settings)) { echo "selected"; } ?>>Bottom Right</option>
492
  </select>
493
  </div>
494
  <div class="inline-setting short field nb-feature">
495
  <label class="inline-setting">Theme:</label>
496
  <select class="ui dropdown" name="notifyButton_theme">
497
- <option value="default" <?php if ((array_key_exists('notifyButton_theme', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_theme'] == "default") || !array_key_exists('notifyButton_theme', $onesignal_wp_settings)) { echo "selected"; } ?>>Red</option>
498
- <option value="inverse" <?php if (array_key_exists('notifyButton_theme', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_theme'] == "inverse") { echo "selected"; } ?>>White</option>
499
  </select>
500
  </div>
501
  <div class="ui segment nb-feature nb-position-feature">
@@ -507,15 +501,15 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
507
  <p class="small normal-weight lato">You can override the Subscription Bell's offset position in the X and Y direction using CSS-valid position values. For example, <code>20px</code> is the default value.</p>
508
  <div class="field nb-feature nb-position-feature">
509
  <label>Bottom offset<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Bottom Offset" data-content="The distance to offset the Subscription Bell from the bottom of the page. For example, <code>20px</code> is the default value." data-variation="wide"></i></label>
510
- <input type="text" name="notifyButton_offset_bottom" placeholder="20px" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_offset_bottom']); ?>">
511
  </div>
512
  <div class="field nb-feature nb-position-feature nb-position-bottom-left-feature">
513
  <label>Left offset<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Left Offset" data-content="The distance to offset the Subscription Bell from the left of the page. For example, <code>20px</code> is the default value." data-variation="wide"></i></label>
514
- <input type="text" name="notifyButton_offset_left" placeholder="20px" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_offset_left']); ?>">
515
  </div>
516
  <div class="field nb-feature nb-position-feature nb-position-bottom-right-feature">
517
  <label>Right offset<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Right Offset" data-content="The distance to offset the Subscription Bell from the right of the page. For example, <code>20px</code> is the default value." data-variation="wide"></i></label>
518
- <input type="text" name="notifyButton_offset_right" placeholder="20px" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_offset_right']); ?>">
519
  </div>
520
  </div>
521
 
@@ -528,43 +522,43 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
528
  <p class="small normal-weight lato">You can override the theme's colors by entering your own. Use any CSS-valid color. For example, <code>white</code>, <code>#FFFFFF</code>, <code>#FFF</code>, <code>rgb(255, 255, 255)</code>, <code>rgba(255, 255, 255, 1.0)</code>, and <code>transparent</code> are all valid values.</p>
529
  <div class="field nb-feature nb-color-feature">
530
  <label>Main button background color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Background Color" data-content="The background color of the main Subscription Bell." data-variation="wide"></i></label>
531
- <input type="text" name="notifyButton_color_background" placeholder="#e54b4d" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_background']); ?>">
532
  </div>
533
  <div class="field nb-feature nb-color-feature">
534
  <label>Main button foreground color (main bell icon and inner circle)<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Foreground Color" data-content="The color of the bell icon and inner circle on the main Subscription Bell." data-variation="wide"></i></label>
535
- <input type="text" name="notifyButton_color_foreground" placeholder="white" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_foreground']); ?>">
536
  </div>
537
  <div class="field nb-feature nb-color-feature">
538
  <label>Pre-notify badge background color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Badge Background Color" data-content="The background color of the small secondary circle on the main Subscription Bell. This badge is shown to first-time site visitors only." data-variation="wide"></i></label>
539
- <input type="text" name="notifyButton_color_badge_background" placeholder="black" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_badge_background']); ?>">
540
  </div>
541
  <div class="field nb-feature nb-color-feature">
542
  <label>Pre-notify badge foreground color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Badge Foreground Color" data-content="The text color on the small secondary circle on the main Subscription Bell. This badge is shown to first-time site visitors only." data-variation="wide"></i></label>
543
- <input type="text" name="notifyButton_color_badge_foreground" placeholder="white" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_badge_foreground']); ?>">
544
  </div>
545
  <div class="field nb-feature nb-color-feature">
546
  <label>Pre-notify badge border color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Badge Border Color" data-content="The border color of the small secondary circle on the main Subscription Bell. This badge is shown to first-time site visitors only." data-variation="wide"></i></label>
547
- <input type="text" name="notifyButton_color_badge_border" placeholder="white" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_badge_border']); ?>">
548
  </div>
549
  <div class="field nb-feature nb-color-feature">
550
  <label>Pulse animation color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Pulse Animation Color" data-content="The color of the quickly expanding circle that's used as an animation when a user clicks on the Subscription Bell." data-variation="wide"></i></label>
551
- <input type="text" name="notifyButton_color_pulse" placeholder="#e54b4d" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_pulse']); ?>">
552
  </div>
553
  <div class="field nb-feature nb-color-feature">
554
  <label>Popup action button background color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Popup - Action Button Background Color" data-content="The color of the action button (SUBSCRIBE/UNSUBSCRIBE) on the Subscription Bell popup." data-variation="wide"></i></label>
555
- <input type="text" name="notifyButton_color_popup_button_background" placeholder="#e54b4d" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_popup_button_background']); ?>">
556
  </div>
557
  <div class="field nb-feature nb-color-feature">
558
  <label>Popup action button background color (on hover)<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Popup - Action Button Background Color (on hover)" data-content="The color of the action button (SUBSCRIBE/UNSUBSCRIBE) on the Subscription Bell popup when you hover over the button." data-variation="wide"></i></label>
559
- <input type="text" name="notifyButton_color_popup_button_background_hover" placeholder="#CC3234" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_popup_button_background_hover']); ?>">
560
  </div>
561
  <div class="field nb-feature nb-color-feature">
562
  <label>Popup action button background color (on click)<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Popup - Action Button Background Color (on click)" data-content="The color of the action button (SUBSCRIBE/UNSUBSCRIBE) on the Subscription Bell popup when you hold down the mouse." data-variation="wide"></i></label>
563
- <input type="text" name="notifyButton_color_popup_button_background_active" placeholder="#B2181A" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_popup_button_background_active']); ?>">
564
  </div>
565
  <div class="field nb-feature nb-color-feature">
566
  <label>Popup action button text color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Popup - Action Button Text Color" data-content="The color of the quickly expanding circle that's used as an animation when a user clicks on the Subscription Bell." data-variation="wide"></i></label>
567
- <input type="text" name="notifyButton_color_popup_button_color" placeholder="white" value="<?php echo esc_attr(@$onesignal_wp_settings['notifyButton_color_popup_button_color']); ?>">
568
  </div>
569
  </div>
570
 
@@ -574,53 +568,49 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
574
  Subscription Bell Text Customization
575
  </h4>
576
  </div>
577
- <div class="field nb-feature nb-text-feature">
578
- <label>First-time visitor message (on Subscription Bell hover)</label>
579
- <input type="text" name="notifyButton_message_prenotify" placeholder="Click to subscribe to notifications" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_message_prenotify']); ?>">
580
- </div>
581
  <div class="field nb-feature nb-text-feature">
582
  <label>Tip when unsubscribed</label>
583
- <input type="text" name="notifyButton_tip_state_unsubscribed" placeholder="Subscribe to notifications" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_tip_state_unsubscribed']); ?>">
584
  </div>
585
  <div class="field nb-feature nb-text-feature">
586
  <label>Tip when subscribed</label>
587
- <input type="text" name="notifyButton_tip_state_subscribed" placeholder="You're subscribed to notifications" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_tip_state_subscribed']); ?>">
588
  </div>
589
  <div class="field nb-feature nb-text-feature">
590
  <label>Tip when blocked</label>
591
- <input type="text" name="notifyButton_tip_state_blocked" placeholder="You've blocked notifications" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_tip_state_blocked']); ?>">
592
  </div>
593
  <div class="field nb-feature nb-text-feature">
594
  <label>Message on subscribed</label>
595
- <input type="text" name="notifyButton_message_action_subscribed" placeholder="Thanks for subscribing!" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_message_action_subscribed']); ?>">
596
  </div>
597
  <div class="field nb-feature nb-text-feature">
598
  <label>Message on re-subscribed (after first unsubscribing)</label>
599
- <input type="text" name="notifyButton_message_action_resubscribed" placeholder="You're subscribed to notifications" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_message_action_resubscribed']); ?>">
600
  </div>
601
  <div class="field nb-feature nb-text-feature">
602
  <label>Message on unsubscribed</label>
603
- <input type="text" name="notifyButton_message_action_unsubscribed" placeholder="You won't receive notifications again" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_message_action_unsubscribed']); ?>">
604
  </div>
605
  <div class="field nb-feature nb-text-feature">
606
  <label>Main dialog title</label>
607
- <input type="text" name="notifyButton_dialog_main_title" placeholder="Manage Site Notifications" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_dialog_main_title']); ?>">
608
  </div>
609
  <div class="field nb-feature nb-text-feature">
610
  <label>Main dialog subscribe button</label>
611
- <input type="text" name="notifyButton_dialog_main_button_subscribe" placeholder="SUBSCRIBE" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_dialog_main_button_subscribe']); ?>">
612
  </div>
613
  <div class="field nb-feature nb-text-feature">
614
  <label>Main dialog unsubscribe button</label>
615
- <input type="text" name="notifyButton_dialog_main_button_unsubscribe" placeholder="UNSUBSCRIBE" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_dialog_main_button_unsubscribe']); ?>">
616
  </div>
617
  <div class="field nb-feature nb-text-feature">
618
  <label>Blocked dialog title</label>
619
- <input type="text" name="notifyButton_dialog_blocked_title" placeholder="Unblock Notifications" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_dialog_blocked_title']); ?>">
620
  </div>
621
  <div class="field nb-feature nb-text-feature">
622
  <label>Blocked dialog message</label>
623
- <input type="text" name="notifyButton_dialog_blocked_message" placeholder="Follow these instructions to allow notifications:" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['notifyButton_dialog_blocked_message']); ?>">
624
  </div>
625
  </div>
626
  </div>
@@ -631,54 +621,54 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
631
  HTTP Pop-Up Settings
632
  </div>
633
  </div>
634
- <img class="img-responsive no-center" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/http-prompt.jpg" ?>" width="360">
635
  <div class="ui borderless shadowless segment" style="position: relative;">
636
  <p class="lato">These settings modify the HTTP Pop-Up Prompt and button text for all users. Use this to localize the HTTP Pop-Up Prompt to your language. All fields here are limited in the length of text they can display.</p>
637
  <div class="field">
638
  <div class="ui toggle checkbox">
639
- <input type="checkbox" name="prompt_customize_enable" value="true" <?php if (array_key_exists('prompt_customize_enable', $onesignal_wp_settings) && @$onesignal_wp_settings['prompt_customize_enable']) { echo "checked"; } ?>>
640
  <label>Customize the HTTP Pop-Up Prompt text</label>
641
  </div>
642
  </div>
643
  <div class="field prompt-customize-feature">
644
  <label>Action Message</label>
645
- <input type="text" name="prompt_action_message" placeholder="wants to show notifications:" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_action_message']); ?>">
646
  </div>
647
  <div class="field prompt-customize-feature">
648
  <label>Auto Accept Title (Click Allow)</label>
649
- <input type="text" name="prompt_auto_accept_title" placeholder="Click Allow" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_auto_accept_title']); ?>">
650
  </div>
651
  <div class="field prompt-customize-feature">
652
  <label>Site Name</label>
653
- <input type="text" name="prompt_site_name" placeholder="http://yoursite.com" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_site_name']); ?>">
654
  </div>
655
  <div class="field prompt-customize-feature">
656
  <label>Example Notification Title (Desktop)</label>
657
- <input type="text" name="prompt_example_notification_title_desktop" placeholder="This is an example notification" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_example_notification_title_desktop']); ?>">
658
  </div>
659
  <div class="field prompt-customize-feature">
660
  <label>Example Notification Message (Desktop)</label>
661
- <input type="text" name="prompt_example_notification_message_desktop" placeholder="Notifications will appear on your desktop" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_example_notification_message_desktop']); ?>">
662
  </div>
663
  <div class="field prompt-customize-feature">
664
  <label>Example Notification Title (Mobile)</label>
665
- <input type="text" name="prompt_example_notification_title_mobile" placeholder="Example notification" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_example_notification_title_mobile']); ?>">
666
  </div>
667
  <div class="field prompt-customize-feature">
668
  <label>Example Notification Message (Mobile)</label>
669
- <input type="text" name="prompt_example_notification_message_mobile" placeholder="Notifications will appear on your device" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_example_notification_message_mobile']); ?>">
670
  </div>
671
  <div class="field prompt-customize-feature">
672
  <label>Example Notification Caption</label>
673
- <input type="text" name="prompt_example_notification_caption" placeholder="(you can unsubscribe anytime)" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_example_notification_caption']); ?>">
674
  </div>
675
  <div class="field prompt-customize-feature">
676
  <label>Accept Button Text</label>
677
- <input type="text" name="prompt_accept_button_text" placeholder="CONTINUE" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_accept_button_text']); ?>">
678
  </div>
679
  <div class="field prompt-customize-feature">
680
  <label>Cancel Button Text</label>
681
- <input type="text" name="prompt_cancel_button_text" placeholder="NO THANKS" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['prompt_cancel_button_text']); ?>">
682
  </div>
683
  </div>
684
  </div>
@@ -689,7 +679,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
689
  </div>
690
  </div>
691
  <div class="ui borderless shadowless segment" style="position: relative;">
692
- <img class="img-responsive no-center" src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/welcome-notification.jpg" ?>" width="360">
693
  <div class="explanation">
694
  <p>A welcome notification is sent to new visitors after subscribing. A new visitor is someone who hasn't previously registered. If a user's browser cache is cleared, the user is considered new again.</p>
695
  </div>
@@ -701,15 +691,15 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
701
  </div>
702
  <div class="field welcome-notification-feature">
703
  <label>Title<i class="tiny circular help icon link" role="popup" data-title="Welcome Notification Title" data-content="The welcome notification's title. You can localize this to your own language. If not set, the site's title will be used. Set to one space ' ' to clear the title, although this is not recommended." data-variation="wide"></i></label>
704
- <input type="text" placeholder="(defaults to your website's title if blank)" name="welcome_notification_title" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['welcome_notification_title']); ?>">
705
  </div>
706
  <div class="field welcome-notification-feature">
707
  <label>Message<i class="tiny circular help icon link" role="popup" data-title="Welcome Notification Message" data-content="The welcome notification's message. You can localize this to your own language. A message is required. If left blank, the default of 'Thanks for subscribing!' will be used." data-variation="wide"></i></label>
708
- <input type="text" placeholder="Thanks for subscribing!" name="welcome_notification_message" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['welcome_notification_message']); ?>">
709
  </div>
710
  <div class="field welcome-notification-feature">
711
  <label>URL<i class="tiny circular help icon link" role="popup" data-title="Welcome Notification URL" data-content="The webpage to open when clicking the notification. If left blank, your main site URL will be used as a default." data-variation="wide"></i></label>
712
- <input type="text" placeholder="(defaults to your website's URL if blank)" name="welcome_notification_url" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['welcome_notification_url']); ?>">
713
  </div>
714
  </div>
715
  <div class="ui dividing header">
@@ -727,7 +717,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
727
  </div>
728
  <div class="field">
729
  <div class="ui toggle checkbox">
730
- <input type="checkbox" name="notification_on_post_from_plugin" value="true" <?php if (@$onesignal_wp_settings['notification_on_post_from_plugin']) { echo "checked"; } ?>>
731
  <label>Automatically send a push notification when I publish a post from 3<sup>rd</sup> party plugins<i class="tiny circular help icon link" role="popup" data-title="Automatic Push outside WordPress Editor" data-content="If checked, when a post is created outside of WordPress's editor, a push notification will automatically be sent. Must be the built-in WordPress post type 'post' and the post must be published." data-variation="wide"></i></label>
732
  </div>
733
  </div>
@@ -741,7 +731,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
741
  <div class="ui borderless shadowless segment">
742
  <div class="field">
743
  <label>Additional Notification URL Parameters<i class="tiny circular help icon link" role="popup" data-html="Adds the specified string as extra URL parameters to your notification URL so that they can be tracked as an event by your analytics system. <em>Please escape your parameter values</em>; your input will be added as-is to the end of your notification URL. Example:</p>If you want:<em><li><code>utm_medium</code> to be <code>ppc</code></li><li><code>utm_source</code> to be <code>adwords</code></li><li><code>utm_campaign</code> to be <code>snow boots</code></li><li><code>utm_content</code> to be <code>durable snow boots</code></li></em><p><p>Then use the following string:</p><p><code style='word-break: break-all;'>utm_medium=ppc&utm_source=adwords&utm_campaign=snow%20boots&utm_content=durable%20%snow%boots</code></p>" data-variation="wide"></i></label>
744
- <input type="text" placeholder="utm_medium=ppc&utm_source=adwords&utm_campaign=snow%20boots&utm_content=durable%20%snow%boots" name="utm_additional_url_params" value="<?php echo OneSignalUtils::html_safe(@$onesignal_wp_settings['utm_additional_url_params']); ?>">
745
  </div>
746
  </div>
747
  <div class="ui dividing header">
@@ -753,7 +743,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
753
  <div class="ui borderless shadowless segment">
754
  <div class="field">
755
  <label>Additional Custom Post Types for Automatic Notifications Created From Plugins<i class="tiny circular help icon link" role="popup" data-html="Enter a comma-separated list of custom post type names. Anytime a post is published with one of the listed post types, a notification will be sent to all your users. <strong class='least-strong'>The setting</strong> <em>Automatically send a push notification when I publish a post from 3rd party plugins</em> <strong class='least-strong'>must be enabled for this feature to work</strong>." data-variation="wide"></i></label>
756
- <input type="text" placeholder="forum,reply,topic (comma separated, no spaces between commas)" name="allowed_custom_post_types" value="<?php echo esc_attr(@$onesignal_wp_settings['allowed_custom_post_types']); ?>">
757
  </div>
758
  <?php if (OneSignalUtils::url_contains_parameter(ONESIGNAL_URI_REVEAL_PROJECT_NUMBER)): ?>
759
  <div class="field">
@@ -765,7 +755,7 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
765
  <?php endif; ?>
766
  <div class="field custom-manifest-feature">
767
  <label>Custom manifest.json URL<i class="tiny circular help icon link" role="popup" data-html="<p>Enter the complete URL to your existing manifest.json file to be used in place of our own. Your URL's domain should match that of your main site that users are visiting.</p><p>e.g. <code>https://yoursite.com/manifest.json</code></p>" data-variation="wide"></i></label>
768
- <input type="text" placeholder="https://yoursite.com/manifest.json" name="custom_manifest_url" value="<?php echo esc_attr(@$onesignal_wp_settings['custom_manifest_url']); ?>">
769
  </div>
770
  <div class="field">
771
  <div class="ui toggle checkbox">
88
  <h4>HTTP Sites:</h4>
89
  <div class="relative ui two column middle aligned very relaxed stackable grid" style="margin-bottom: 0 !important; padding-bottom: 0 !important;">
90
  <div class="center aligned column">
91
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/http-prompt.png") ?>" width="100%">
92
  </div>
93
  <div class="center aligned column">
94
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/bell.jpg") ?>" width="60%">
95
  </div>
96
  </div>
97
  <div class="relative ui two column middle aligned very relaxed stackable grid" style="margin-top: 0 !important; padding-top: 0 !important;">
105
  <h4>HTTPS Sites:</h4>
106
  <div class="relative ui two column middle aligned very relaxed stackable grid" style="margin-bottom: 0 !important; padding-bottom: 0 !important;">
107
  <div class="center aligned column">
108
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/https-prompt.png") ?>" width="100%">
109
  </div>
110
  <div class="center aligned column">
111
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/bell.jpg") ?>" width="60%">
112
  </div>
113
  </div>
114
  <div class="relative ui two column middle aligned very relaxed stackable grid" style="margin-top: 0 !important; padding-top: 0 !important;">
153
  <dd>
154
  <p>Log in to your OneSignal account, and navigate to the <em>App Settings</em> page of the app you configured in this guide.</p>
155
  <p>You should be on this page:</p>
156
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/safari-1.jpg") ?>">
157
  <p>Click <strong>Configure</strong> on the platform <em>Apple Safari</em>.</p>
158
  </dd>
159
  </div>
161
  <dt>2</dt>
162
  <dd>
163
  <p>In this step, we'll focus on filling out the <em>Site Name</em> and <em>Site URL</em> fields.</p>
164
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/safari-2.jpg") ?>">
165
  <p>For the <strong>Site Name</strong>, enter a name you'd like your users to see.</p>
166
  <p>In the following sample image, <em>OneSignal</em> is the site name:</p>
167
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/safari-prompt.jpg") ?>" width="450">
168
  <p>For the <strong>Site URL</strong>, enter the URL to your site's domain. The purpose of this field is to prevent other sites from hijacking your keys to impersonate you and send push notifications on your behalf. Please note:</p>
169
  <ul>
170
  <li>
189
  <dt>3</dt>
190
  <dd>
191
  <p>In this step, we'll focus on uploading your Safari notification icons.</p>
192
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/safari-3.jpg") ?>">
193
  <p>Please have your icon in the following sizes:</p>
194
  <ul>
195
  <li>16 &times; 16</li>
212
  <dt>5</dt>
213
  <dd>
214
  <p><strong>Refresh</strong> the page, and then copy the <strong>Safari Web ID</strong> you see to the <em>Configuration</em> tab.</p>
215
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/safari-4.jpg") ?>">
216
  <p>That's it for setting up Safari push!</p>
217
  </dd>
218
  </div>
225
  </div>
226
  <div class="ui tab borderless shadowless segment" style="z-index: 1;" data-tab="setup/3">
227
  <p>This section shows push notifications working for <em>Chrome</em>, <em>Safari</em>, and <em>Firefox</em> in <em>HTTP</em> and <em>HTTPS</em> mode.</p>
228
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/web-push.jpg") ?>">
229
  <p></p>
230
  <dl>
231
  <div class="ui horizontal divider">Subscription Bell</div>
232
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/notify-button.jpg") ?>">
233
  <div class="ui horizontal divider">Chrome (HTTP)</div>
234
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/chrome-http.jpg") ?>">
235
  <div class="ui horizontal divider">Chrome (HTTPS)</div>
236
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/chrome-https.jpg") ?>">
237
  <div class="ui horizontal divider">Safari (HTTP & HTTPS)</div>
238
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/safari-https.jpg") ?>">
239
  <div class="ui horizontal divider">Firefox (HTTP)</div>
240
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/firefox-http.jpg") ?>">
241
  <div class="ui horizontal divider">Firefox (HTTPS)</div>
242
+ <img class="img-responsive" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/firefox-https.jpg") ?>">
243
  </dl>
244
  </div>
245
  </div>
260
  <div class="ui borderless shadowless segment">
261
  <div class="field">
262
  <div class="ui toggle checkbox">
263
+ <input type="checkbox" name="is_site_https" <?php if ($onesignal_wp_settings['is_site_https_firsttime'] === 'unset') { echo "data-unset=\"true\""; } if ($onesignal_wp_settings['is_site_https']) { echo "checked"; } ?>>
264
+ <label>My site uses an HTTPS connection (SSL)<i class="tiny circular help icon link" role="popup" data-html="<p>Check this if your site uses HTTPS:</p><img src='<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/https-url.png") ?>' width=619>" data-variation="flowing"></i></label>
265
  </div>
266
  </div>
267
  <div class="ui inline subdomain-http nag">
298
  </div>
299
  <div class="field">
300
  <label>Safari Web ID<i class="tiny circular help icon link" role="popup" data-title="Safari Web ID" data-content="Your Safari Web ID. You can find this on Setup > Safari Push > Step 5." data-variation="wide"></i></label>
301
+ <input type="text" name="safari_web_id" placeholder="web.com.example" value="<?php echo esc_attr($onesignal_wp_settings['safari_web_id']); ?>">
302
  </div>
303
  </div>
304
  <div class="ui dividing header">
347
  value="platform-default"
348
  <?php
349
  if ((array_key_exists('persist_notifications', $onesignal_wp_settings) &&
350
+ $onesignal_wp_settings['persist_notifications'] === "platform-default")) {
351
  echo "selected";
352
  }
353
  ?>>Yes
356
  value="yes-except-notification-manager-platforms"
357
  <?php
358
  if ((array_key_exists('persist_notifications', $onesignal_wp_settings) &&
359
+ $onesignal_wp_settings['persist_notifications'] === "yes-except-notification-manager-platforms")) {
360
  echo "selected";
361
  }
362
  ?>>Yes on Mac OS X. No on other platforms.
365
  value="yes-all"
366
  <?php
367
  if ((array_key_exists('persist_notifications', $onesignal_wp_settings) &&
368
+ $onesignal_wp_settings['persist_notifications'] === "yes-all")) {
369
  echo "selected";
370
  }
371
  ?>>No
374
  </div>
375
  <div class="field">
376
  <label>Notification Title<i class="tiny circular help icon link" role="popup" data-html="The notification title to use for all outgoing notifications. Defaults to your site's title." data-variation="wide"></i></label>
377
+ <input type="text" name="notification_title" placeholder="<?php echo esc_attr(OneSignalUtils::decode_entities(get_bloginfo('name'))); ?>" value="<?php echo esc_attr($onesignal_wp_settings['notification_title']); ?>">
378
  </div>
379
  <div class="field">
380
  <div class="ui toggle checkbox">
390
  </div>
391
  </div>
392
  <div class="ui borderless shadowless segment">
393
+ <img class="img-responsive no-center" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/nb-unsubscribe.png") ?>" width="234">
394
  <div class="explanation">
395
  <p>Control the way visitors are prompted to subscribe. The Subscription Bell is an interactive widget your site visitors can use to manage their push notification subscription status. The Subscription Bell can be used to initially subscribe to push notifications, and to unsubscribe.</p>
396
  </div>
413
  <p>If enabled, your site will automatically present the following without any code required:</p>
414
  <p>HTTPS Sites:
415
  <img
416
+ src='<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/chrome-https.jpg") ?>'
417
  width=400>
418
  </p>
419
  <p>HTTP Sites:
420
  <img
421
+ src='<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/http-prompt.png") ?>'
422
  width=400>
423
  </p>"
424
  width=450
442
  </div>
443
  <div class="field nb-feature">
444
  <div class="ui toggle checkbox">
445
+ <input type="checkbox" name="notifyButton_showAfterSubscribed" value="true" <?php if (array_key_exists('notifyButton_showAfterSubscribed', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_showAfterSubscribed']) { echo "checked"; } ?>>
446
  <label>Show the Subscription Bell after users have subscribed<i class="tiny circular help icon link" role="popup" data-html="<p>If checked, the Subscription Bell will continue to be shown on all pages after the user subscribes.</p><p>If unchecked, the Subscription Bell will be hidden not be shown after the user subscribes and refreshes the page.</p>" data-variation="wide"></i></label>
447
  </div>
448
  </div>
449
  <div class="field nb-feature">
450
  <div class="ui toggle checkbox">
451
+ <input type="checkbox" name="notifyButton_showcredit" value="true" <?php if (array_key_exists('notifyButton_showcredit', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_showcredit']) { echo "checked"; } ?>>
 
 
 
 
 
 
452
  <label>Show the OneSignal logo on the Subscription Bell dialog</label>
453
  </div>
454
  </div>
455
  <div class="field nb-feature">
456
  <div class="ui toggle checkbox">
457
+ <input type="checkbox" name="notifyButton_customize_enable" value="true" <?php if (array_key_exists('notifyButton_customize_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_customize_enable']) { echo "checked"; } ?>>
458
  <label>Customize the Subscription Bell text</label>
459
  </div>
460
  </div>
461
  <div class="field nb-feature">
462
  <div class="ui toggle checkbox">
463
+ <input type="checkbox" name="notifyButton_customize_offset_enable" value="true" <?php if (array_key_exists('notifyButton_customize_offset_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_customize_offset_enable']) { echo "checked"; } ?>>
464
  <label>Customize the Subscription Bell offset position</label>
465
  </div>
466
  </div>
467
  <div class="field nb-feature">
468
  <div class="ui toggle checkbox">
469
+ <input type="checkbox" name="notifyButton_customize_colors_enable" value="true" <?php if (array_key_exists('notifyButton_customize_colors_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_customize_colors_enable']) { echo "checked"; } ?>>
470
  <label>Customize the Subscription Bell theme colors</label>
471
  </div>
472
  </div>
473
  <div class="inline-setting short field nb-feature">
474
  <label class="inline-setting">Size:</label>
475
  <select class="ui dropdown" name="notifyButton_size">
476
+ <option value="small" <?php if (array_key_exists('notifyButton_size', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_size'] === "small") { echo "selected"; } ?>>Small</option>
477
+ <option value="medium" <?php if ((array_key_exists('notifyButton_size', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_size'] === "medium") || !array_key_exists('notifyButton_theme', $onesignal_wp_settings)) { echo "selected"; } ?>>Medium</option>
478
+ <option value="large" <?php if (array_key_exists('notifyButton_size', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_size'] === "large") { echo "selected"; } ?>>Large</option>
479
  </select>
480
  </div>
481
  <div class="inline-setting short field nb-feature">
482
  <label class="inline-setting">Position:</label>
483
  <select class="ui dropdown" name="notifyButton_position">
484
+ <option value="bottom-left" <?php if (array_key_exists('notifyButton_position', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_position'] === "bottom-left") { echo "selected"; } ?>>Bottom Left</option>
485
+ <option value="bottom-right" <?php if ((array_key_exists('notifyButton_position', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_position'] === "bottom-right") || !array_key_exists('notifyButton_position', $onesignal_wp_settings)) { echo "selected"; } ?>>Bottom Right</option>
486
  </select>
487
  </div>
488
  <div class="inline-setting short field nb-feature">
489
  <label class="inline-setting">Theme:</label>
490
  <select class="ui dropdown" name="notifyButton_theme">
491
+ <option value="default" <?php if ((array_key_exists('notifyButton_theme', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_theme'] === "default") || !array_key_exists('notifyButton_theme', $onesignal_wp_settings)) { echo "selected"; } ?>>Red</option>
492
+ <option value="inverse" <?php if (array_key_exists('notifyButton_theme', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_theme'] === "inverse") { echo "selected"; } ?>>White</option>
493
  </select>
494
  </div>
495
  <div class="ui segment nb-feature nb-position-feature">
501
  <p class="small normal-weight lato">You can override the Subscription Bell's offset position in the X and Y direction using CSS-valid position values. For example, <code>20px</code> is the default value.</p>
502
  <div class="field nb-feature nb-position-feature">
503
  <label>Bottom offset<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Bottom Offset" data-content="The distance to offset the Subscription Bell from the bottom of the page. For example, <code>20px</code> is the default value." data-variation="wide"></i></label>
504
+ <input type="text" name="notifyButton_offset_bottom" placeholder="20px" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_offset_bottom']); ?>">
505
  </div>
506
  <div class="field nb-feature nb-position-feature nb-position-bottom-left-feature">
507
  <label>Left offset<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Left Offset" data-content="The distance to offset the Subscription Bell from the left of the page. For example, <code>20px</code> is the default value." data-variation="wide"></i></label>
508
+ <input type="text" name="notifyButton_offset_left" placeholder="20px" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_offset_left']); ?>">
509
  </div>
510
  <div class="field nb-feature nb-position-feature nb-position-bottom-right-feature">
511
  <label>Right offset<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Right Offset" data-content="The distance to offset the Subscription Bell from the right of the page. For example, <code>20px</code> is the default value." data-variation="wide"></i></label>
512
+ <input type="text" name="notifyButton_offset_right" placeholder="20px" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_offset_right']); ?>">
513
  </div>
514
  </div>
515
 
522
  <p class="small normal-weight lato">You can override the theme's colors by entering your own. Use any CSS-valid color. For example, <code>white</code>, <code>#FFFFFF</code>, <code>#FFF</code>, <code>rgb(255, 255, 255)</code>, <code>rgba(255, 255, 255, 1.0)</code>, and <code>transparent</code> are all valid values.</p>
523
  <div class="field nb-feature nb-color-feature">
524
  <label>Main button background color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Background Color" data-content="The background color of the main Subscription Bell." data-variation="wide"></i></label>
525
+ <input type="text" name="notifyButton_color_background" placeholder="#e54b4d" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_background']); ?>">
526
  </div>
527
  <div class="field nb-feature nb-color-feature">
528
  <label>Main button foreground color (main bell icon and inner circle)<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Foreground Color" data-content="The color of the bell icon and inner circle on the main Subscription Bell." data-variation="wide"></i></label>
529
+ <input type="text" name="notifyButton_color_foreground" placeholder="white" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_foreground']); ?>">
530
  </div>
531
  <div class="field nb-feature nb-color-feature">
532
  <label>Pre-notify badge background color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Badge Background Color" data-content="The background color of the small secondary circle on the main Subscription Bell. This badge is shown to first-time site visitors only." data-variation="wide"></i></label>
533
+ <input type="text" name="notifyButton_color_badge_background" placeholder="black" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_badge_background']); ?>">
534
  </div>
535
  <div class="field nb-feature nb-color-feature">
536
  <label>Pre-notify badge foreground color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Badge Foreground Color" data-content="The text color on the small secondary circle on the main Subscription Bell. This badge is shown to first-time site visitors only." data-variation="wide"></i></label>
537
+ <input type="text" name="notifyButton_color_badge_foreground" placeholder="white" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_badge_foreground']); ?>">
538
  </div>
539
  <div class="field nb-feature nb-color-feature">
540
  <label>Pre-notify badge border color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Badge Border Color" data-content="The border color of the small secondary circle on the main Subscription Bell. This badge is shown to first-time site visitors only." data-variation="wide"></i></label>
541
+ <input type="text" name="notifyButton_color_badge_border" placeholder="white" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_badge_border']); ?>">
542
  </div>
543
  <div class="field nb-feature nb-color-feature">
544
  <label>Pulse animation color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Pulse Animation Color" data-content="The color of the quickly expanding circle that's used as an animation when a user clicks on the Subscription Bell." data-variation="wide"></i></label>
545
+ <input type="text" name="notifyButton_color_pulse" placeholder="#e54b4d" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_pulse']); ?>">
546
  </div>
547
  <div class="field nb-feature nb-color-feature">
548
  <label>Popup action button background color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Popup - Action Button Background Color" data-content="The color of the action button (SUBSCRIBE/UNSUBSCRIBE) on the Subscription Bell popup." data-variation="wide"></i></label>
549
+ <input type="text" name="notifyButton_color_popup_button_background" placeholder="#e54b4d" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_popup_button_background']); ?>">
550
  </div>
551
  <div class="field nb-feature nb-color-feature">
552
  <label>Popup action button background color (on hover)<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Popup - Action Button Background Color (on hover)" data-content="The color of the action button (SUBSCRIBE/UNSUBSCRIBE) on the Subscription Bell popup when you hover over the button." data-variation="wide"></i></label>
553
+ <input type="text" name="notifyButton_color_popup_button_background_hover" placeholder="#CC3234" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_popup_button_background_hover']); ?>">
554
  </div>
555
  <div class="field nb-feature nb-color-feature">
556
  <label>Popup action button background color (on click)<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Popup - Action Button Background Color (on click)" data-content="The color of the action button (SUBSCRIBE/UNSUBSCRIBE) on the Subscription Bell popup when you hold down the mouse." data-variation="wide"></i></label>
557
+ <input type="text" name="notifyButton_color_popup_button_background_active" placeholder="#B2181A" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_popup_button_background_active']); ?>">
558
  </div>
559
  <div class="field nb-feature nb-color-feature">
560
  <label>Popup action button text color<i class="tiny circular help icon link" role="popup" data-title="Subscription Bell Popup - Action Button Text Color" data-content="The color of the quickly expanding circle that's used as an animation when a user clicks on the Subscription Bell." data-variation="wide"></i></label>
561
+ <input type="text" name="notifyButton_color_popup_button_color" placeholder="white" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_color_popup_button_color']); ?>">
562
  </div>
563
  </div>
564
 
568
  Subscription Bell Text Customization
569
  </h4>
570
  </div>
 
 
 
 
571
  <div class="field nb-feature nb-text-feature">
572
  <label>Tip when unsubscribed</label>
573
+ <input type="text" name="notifyButton_tip_state_unsubscribed" placeholder="Subscribe to notifications" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_tip_state_unsubscribed']); ?>">
574
  </div>
575
  <div class="field nb-feature nb-text-feature">
576
  <label>Tip when subscribed</label>
577
+ <input type="text" name="notifyButton_tip_state_subscribed" placeholder="You're subscribed to notifications" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_tip_state_subscribed']); ?>">
578
  </div>
579
  <div class="field nb-feature nb-text-feature">
580
  <label>Tip when blocked</label>
581
+ <input type="text" name="notifyButton_tip_state_blocked" placeholder="You've blocked notifications" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_tip_state_blocked']); ?>">
582
  </div>
583
  <div class="field nb-feature nb-text-feature">
584
  <label>Message on subscribed</label>
585
+ <input type="text" name="notifyButton_message_action_subscribed" placeholder="Thanks for subscribing!" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_message_action_subscribed']); ?>">
586
  </div>
587
  <div class="field nb-feature nb-text-feature">
588
  <label>Message on re-subscribed (after first unsubscribing)</label>
589
+ <input type="text" name="notifyButton_message_action_resubscribed" placeholder="You're subscribed to notifications" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_message_action_resubscribed']); ?>">
590
  </div>
591
  <div class="field nb-feature nb-text-feature">
592
  <label>Message on unsubscribed</label>
593
+ <input type="text" name="notifyButton_message_action_unsubscribed" placeholder="You won't receive notifications again" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_message_action_unsubscribed']); ?>">
594
  </div>
595
  <div class="field nb-feature nb-text-feature">
596
  <label>Main dialog title</label>
597
+ <input type="text" name="notifyButton_dialog_main_title" placeholder="Manage Site Notifications" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_dialog_main_title']); ?>">
598
  </div>
599
  <div class="field nb-feature nb-text-feature">
600
  <label>Main dialog subscribe button</label>
601
+ <input type="text" name="notifyButton_dialog_main_button_subscribe" placeholder="SUBSCRIBE" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_dialog_main_button_subscribe']); ?>">
602
  </div>
603
  <div class="field nb-feature nb-text-feature">
604
  <label>Main dialog unsubscribe button</label>
605
+ <input type="text" name="notifyButton_dialog_main_button_unsubscribe" placeholder="UNSUBSCRIBE" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_dialog_main_button_unsubscribe']); ?>">
606
  </div>
607
  <div class="field nb-feature nb-text-feature">
608
  <label>Blocked dialog title</label>
609
+ <input type="text" name="notifyButton_dialog_blocked_title" placeholder="Unblock Notifications" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_dialog_blocked_title']); ?>">
610
  </div>
611
  <div class="field nb-feature nb-text-feature">
612
  <label>Blocked dialog message</label>
613
+ <input type="text" name="notifyButton_dialog_blocked_message" placeholder="Follow these instructions to allow notifications:" value="<?php echo esc_attr($onesignal_wp_settings['notifyButton_dialog_blocked_message']); ?>">
614
  </div>
615
  </div>
616
  </div>
621
  HTTP Pop-Up Settings
622
  </div>
623
  </div>
624
+ <img class="img-responsive no-center" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/http-prompt.jpg") ?>" width="360">
625
  <div class="ui borderless shadowless segment" style="position: relative;">
626
  <p class="lato">These settings modify the HTTP Pop-Up Prompt and button text for all users. Use this to localize the HTTP Pop-Up Prompt to your language. All fields here are limited in the length of text they can display.</p>
627
  <div class="field">
628
  <div class="ui toggle checkbox">
629
+ <input type="checkbox" name="prompt_customize_enable" value="true" <?php if (array_key_exists('prompt_customize_enable', $onesignal_wp_settings) && $onesignal_wp_settings['prompt_customize_enable']) { echo "checked"; } ?>>
630
  <label>Customize the HTTP Pop-Up Prompt text</label>
631
  </div>
632
  </div>
633
  <div class="field prompt-customize-feature">
634
  <label>Action Message</label>
635
+ <input type="text" name="prompt_action_message" placeholder="wants to show notifications:" value="<?php echo esc_attr($onesignal_wp_settings['prompt_action_message']); ?>">
636
  </div>
637
  <div class="field prompt-customize-feature">
638
  <label>Auto Accept Title (Click Allow)</label>
639
+ <input type="text" name="prompt_auto_accept_title" placeholder="Click Allow" value="<?php echo esc_attr($onesignal_wp_settings['prompt_auto_accept_title']); ?>">
640
  </div>
641
  <div class="field prompt-customize-feature">
642
  <label>Site Name</label>
643
+ <input type="text" name="prompt_site_name" placeholder="http://yoursite.com" value="<?php echo esc_attr($onesignal_wp_settings['prompt_site_name']); ?>">
644
  </div>
645
  <div class="field prompt-customize-feature">
646
  <label>Example Notification Title (Desktop)</label>
647
+ <input type="text" name="prompt_example_notification_title_desktop" placeholder="This is an example notification" value="<?php echo esc_attr($onesignal_wp_settings['prompt_example_notification_title_desktop']); ?>">
648
  </div>
649
  <div class="field prompt-customize-feature">
650
  <label>Example Notification Message (Desktop)</label>
651
+ <input type="text" name="prompt_example_notification_message_desktop" placeholder="Notifications will appear on your desktop" value="<?php echo esc_attr($onesignal_wp_settings['prompt_example_notification_message_desktop']); ?>">
652
  </div>
653
  <div class="field prompt-customize-feature">
654
  <label>Example Notification Title (Mobile)</label>
655
+ <input type="text" name="prompt_example_notification_title_mobile" placeholder="Example notification" value="<?php echo esc_attr($onesignal_wp_settings['prompt_example_notification_title_mobile']); ?>">
656
  </div>
657
  <div class="field prompt-customize-feature">
658
  <label>Example Notification Message (Mobile)</label>
659
+ <input type="text" name="prompt_example_notification_message_mobile" placeholder="Notifications will appear on your device" value="<?php echo esc_attr($onesignal_wp_settings['prompt_example_notification_message_mobile']); ?>">
660
  </div>
661
  <div class="field prompt-customize-feature">
662
  <label>Example Notification Caption</label>
663
+ <input type="text" name="prompt_example_notification_caption" placeholder="(you can unsubscribe anytime)" value="<?php echo esc_attr($onesignal_wp_settings['prompt_example_notification_caption']); ?>">
664
  </div>
665
  <div class="field prompt-customize-feature">
666
  <label>Accept Button Text</label>
667
+ <input type="text" name="prompt_accept_button_text" placeholder="CONTINUE" value="<?php echo esc_attr($onesignal_wp_settings['prompt_accept_button_text']); ?>">
668
  </div>
669
  <div class="field prompt-customize-feature">
670
  <label>Cancel Button Text</label>
671
+ <input type="text" name="prompt_cancel_button_text" placeholder="NO THANKS" value="<?php echo esc_attr($onesignal_wp_settings['prompt_cancel_button_text']); ?>">
672
  </div>
673
  </div>
674
  </div>
679
  </div>
680
  </div>
681
  <div class="ui borderless shadowless segment" style="position: relative;">
682
+ <img class="img-responsive no-center" src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/welcome-notification.jpg") ?>" width="360">
683
  <div class="explanation">
684
  <p>A welcome notification is sent to new visitors after subscribing. A new visitor is someone who hasn't previously registered. If a user's browser cache is cleared, the user is considered new again.</p>
685
  </div>
691
  </div>
692
  <div class="field welcome-notification-feature">
693
  <label>Title<i class="tiny circular help icon link" role="popup" data-title="Welcome Notification Title" data-content="The welcome notification's title. You can localize this to your own language. If not set, the site's title will be used. Set to one space ' ' to clear the title, although this is not recommended." data-variation="wide"></i></label>
694
+ <input type="text" placeholder="(defaults to your website's title if blank)" name="welcome_notification_title" value="<?php echo esc_attr($onesignal_wp_settings['welcome_notification_title']); ?>">
695
  </div>
696
  <div class="field welcome-notification-feature">
697
  <label>Message<i class="tiny circular help icon link" role="popup" data-title="Welcome Notification Message" data-content="The welcome notification's message. You can localize this to your own language. A message is required. If left blank, the default of 'Thanks for subscribing!' will be used." data-variation="wide"></i></label>
698
+ <input type="text" placeholder="Thanks for subscribing!" name="welcome_notification_message" value="<?php echo esc_attr($onesignal_wp_settings['welcome_notification_message']); ?>">
699
  </div>
700
  <div class="field welcome-notification-feature">
701
  <label>URL<i class="tiny circular help icon link" role="popup" data-title="Welcome Notification URL" data-content="The webpage to open when clicking the notification. If left blank, your main site URL will be used as a default." data-variation="wide"></i></label>
702
+ <input type="text" placeholder="(defaults to your website's URL if blank)" name="welcome_notification_url" value="<?php echo esc_attr($onesignal_wp_settings['welcome_notification_url']); ?>">
703
  </div>
704
  </div>
705
  <div class="ui dividing header">
717
  </div>
718
  <div class="field">
719
  <div class="ui toggle checkbox">
720
+ <input type="checkbox" name="notification_on_post_from_plugin" value="true" <?php if ($onesignal_wp_settings['notification_on_post_from_plugin']) { echo "checked"; } ?>>
721
  <label>Automatically send a push notification when I publish a post from 3<sup>rd</sup> party plugins<i class="tiny circular help icon link" role="popup" data-title="Automatic Push outside WordPress Editor" data-content="If checked, when a post is created outside of WordPress's editor, a push notification will automatically be sent. Must be the built-in WordPress post type 'post' and the post must be published." data-variation="wide"></i></label>
722
  </div>
723
  </div>
731
  <div class="ui borderless shadowless segment">
732
  <div class="field">
733
  <label>Additional Notification URL Parameters<i class="tiny circular help icon link" role="popup" data-html="Adds the specified string as extra URL parameters to your notification URL so that they can be tracked as an event by your analytics system. <em>Please escape your parameter values</em>; your input will be added as-is to the end of your notification URL. Example:</p>If you want:<em><li><code>utm_medium</code> to be <code>ppc</code></li><li><code>utm_source</code> to be <code>adwords</code></li><li><code>utm_campaign</code> to be <code>snow boots</code></li><li><code>utm_content</code> to be <code>durable snow boots</code></li></em><p><p>Then use the following string:</p><p><code style='word-break: break-all;'>utm_medium=ppc&utm_source=adwords&utm_campaign=snow%20boots&utm_content=durable%20%snow%boots</code></p>" data-variation="wide"></i></label>
734
+ <input type="text" placeholder="utm_medium=ppc&utm_source=adwords&utm_campaign=snow%20boots&utm_content=durable%20%snow%boots" name="utm_additional_url_params" value="<?php echo esc_attr($onesignal_wp_settings['utm_additional_url_params']); ?>">
735
  </div>
736
  </div>
737
  <div class="ui dividing header">
743
  <div class="ui borderless shadowless segment">
744
  <div class="field">
745
  <label>Additional Custom Post Types for Automatic Notifications Created From Plugins<i class="tiny circular help icon link" role="popup" data-html="Enter a comma-separated list of custom post type names. Anytime a post is published with one of the listed post types, a notification will be sent to all your users. <strong class='least-strong'>The setting</strong> <em>Automatically send a push notification when I publish a post from 3rd party plugins</em> <strong class='least-strong'>must be enabled for this feature to work</strong>." data-variation="wide"></i></label>
746
+ <input type="text" placeholder="forum,reply,topic (comma separated, no spaces between commas)" name="allowed_custom_post_types" value="<?php echo esc_attr($onesignal_wp_settings['allowed_custom_post_types']); ?>">
747
  </div>
748
  <?php if (OneSignalUtils::url_contains_parameter(ONESIGNAL_URI_REVEAL_PROJECT_NUMBER)): ?>
749
  <div class="field">
755
  <?php endif; ?>
756
  <div class="field custom-manifest-feature">
757
  <label>Custom manifest.json URL<i class="tiny circular help icon link" role="popup" data-html="<p>Enter the complete URL to your existing manifest.json file to be used in place of our own. Your URL's domain should match that of your main site that users are visiting.</p><p>e.g. <code>https://yoursite.com/manifest.json</code></p>" data-variation="wide"></i></label>
758
+ <input type="text" placeholder="https://yoursite.com/manifest.json" name="custom_manifest_url" value="<?php echo esc_attr($onesignal_wp_settings['custom_manifest_url']); ?>">
759
  </div>
760
  <div class="field">
761
  <div class="ui toggle checkbox">
views/javascript/site-admin.js CHANGED
@@ -31,8 +31,8 @@ jQuery(function() {
31
  setupModalPopupSwitcharoo();
32
 
33
  function onFormSubmit(e) {
34
- var safariWebId = $('[name=safari_web_id]').val();
35
- var subdomain = $('[name=subdomain]').val();
36
  var isSiteHttps = isChecked('[name=is_site_https]');
37
 
38
  var missingRequiredSubdomain = (!isSiteHttps &&
@@ -51,7 +51,7 @@ jQuery(function() {
51
  }
52
  }
53
 
54
- $('.ui.form').submit(onFormSubmit);
55
 
56
  hookHiddenDangerLabels();
57
  });
31
  setupModalPopupSwitcharoo();
32
 
33
  function onFormSubmit(e) {
34
+ var safariWebId = jQuery('[name=safari_web_id]').val();
35
+ var subdomain = jQuery('[name=subdomain]').val();
36
  var isSiteHttps = isChecked('[name=is_site_https]');
37
 
38
  var missingRequiredSubdomain = (!isSiteHttps &&
51
  }
52
  }
53
 
54
+ jQuery('.ui.form').submit(onFormSubmit);
55
 
56
  hookHiddenDangerLabels();
57
  });