OneSignal – Free Web Push Notifications - Version 1.0.8

Version Description

  • UTF-8 characters in post's title now display correctly in notifications.
  • Fixed bug where manifest.json was not being created for HTTPS sites due to permissions.
  • Now adapts to use HTTPS for service worker files if the WordPress settings are not correct.
Download this release

Release Info

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

Code changes from version 1.0.7 to 1.0.8

onesignal-admin.php CHANGED
@@ -50,17 +50,9 @@ class OneSignal_Admin {
50
 
51
  if (is_numeric($config['gcm_sender_id'])) {
52
  $onesignal_wp_settings['gcm_sender_id'] = $config['gcm_sender_id'];
53
- $manifest_json = "{\n"
54
- . " \"start_url\": \"/\",\n"
55
- . " \"gcm_sender_id\": \"" . $onesignal_wp_settings['gcm_sender_id'] . "\",\n"
56
- . " \"gcm_user_visible_only\": true\n"
57
- . "}";
58
- file_put_contents($sdk_dir . 'manifest.json', $manifest_json);
59
  }
60
 
61
- if ($config['gcm_sender_id']) {
62
- $onesignal_wp_settings['subdomain'] = $config['subdomain'];
63
- }
64
 
65
  if (@$config['auto_register'] == "true") {
66
  $onesignal_wp_settings['auto_register'] = true;
@@ -134,10 +126,8 @@ class OneSignal_Admin {
134
  $send_onesignal_notification = $onesignal_wp_settings['notification_on_post_from_plugin'];
135
  }
136
 
137
- if ($send_onesignal_notification === true || $send_onesignal_notification === "true") {
138
- update_post_meta($post->ID, 'send_onesignal_notification', "false");
139
-
140
- $notif_content = get_the_title( $post->ID );
141
 
142
  $fields = array(
143
  'app_id' => $onesignal_wp_settings['app_id'],
50
 
51
  if (is_numeric($config['gcm_sender_id'])) {
52
  $onesignal_wp_settings['gcm_sender_id'] = $config['gcm_sender_id'];
 
 
 
 
 
 
53
  }
54
 
55
+ $onesignal_wp_settings['subdomain'] = $config['subdomain'];
 
 
56
 
57
  if (@$config['auto_register'] == "true") {
58
  $onesignal_wp_settings['auto_register'] = true;
126
  $send_onesignal_notification = $onesignal_wp_settings['notification_on_post_from_plugin'];
127
  }
128
 
129
+ if ($send_onesignal_notification === true || $send_onesignal_notification === "true") {
130
+ $notif_content = html_entity_decode(get_the_title($post->ID), ENT_QUOTES, 'UTF-8');
 
 
131
 
132
  $fields = array(
133
  'app_id' => $onesignal_wp_settings['app_id'],
onesignal-public.php CHANGED
@@ -10,11 +10,18 @@ class OneSignal_Public {
10
 
11
  public static function onesignal_header() {
12
  $onesignal_wp_settings = OneSignal::get_onesignal_settings();
 
 
 
 
 
 
 
 
13
  ?>
 
 
14
  <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script>
15
- <?php if ($onesignal_wp_settings["subdomain"] == "") { ?>
16
- <link rel="manifest" href="<?php echo( ONESIGNAL_PLUGIN_URL . 'sdk_files/manifest.json' ) ?>" />
17
- <?php } ?>
18
  <script>
19
  var OneSignal = OneSignal || [];
20
 
@@ -29,11 +36,11 @@ class OneSignal_Public {
29
  else {
30
  echo "OneSignal.setDefaultTitle(\"" . get_bloginfo( 'name' ) . "\");\n";
31
  }
32
- ?>
33
- <?php if ($onesignal_wp_settings['default_icon'] != "") {
34
  echo "OneSignal.setDefaultIcon(\"" . $onesignal_wp_settings['default_icon'] . "\");\n";
35
- } ?>
36
- <?php
37
  if ($onesignal_wp_settings['default_url'] != "") {
38
  echo "OneSignal.setDefaultNotificationUrl(\"" . $onesignal_wp_settings['default_url'] . "\");";
39
  }
@@ -43,8 +50,13 @@ class OneSignal_Public {
43
  ?>
44
 
45
  OneSignal.init({appId: "<?php echo $onesignal_wp_settings["app_id"] ?>",
46
- <?php if ($onesignal_wp_settings["subdomain"] != "") { echo "subdomainName: \"" . $onesignal_wp_settings["subdomain"] . "\",\n"; } ?>
47
- path: "<?php echo ONESIGNAL_PLUGIN_URL . 'sdk_files' ?>/"});
 
 
 
 
 
48
  }
49
 
50
  window.addEventListener("load", function(event){
10
 
11
  public static function onesignal_header() {
12
  $onesignal_wp_settings = OneSignal::get_onesignal_settings();
13
+
14
+ if ($onesignal_wp_settings["subdomain"] == "") {
15
+ if (strpos(ONESIGNAL_PLUGIN_URL, "http://localhost") === false && strpos(ONESIGNAL_PLUGIN_URL, "http://127.0.0.1") === false) {
16
+ $current_plugin_url = preg_replace("/(http:\/\/)/i", "https://", ONESIGNAL_PLUGIN_URL);
17
+ }
18
+ else {
19
+ $current_plugin_url = ONESIGNAL_PLUGIN_URL;
20
+ }
21
  ?>
22
+ <link rel="manifest" href="<?php echo( $current_plugin_url . 'sdk_files/manifest.json.php' ) ?>" />
23
+ <?php } ?>
24
  <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script>
 
 
 
25
  <script>
26
  var OneSignal = OneSignal || [];
27
 
36
  else {
37
  echo "OneSignal.setDefaultTitle(\"" . get_bloginfo( 'name' ) . "\");\n";
38
  }
39
+
40
+ if ($onesignal_wp_settings['default_icon'] != "") {
41
  echo "OneSignal.setDefaultIcon(\"" . $onesignal_wp_settings['default_icon'] . "\");\n";
42
+ }
43
+
44
  if ($onesignal_wp_settings['default_url'] != "") {
45
  echo "OneSignal.setDefaultNotificationUrl(\"" . $onesignal_wp_settings['default_url'] . "\");";
46
  }
50
  ?>
51
 
52
  OneSignal.init({appId: "<?php echo $onesignal_wp_settings["app_id"] ?>",
53
+ <?php
54
+ if ($onesignal_wp_settings["subdomain"] != "") {
55
+ echo "subdomainName: \"" . $onesignal_wp_settings["subdomain"] . "\"";
56
+ }
57
+ else {
58
+ echo 'path: "' . $current_plugin_url . 'sdk_files/"';
59
+ } ?>});
60
  }
61
 
62
  window.addEventListener("load", function(event){
onesignal.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: OneSignal Push Notifications
4
  * Plugin URI: https://onesignal.com/
5
  * Description:
6
- * Version: 1.0.7
7
  * Author: OneSignal
8
  * Author URI: https://onesignal.com
9
  * License: MIT
3
  * Plugin Name: OneSignal Push Notifications
4
  * Plugin URI: https://onesignal.com/
5
  * Description:
6
+ * Version: 1.0.8
7
  * Author: OneSignal
8
  * Author URI: https://onesignal.com
9
  * License: MIT
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://onesignal.com
4
  Tags: chrome, push, push notifications, safari, chrome push, safari push, notifications, web push, notification, notify, mavericks, firefox push, android, android push, android notifications, mobile notifications, mobile, desktop notifications, gcm, push messages, onesignal
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
- Stable tag: 1.0.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -45,6 +45,11 @@ Features:
45
  3. Follow the instructions on the new OneSignal Wordpress menu option to get started.
46
 
47
  == Changelog ==
 
 
 
 
 
48
  = 1.0.7 =
49
  - Fixed bug where some plugins that create posts were not sending out a OneSignal notifications automatically when 'All Posts created from other plugins' was enabled.
50
  - Fixed errors that display when 'WP_DEBUG' is set to true
4
  Tags: chrome, push, push notifications, safari, chrome push, safari push, notifications, web push, notification, notify, mavericks, firefox push, android, android push, android notifications, mobile notifications, mobile, desktop notifications, gcm, push messages, onesignal
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
+ Stable tag: 1.0.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
45
  3. Follow the instructions on the new OneSignal Wordpress menu option to get started.
46
 
47
  == Changelog ==
48
+ = 1.0.8 =
49
+ - UTF-8 characters in post's title now display correctly in notifications.
50
+ - Fixed bug where manifest.json was not being created for HTTPS sites due to permissions.
51
+ - Now adapts to use HTTPS for service worker files if the WordPress settings are not correct.
52
+
53
  = 1.0.7 =
54
  - Fixed bug where some plugins that create posts were not sending out a OneSignal notifications automatically when 'All Posts created from other plugins' was enabled.
55
  - Fixed errors that display when 'WP_DEBUG' is set to true
sdk_files/manifest.json.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ header("Content-Type: application/json");
3
+ require '../../../../wp-load.php';
4
+
5
+ $onesignal_wp_options = get_option("OneSignalWPSetting");
6
+ ?>
7
+ {
8
+ "start_url": "/",
9
+ "gcm_sender_id": "<?php echo $onesignal_wp_options['gcm_sender_id']; ?>",
10
+ "gcm_user_visible_only": true
11
+ }