Version Description
- Added Automatic Push Notifications option for 'All Posts created from other plugins' on the "Notification Settings" tab.
- Note, this is on by default for new installs but off of existing ones so behavior does not automatically change when you update.
- Fixed errors with missing images.
Download this release
Release Info
Developer | OneSignal |
Plugin | OneSignal – Free Web Push Notifications |
Version | 1.0.6 |
Comparing to | |
See all releases |
Code changes from version 1.0.5 to 1.0.6
- onesignal-admin.php +41 -36
- onesignal-settings.php +1 -0
- onesignal.php +1 -1
- readme.txt +9 -4
- views/config.php +11 -4
- views/images/settings/app_id-1.jpg +0 -0
- views/images/settings/gcm-12.jpg +0 -0
onesignal-admin.php
CHANGED
@@ -1,36 +1,31 @@
|
|
1 |
<?php
|
2 |
|
3 |
class OneSignal_Admin {
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
}
|
13 |
if(current_user_can('publish_posts') || current_user_can('edit_published_posts')) {
|
14 |
add_action( 'add_meta_boxes_post', array( __CLASS__, 'add_onesignal_post_options' ) );
|
15 |
add_action( 'save_post', array( __CLASS__, 'on_post_save' ) );
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
add_action( 'transition_post_status', array( __CLASS__, 'notification_on_blog_post' ), 10, 3 );
|
20 |
|
21 |
-
|
22 |
-
|
23 |
|
24 |
public static function add_onesignal_post_options() {
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
'side',
|
32 |
-
'high'
|
33 |
-
);
|
34 |
}
|
35 |
|
36 |
public static function on_post_save($post_id) {
|
@@ -46,6 +41,7 @@ class OneSignal_Admin {
|
|
46 |
$onesignal_wp_settings = OneSignal::get_onesignal_settings();
|
47 |
?>
|
48 |
<input type="checkbox" name="send_onesignal_notification" value="true" <?php if ($onesignal_wp_settings['notification_on_post'] && $post->post_status != "publish") { echo checked; } ?>></input>
|
|
|
49 |
<label> <?php if ($post->post_status == "publish") { echo "Send notification on update"; } else { echo "Send notification on publish"; } ?></label>
|
50 |
<?php
|
51 |
}
|
@@ -90,6 +86,13 @@ class OneSignal_Admin {
|
|
90 |
$onesignal_wp_settings['notification_on_post'] = false;
|
91 |
}
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
$onesignal_wp_settings['default_title'] = $config['default_title'];
|
94 |
$onesignal_wp_settings['default_icon'] = $config['default_icon'];
|
95 |
$onesignal_wp_settings['default_url'] = $config['default_url'];
|
@@ -131,38 +134,36 @@ class OneSignal_Admin {
|
|
131 |
|
132 |
}
|
133 |
|
134 |
-
public static function
|
135 |
-
if (empty( $post )) {
|
136 |
return;
|
137 |
}
|
138 |
|
139 |
$onesignal_wp_settings = OneSignal::get_onesignal_settings();
|
140 |
|
141 |
-
if (isset($_POST['
|
142 |
$send_onesignal_notification = $_POST['send_onesignal_notification'];
|
143 |
}
|
144 |
else {
|
145 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
|
148 |
-
if ($send_onesignal_notification === "true") {
|
149 |
-
if ( get_post_type( $post ) !== 'post' || $post->post_status !== "publish") {
|
150 |
-
return;
|
151 |
-
}
|
152 |
-
|
153 |
update_post_meta($post->ID, 'send_onesignal_notification', "false");
|
154 |
|
155 |
-
|
156 |
-
$notif_content = get_the_title( $post->ID );
|
157 |
-
} else {
|
158 |
-
$notif_content = $custom_headline;
|
159 |
-
}
|
160 |
|
161 |
$fields = array(
|
162 |
'app_id' => $onesignal_wp_settings['app_id'],
|
163 |
'included_segments' => array('All'),
|
164 |
'isChromeWeb' => true,
|
165 |
-
'url' => get_permalink(),
|
166 |
'contents' => array("en" => $notif_content)
|
167 |
);
|
168 |
|
@@ -182,6 +183,10 @@ class OneSignal_Admin {
|
|
182 |
return $response;
|
183 |
}
|
184 |
}
|
|
|
|
|
|
|
|
|
185 |
}
|
186 |
|
187 |
?>
|
1 |
<?php
|
2 |
|
3 |
class OneSignal_Admin {
|
4 |
+
public function __construct() {
|
5 |
+
}
|
|
|
6 |
|
7 |
+
public static function init() {
|
8 |
+
$onesignal = new self();
|
9 |
+
if(current_user_can('update_plugins')) {
|
10 |
+
add_action( 'admin_menu', array(__CLASS__, 'add_admin_page') );
|
11 |
}
|
12 |
if(current_user_can('publish_posts') || current_user_can('edit_published_posts')) {
|
13 |
add_action( 'add_meta_boxes_post', array( __CLASS__, 'add_onesignal_post_options' ) );
|
14 |
add_action( 'save_post', array( __CLASS__, 'on_post_save' ) );
|
15 |
+
}
|
16 |
|
17 |
+
add_action( 'transition_post_status', array( __CLASS__, 'on_transition_post_status' ), 10, 3 );
|
|
|
18 |
|
19 |
+
return $onesignal;
|
20 |
+
}
|
21 |
|
22 |
public static function add_onesignal_post_options() {
|
23 |
+
add_meta_box('onesignal_notif_on_post',
|
24 |
+
'OneSignal',
|
25 |
+
array( __CLASS__, 'onesignal_notif_on_post_html_view' ),
|
26 |
+
'post',
|
27 |
+
'side',
|
28 |
+
'high');
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
public static function on_post_save($post_id) {
|
41 |
$onesignal_wp_settings = OneSignal::get_onesignal_settings();
|
42 |
?>
|
43 |
<input type="checkbox" name="send_onesignal_notification" value="true" <?php if ($onesignal_wp_settings['notification_on_post'] && $post->post_status != "publish") { echo checked; } ?>></input>
|
44 |
+
<input type="hidden" name="has_onesignal_setting" value="true"></input>
|
45 |
<label> <?php if ($post->post_status == "publish") { echo "Send notification on update"; } else { echo "Send notification on publish"; } ?></label>
|
46 |
<?php
|
47 |
}
|
86 |
$onesignal_wp_settings['notification_on_post'] = false;
|
87 |
}
|
88 |
|
89 |
+
if ($config['notification_on_post_from_plugin'] == "true") {
|
90 |
+
$onesignal_wp_settings['notification_on_post_from_plugin'] = true;
|
91 |
+
}
|
92 |
+
else {
|
93 |
+
$onesignal_wp_settings['notification_on_post_from_plugin'] = false;
|
94 |
+
}
|
95 |
+
|
96 |
$onesignal_wp_settings['default_title'] = $config['default_title'];
|
97 |
$onesignal_wp_settings['default_icon'] = $config['default_icon'];
|
98 |
$onesignal_wp_settings['default_url'] = $config['default_url'];
|
134 |
|
135 |
}
|
136 |
|
137 |
+
public static function send_notification_on_wp_post($new_status, $old_status, $post) {
|
138 |
+
if (empty( $post ) || get_post_type( $post ) !== 'post' || $new_status !== "publish") {
|
139 |
return;
|
140 |
}
|
141 |
|
142 |
$onesignal_wp_settings = OneSignal::get_onesignal_settings();
|
143 |
|
144 |
+
if (isset($_POST['has_onesignal_setting'])) {
|
145 |
$send_onesignal_notification = $_POST['send_onesignal_notification'];
|
146 |
}
|
147 |
else {
|
148 |
+
$isOneSignalPostMeta = get_post_meta( $post->ID, 'send_onesignal_notification', true );
|
149 |
+
if (empty($isOneSignalPostMeta)) {
|
150 |
+
$send_onesignal_notification = $isOneSignalPostMeta;
|
151 |
+
}
|
152 |
+
elseif ($old_status !== "publish") {
|
153 |
+
$send_onesignal_notification = $onesignal_wp_settings['notification_on_post_from_plugin'];
|
154 |
+
}
|
155 |
}
|
156 |
|
157 |
+
if ($send_onesignal_notification === true || $send_onesignal_notification === "true") {
|
|
|
|
|
|
|
|
|
158 |
update_post_meta($post->ID, 'send_onesignal_notification', "false");
|
159 |
|
160 |
+
$notif_content = get_the_title( $post->ID );
|
|
|
|
|
|
|
|
|
161 |
|
162 |
$fields = array(
|
163 |
'app_id' => $onesignal_wp_settings['app_id'],
|
164 |
'included_segments' => array('All'),
|
165 |
'isChromeWeb' => true,
|
166 |
+
'url' => get_permalink($post->ID),
|
167 |
'contents' => array("en" => $notif_content)
|
168 |
);
|
169 |
|
183 |
return $response;
|
184 |
}
|
185 |
}
|
186 |
+
|
187 |
+
public static function on_transition_post_status( $new_status, $old_status, $post ) {
|
188 |
+
self::send_notification_on_wp_post($new_status, $old_status, $post);
|
189 |
+
}
|
190 |
}
|
191 |
|
192 |
?>
|
onesignal-settings.php
CHANGED
@@ -9,6 +9,7 @@ class OneSignal {
|
|
9 |
'gcm_sender_id' => '',
|
10 |
'auto_register' => true,
|
11 |
'notification_on_post' => true,
|
|
|
12 |
'use_http' => false,
|
13 |
'subdomain' => "",
|
14 |
'origin' => "",
|
9 |
'gcm_sender_id' => '',
|
10 |
'auto_register' => true,
|
11 |
'notification_on_post' => true,
|
12 |
+
'notification_on_post_from_plugin' => true,
|
13 |
'use_http' => false,
|
14 |
'subdomain' => "",
|
15 |
'origin' => "",
|
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 |
* 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.6
|
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.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -46,8 +46,13 @@ Features:
|
|
46 |
|
47 |
== Changelog ==
|
48 |
|
|
|
|
|
|
|
|
|
|
|
49 |
= 1.0.5 =
|
50 |
-
Send notification on post is now available to any Wordpress user with permissions to create or edit posts.
|
51 |
|
52 |
= 1.0.4 =
|
53 |
- Notifications sent with the Automatic Push Notifications on Post feature directly link to the post instead of the homepage when opening the notification.
|
@@ -63,7 +68,7 @@ Send notification on post is now available to any Wordpress user with permission
|
|
63 |
- Clicks handler added to elements with the class OneSignal-prompt are now setup in a more compatible way.
|
64 |
|
65 |
= 1.0.1 =
|
66 |
-
Modified description
|
67 |
|
68 |
= 1.0.0 =
|
69 |
-
Initial release of the plugin
|
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.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
46 |
|
47 |
== Changelog ==
|
48 |
|
49 |
+
= 1.0.6 =
|
50 |
+
- Added Automatic Push Notifications option for 'All Posts created from other plugins' on the "Notification Settings" tab.
|
51 |
+
- Note, this is on by default for new installs but off of existing ones so behavior does not automatically change when you update.
|
52 |
+
- Fixed errors with missing images.
|
53 |
+
|
54 |
= 1.0.5 =
|
55 |
+
- Send notification on post is now available to any Wordpress user with permissions to create or edit posts.
|
56 |
|
57 |
= 1.0.4 =
|
58 |
- Notifications sent with the Automatic Push Notifications on Post feature directly link to the post instead of the homepage when opening the notification.
|
68 |
- Clicks handler added to elements with the class OneSignal-prompt are now setup in a more compatible way.
|
69 |
|
70 |
= 1.0.1 =
|
71 |
+
- Modified description
|
72 |
|
73 |
= 1.0.0 =
|
74 |
+
- Initial release of the plugin
|
views/config.php
CHANGED
@@ -193,7 +193,7 @@ if ($_POST['app_id']) {
|
|
193 |
|
194 |
<div class="row" id="appID-helper" style="display:none;">
|
195 |
<div class="col-md-12">
|
196 |
-
<img src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/app_id-1.jpg"?>">
|
197 |
</div>
|
198 |
</div>
|
199 |
|
@@ -212,7 +212,7 @@ if ($_POST['app_id']) {
|
|
212 |
|
213 |
<div class="row" id="rest-API-helper" style="display:none;">
|
214 |
<div class="col-md-12">
|
215 |
-
<img src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/app_id-1.jpg"?>">
|
216 |
</div>
|
217 |
</div>
|
218 |
|
@@ -268,8 +268,15 @@ if ($_POST['app_id']) {
|
|
268 |
|
269 |
<div class="col-md-9">
|
270 |
<input type="checkbox" name="notification_on_post" value="true" <?php if ($onesignal_wp_settings['notification_on_post']) { echo checked; } ?>></input>
|
271 |
-
<p>
|
272 |
-
<p style="font-style:italic;">(You can change this setting per post before you publish.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
</div>
|
274 |
</div>
|
275 |
|
193 |
|
194 |
<div class="row" id="appID-helper" style="display:none;">
|
195 |
<div class="col-md-12">
|
196 |
+
<img src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/app_id-1.jpg" ?>" style="width: 80%">
|
197 |
</div>
|
198 |
</div>
|
199 |
|
212 |
|
213 |
<div class="row" id="rest-API-helper" style="display:none;">
|
214 |
<div class="col-md-12">
|
215 |
+
<img src="<?php echo ONESIGNAL_PLUGIN_URL."views/images/settings/app_id-1.jpg"?>" style="width: 80%">
|
216 |
</div>
|
217 |
</div>
|
218 |
|
268 |
|
269 |
<div class="col-md-9">
|
270 |
<input type="checkbox" name="notification_on_post" value="true" <?php if ($onesignal_wp_settings['notification_on_post']) { echo checked; } ?>></input>
|
271 |
+
<p> Post from default Wordpress creator.</p><br/>
|
272 |
+
<p style="font-style:italic; font-size:10pt">(You can change this setting per post before you publish.)</p>
|
273 |
+
</div>
|
274 |
+
|
275 |
+
<div class="col-md-3">
|
276 |
+
</div>
|
277 |
+
<div class="col-md-9">
|
278 |
+
<input type="checkbox" name="notification_on_post_from_plugin" value="true" <?php if ($onesignal_wp_settings['notification_on_post_from_plugin']) { echo checked; } ?>></input>
|
279 |
+
<p> All Posts created from other plugins. </p>
|
280 |
</div>
|
281 |
</div>
|
282 |
|
views/images/settings/app_id-1.jpg
ADDED
Binary file
|
views/images/settings/gcm-12.jpg
ADDED
Binary file
|