OneSignal – Free Web Push Notifications - Version 2.1.0

Version Description

  • OneSignal config page interface changes to prompting options to discourage native prompt use, bug fixes
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.1.0

onesignal-admin.php CHANGED
@@ -160,44 +160,31 @@ class OneSignal_Admin
160
  return;
161
  }
162
  /*
163
- * We need to verify this came from the our screen and with proper authorization,
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
 
179
  /*
180
- * If this is an autosave, our form has not been submitted,
181
- * so we don't want to do anything.
182
- */
183
  if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
184
  return $post_id;
185
  }
186
 
187
- /* OK, it's safe for us to save the data now. */
188
-
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 {
@@ -344,6 +331,7 @@ class OneSignal_Admin
344
  $onesignal_wp_settings['is_site_https_firsttime'] = 'set';
345
 
346
  $booleanSettings = array(
 
347
  'is_site_https',
348
  'prompt_auto_register',
349
  'use_modal_prompt',
@@ -367,7 +355,6 @@ class OneSignal_Admin
367
  'show_notification_send_status_message',
368
  'use_http_permission_request',
369
  'customize_http_permission_request',
370
- 'use_slidedown_permission_message_for_https',
371
  );
372
  OneSignal_Admin::saveBooleanSettings($onesignal_wp_settings, $config, $booleanSettings);
373
 
@@ -608,14 +595,16 @@ class OneSignal_Admin
608
  return;
609
  }
610
 
611
- /* The checkbox "Send notification on post publish/update" on the OneSignal meta box is checked */
612
- $onesignal_meta_box_send_notification_checked = $was_posted && array_key_exists('send_onesignal_notification', $_POST) && $_POST['send_onesignal_notification'] === 'true';
613
 
614
- $nonce = (isset($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY]) ? filter_var(isset($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY]), FILTER_SANITIZE_STRING) : '');
615
-
616
- // Verify that the nonce is valid.
617
- if ($onesignal_meta_box_send_notification_checked && !wp_verify_nonce($nonce, OneSignal_Admin::$SAVE_POST_NONCE_ACTION)) {
618
- return;
 
 
619
  }
620
 
621
  $time_to_wait = self::get_sending_rate_limit_wait_time();
@@ -633,16 +622,15 @@ class OneSignal_Admin
633
 
634
  /* Settings related to creating a post involving the WordPress editor displaying the OneSignal meta box
635
  **********************************************************************************************************/
636
- /* Returns true if there is POST data */
637
- $was_posted = !empty($_POST);
638
 
639
  /* When this post was created or updated, the OneSignal meta box in the WordPress post editor screen was visible */
640
  $onesignal_meta_box_present = $was_posted && isset($_POST['onesignal_meta_box_present'], $_POST['onesignal_meta_box_present']) && $_POST['onesignal_meta_box_present'] === 'true';
641
-
 
642
  /* This is a scheduled post and the OneSignal meta box was present. */
643
- $post_metadata_was_onesignal_meta_box_present = (get_post_meta($post->ID, 'onesignal_meta_box_present') === true);
644
  /* This is a scheduled post and the user checked "Send a notification on post publish/update". */
645
- $post_metadata_was_send_notification_checked = (get_post_meta($post->ID, 'onesignal_send_notification') === true);
646
 
647
  /* 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 */
648
  $posted_from_wordpress_editor = $onesignal_meta_box_present || $post_metadata_was_onesignal_meta_box_present;
@@ -703,7 +691,6 @@ class OneSignal_Admin
703
  }
704
 
705
  $notif_content = OneSignalUtils::decode_entities(get_the_title($post->ID));
706
-
707
  $site_title = '';
708
  if ($onesignal_wp_settings['notification_title'] !== '') {
709
  $site_title = OneSignalUtils::decode_entities($onesignal_wp_settings['notification_title']);
160
  return;
161
  }
162
  /*
163
+ * We need to verify this came from the our screen and with proper authorization,
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
+ // Verify that the nonce is valid.
173
+ if (!wp_verify_nonce((isset($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY]) ?
174
+ sanitize_text_field($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY]) :
175
+ ''
176
+ ), OneSignal_Admin::$SAVE_POST_NONCE_ACTION)) {
177
  return $post_id;
178
  }
179
 
180
  /*
181
+ * If this is an autosave, our form has not been submitted,
182
+ * so we don't want to do anything.
183
+ */
184
  if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
185
  return $post_id;
186
  }
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  if (array_key_exists('onesignal_meta_box_present', $_POST)) {
189
  update_post_meta($post_id, 'onesignal_meta_box_present', true);
190
  } else {
331
  $onesignal_wp_settings['is_site_https_firsttime'] = 'set';
332
 
333
  $booleanSettings = array(
334
+ 'use_native_prompt',
335
  'is_site_https',
336
  'prompt_auto_register',
337
  'use_modal_prompt',
355
  'show_notification_send_status_message',
356
  'use_http_permission_request',
357
  'customize_http_permission_request',
 
358
  );
359
  OneSignal_Admin::saveBooleanSettings($onesignal_wp_settings, $config, $booleanSettings);
360
 
595
  return;
596
  }
597
 
598
+ /* Returns true if there is POST data */
599
+ $was_posted = !empty($_POST);
600
 
601
+ // Verify that the nonce is valid.
602
+ if ($was_posted && !wp_verify_nonce((
603
+ isset($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY]) ?
604
+ sanitize_text_field($_POST[OneSignal_Admin::$SAVE_POST_NONCE_KEY]) :
605
+ ''
606
+ ), OneSignal_Admin::$SAVE_POST_NONCE_ACTION)) {
607
+ return;
608
  }
609
 
610
  $time_to_wait = self::get_sending_rate_limit_wait_time();
622
 
623
  /* Settings related to creating a post involving the WordPress editor displaying the OneSignal meta box
624
  **********************************************************************************************************/
 
 
625
 
626
  /* When this post was created or updated, the OneSignal meta box in the WordPress post editor screen was visible */
627
  $onesignal_meta_box_present = $was_posted && isset($_POST['onesignal_meta_box_present'], $_POST['onesignal_meta_box_present']) && $_POST['onesignal_meta_box_present'] === 'true';
628
+ /* The checkbox "Send notification on post publish/update" on the OneSignal meta box is checked */
629
+ $onesignal_meta_box_send_notification_checked = $was_posted && array_key_exists('send_onesignal_notification', $_POST) && $_POST['send_onesignal_notification'] === 'true';
630
  /* This is a scheduled post and the OneSignal meta box was present. */
631
+ $post_metadata_was_onesignal_meta_box_present = (get_post_meta($post->ID, 'onesignal_meta_box_present', true) === '1');
632
  /* This is a scheduled post and the user checked "Send a notification on post publish/update". */
633
+ $post_metadata_was_send_notification_checked = (get_post_meta($post->ID, 'onesignal_send_notification', true) === '1');
634
 
635
  /* 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 */
636
  $posted_from_wordpress_editor = $onesignal_meta_box_present || $post_metadata_was_onesignal_meta_box_present;
691
  }
692
 
693
  $notif_content = OneSignalUtils::decode_entities(get_the_title($post->ID));
 
694
  $site_title = '';
695
  if ($onesignal_wp_settings['notification_title'] !== '') {
696
  $site_title = OneSignalUtils::decode_entities($onesignal_wp_settings['notification_title']);
onesignal-public.php CHANGED
@@ -83,12 +83,6 @@ class OneSignal_Public
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";
@@ -277,7 +271,6 @@ class OneSignal_Public
277
  $use_custom_sdk_init = $onesignal_wp_settings['use_custom_sdk_init'];
278
  if (!$use_custom_sdk_init) {
279
  if (has_filter('onesignal_initialize_sdk')) {
280
- onesignal_debug('Applying onesignal_initialize_sdk filter.');
281
  if (apply_filters('onesignal_initialize_sdk', $onesignal_wp_settings)) {
282
  // If the filter returns "$do_initialize_sdk: true", initialize the web SDK
283
  ?>
@@ -289,19 +282,19 @@ class OneSignal_Public
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();
297
- OneSignal.init(window._oneSignalInitOptions);
298
- <?php
299
- } else {
300
- ?>
301
- OneSignal.init(window._oneSignalInitOptions);
302
- <?php
303
- }
304
  }
 
305
  } else {
306
  ?>
307
  /* OneSignal: Using custom SDK initialization. */
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('use_http_permission_request', $onesignal_wp_settings) && $onesignal_wp_settings['use_http_permission_request'] === true) {
87
  echo "oneSignal_options['httpPermissionRequest'] = { };\n";
88
  echo "oneSignal_options['httpPermissionRequest']['enable'] = true;\n";
271
  $use_custom_sdk_init = $onesignal_wp_settings['use_custom_sdk_init'];
272
  if (!$use_custom_sdk_init) {
273
  if (has_filter('onesignal_initialize_sdk')) {
 
274
  if (apply_filters('onesignal_initialize_sdk', $onesignal_wp_settings)) {
275
  // If the filter returns "$do_initialize_sdk: true", initialize the web SDK
276
  ?>
282
  <?php
283
  }
284
  } else {
285
+ ?>
286
+ OneSignal.init(window._oneSignalInitOptions);
287
+ <?php
288
+ }
289
+
290
+ if ($onesignal_wp_settings['prompt_auto_register'] === true) {
291
+ echo "OneSignal.showSlidedownPrompt();";
292
+ }
293
+
294
+ if ($onesignal_wp_settings['use_native_prompt'] === true) {
295
+ echo "OneSignal.showNativePrompt();";
 
296
  }
297
+
298
  } else {
299
  ?>
300
  /* OneSignal: Using custom SDK initialization. */
onesignal-settings.php CHANGED
@@ -90,7 +90,6 @@ class OneSignal {
90
  'http_permission_request_modal_title' => '',
91
  'http_permission_request_modal_message' => '',
92
  'http_permission_request_modal_button_text' => '',
93
- 'use_slidedown_permission_message_for_https' => false,
94
  'persist_notifications' => 'CALCULATE_SPECIAL_VALUE'
95
  );
96
 
90
  'http_permission_request_modal_title' => '',
91
  'http_permission_request_modal_message' => '',
92
  'http_permission_request_modal_button_text' => '',
 
93
  'persist_notifications' => 'CALCULATE_SPECIAL_VALUE'
94
  );
95
 
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: 2.0.1
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.1.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.2
7
- Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -65,6 +65,10 @@ HTTPS Setup Video: [youtube https://www.youtube.com/watch?v=BeTZ2KgytC0]
65
 
66
  == Changelog ==
67
 
 
 
 
 
68
  = 2.0.1 =
69
 
70
  - Bug fix: link expired issue due to failing nonce check when creating posts from other WordPress plugins
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.3.2
7
+ Stable tag: 2.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
65
 
66
  == Changelog ==
67
 
68
+ = 2.1.0 =
69
+
70
+ - OneSignal config page interface changes to prompting options to discourage native prompt use, bug fixes
71
+
72
  = 2.0.1 =
73
 
74
  - Bug fix: link expired issue due to failing nonce check when creating posts from other WordPress plugins
views/config.php CHANGED
@@ -394,29 +394,17 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
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>
397
-
398
- <div class="field modal-prompt-feature">
399
- <div class="ui toggle checkbox">
400
- <input type="checkbox" name="use_modal_prompt" value="true" <?php if ($onesignal_wp_settings['use_modal_prompt']) { echo "checked"; } ?>>
401
- <label>Use an alternate full-screen prompt when requesting subscription permission (incompatible with Subscription Bell and auto-prompting)</label>
402
- </div>
403
- </div>
404
  <div class="field auto-register-feature">
405
  <div class="field">
406
  <div class="ui toggle checkbox">
407
  <input type="checkbox" name="prompt_auto_register" value="true" <?php if ($onesignal_wp_settings['prompt_auto_register']) { echo "checked"; } ?>>
408
  <label>
409
- Automatically prompt new site visitors to subscribe to push notifications
410
  <i class="tiny circular help icon link"
411
- role="popup"
412
  data-html="
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>
@@ -428,12 +416,6 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
428
  </div>
429
  </div>
430
  </div>
431
- <div class="field slidedown-permission-message-https-feature">
432
- <div class="ui toggle checkbox">
433
- <input type="checkbox" name="use_slidedown_permission_message_for_https" value="true" <?php if (array_key_exists('use_slidedown_permission_message_for_https', $onesignal_wp_settings) && $onesignal_wp_settings['use_slidedown_permission_message_for_https']) { echo "checked"; } ?>>
434
- <label>Show the Slide Prompt before prompting users to subscribe<i class="tiny circular help icon link" role="popup" data-title="Slide Prompt for HTTPS Sites" data-content="If checked, the Slide Prompt will be shown before the browser's permission request. Please note that this Slide Prompt cannot replace the browser's native permission request. The browser's native permission request must always be finally shown before the user can be subscribed." data-variation="wide"></i></label>
435
- </div>
436
- </div>
437
  <div class="field">
438
  <div class="ui toggle checkbox">
439
  <input type="checkbox" name="notifyButton_enable" value="true" <?php if (array_key_exists('notifyButton_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_enable']) { echo "checked"; } ?>>
@@ -613,63 +595,75 @@ $onesignal_wp_settings = OneSignal::get_onesignal_settings();
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>
617
  <div class="popup-modal-settings">
618
  <div class="ui dividing header">
619
  <i class="external icon"></i>
620
  <div class="content">
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>
675
  <div class="ui dividing header">
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>
 
 
 
 
 
 
 
397
  <div class="field auto-register-feature">
398
  <div class="field">
399
  <div class="ui toggle checkbox">
400
  <input type="checkbox" name="prompt_auto_register" value="true" <?php if ($onesignal_wp_settings['prompt_auto_register']) { echo "checked"; } ?>>
401
  <label>
402
+ Automatically prompt new site visitors with OneSignal Slide Prompt before Native Browser Prompt (recommended)
403
  <i class="tiny circular help icon link"
404
+ role="popup"
405
  data-html="
406
+ <h4>Slide Prompt</h4><p>If enabled, the Slide Prompt will be shown before the browser's permission request.</p><p>Please note that this Slide Prompt cannot replace the browser's native permission request.</p><p>The browser's native permission request must always be finally shown before the user can be subscribed.</p>
407
+ <p>
 
 
 
 
 
408
  <img
409
  src='<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/http-prompt.png") ?>'
410
  width=400>
416
  </div>
417
  </div>
418
  </div>
 
 
 
 
 
 
419
  <div class="field">
420
  <div class="ui toggle checkbox">
421
  <input type="checkbox" name="notifyButton_enable" value="true" <?php if (array_key_exists('notifyButton_enable', $onesignal_wp_settings) && $onesignal_wp_settings['notifyButton_enable']) { echo "checked"; } ?>>
595
  <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']); ?>">
596
  </div>
597
  </div>
598
+ <div class="field">
599
+ <div class="ui toggle checkbox">
600
+ <input type="checkbox" name="use_native_prompt" value="true" <?php if (array_key_exists('use_native_prompt', $onesignal_wp_settings) && $onesignal_wp_settings['use_native_prompt']) { echo "checked"; } ?>>
601
+ <label>Attempt to automatically prompt new site visitors with Native Browser Prompt (not recommended)<i class="tiny circular help icon link" role="popup" data-title="Native Prompt" data-content="If checked, we will attempt to automatically present the browser's native prompt. We don't recommend this as browsers may penalize you for immediately displaying this prompt. Instead we recommend using one of our two-step prompting options: Slide Prompt or Subscription Bell." data-variation="wide"></i></label>
602
+ </div>
603
+ </div>
604
+ <div class="callout danger native-prompt-warning" style="display: none;">
605
+ <p>We strongly recommend not immediately prompting users with the native prompt as most browsers will hide this prompt if users frequently click deny. <a href="https://documentation.onesignal.com/docs/native-browser-prompt" target="_blank"> More information</a></p>
606
+ </div>
607
  </div>
608
  <div class="popup-modal-settings">
609
  <div class="ui dividing header">
610
  <i class="external icon"></i>
611
  <div class="content">
612
+ Prompt Customization
613
  </div>
614
  </div>
615
+ <div style="display:flex; flex-wrap: wrap; align-items: center;">
616
+ <img src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/http-prompt.jpg") ?>" width="500">
617
+ <img src="<?php echo esc_url(ONESIGNAL_PLUGIN_URL."views/images/settings/http-prompt.png") ?>" width="500">
618
+ </div>
619
  <div class="ui borderless shadowless segment" style="position: relative;">
620
+ <p class="lato">These settings modify the HTTP Pop-up Prompt and HTTPS Slide Prompt for all users. Use this to localize the Prompt to your language. All fields here are limited in the length of text they can display.</p>
621
  <div class="field">
622
  <div class="ui toggle checkbox">
623
  <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"; } ?>>
624
+ <label>Customize the Prompt text</label>
625
  </div>
626
  </div>
627
  <div class="field prompt-customize-feature">
628
  <label>Action Message</label>
629
+ <input type="text" name="prompt_action_message" placeholder="We'd like to send you push notifications. You can unsubscribe at any time." value="<?php echo esc_attr($onesignal_wp_settings['prompt_action_message']); ?>">
630
  </div>
631
  <div class="field prompt-customize-feature">
632
+ <label>Accept Button Text</label>
633
+ <input type="text" name="prompt_accept_button_text" placeholder="ALLOW" value="<?php echo esc_attr($onesignal_wp_settings['prompt_accept_button_text']); ?>">
634
+ </div>
635
+ <div class="field prompt-customize-feature">
636
+ <label>Cancel Button Text</label>
637
+ <input type="text" name="prompt_cancel_button_text" placeholder="NO THANKS" value="<?php echo esc_attr($onesignal_wp_settings['prompt_cancel_button_text']); ?>">
638
+ </div>
639
+ <div class="field prompt-customize-feature">
640
+ <label>Auto Accept Title (Click Allow) - HTTP Only</label>
641
  <input type="text" name="prompt_auto_accept_title" placeholder="Click Allow" value="<?php echo esc_attr($onesignal_wp_settings['prompt_auto_accept_title']); ?>">
642
  </div>
643
  <div class="field prompt-customize-feature">
644
+ <label>Site Name - HTTP Only</label>
645
  <input type="text" name="prompt_site_name" placeholder="http://yoursite.com" value="<?php echo esc_attr($onesignal_wp_settings['prompt_site_name']); ?>">
646
  </div>
647
  <div class="field prompt-customize-feature">
648
+ <label>Example Notification Title (Desktop) - HTTP Only</label>
649
  <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']); ?>">
650
  </div>
651
  <div class="field prompt-customize-feature">
652
+ <label>Example Notification Message (Desktop) - HTTP Only</label>
653
  <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']); ?>">
654
  </div>
655
  <div class="field prompt-customize-feature">
656
+ <label>Example Notification Title (Mobile) - HTTP Only</label>
657
  <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']); ?>">
658
  </div>
659
  <div class="field prompt-customize-feature">
660
+ <label>Example Notification Message (Mobile) - HTTP Only</label>
661
  <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']); ?>">
662
  </div>
663
  <div class="field prompt-customize-feature">
664
+ <label>Example Notification Caption - HTTP Only</label>
665
  <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']); ?>">
666
  </div>
 
 
 
 
 
 
 
 
667
  </div>
668
  </div>
669
  <div class="ui dividing header">
views/javascript/site-admin.js CHANGED
@@ -9,9 +9,10 @@ jQuery(function() {
9
  jQuery('.ui.dropdown').dropdown();
10
 
11
  ensureNoCheckboxConflicts({
12
- use_modal_prompt: ['prompt_auto_register', 'notifyButton_enable'],
13
- prompt_auto_register: ['use_modal_prompt'],
14
- notifyButton_enable: ['use_modal_prompt']
 
15
  });
16
 
17
  ensureFeaturesVisible({
@@ -23,7 +24,8 @@ jQuery(function() {
23
  'prompt_customize_enable': ['.prompt-customize-feature'],
24
  'send_welcome_notification': ['.welcome-notification-feature'],
25
  'is_site_https': ['.modal-prompt-feature', '.slidedown-permission-message-https-feature'],
26
- 'use_custom_manifest': ['.custom-manifest-feature']
 
27
  });
28
 
29
  httpSiteCheck();
@@ -332,4 +334,4 @@ function showHttpPopup() {
332
 
333
  if (popupPreviewWindow)
334
  popupPreviewWindow.focus();
335
- }
9
  jQuery('.ui.dropdown').dropdown();
10
 
11
  ensureNoCheckboxConflicts({
12
+ use_modal_prompt: ['prompt_auto_register', 'notifyButton_enable', 'use_native_prompt'],
13
+ prompt_auto_register: ['use_modal_prompt', 'use_native_prompt'],
14
+ notifyButton_enable: ['use_modal_prompt'],
15
+ use_native_prompt: ['prompt_auto_register', 'use_modal_prompt']
16
  });
17
 
18
  ensureFeaturesVisible({
24
  'prompt_customize_enable': ['.prompt-customize-feature'],
25
  'send_welcome_notification': ['.welcome-notification-feature'],
26
  'is_site_https': ['.modal-prompt-feature', '.slidedown-permission-message-https-feature'],
27
+ 'use_custom_manifest': ['.custom-manifest-feature'],
28
+ 'use_native_prompt': ['.native-prompt-warning']
29
  });
30
 
31
  httpSiteCheck();
334
 
335
  if (popupPreviewWindow)
336
  popupPreviewWindow.focus();
337
+ }