Skip to content

Commit 8540956

Browse files
author
Rodrigo Gomez Palacio
authored
Merge pull request #312 from OneSignal/update-recipient-count
2.4.0 Release - remove recipient count
2 parents ec26ff9 + 31a289c commit 8540956

File tree

5 files changed

+31
-57
lines changed

5 files changed

+31
-57
lines changed

notice.js

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ function notice() {
1515
}
1616

1717
const editor = wp.data.select("core/editor");
18-
const get_wp_attr = attr => {
19-
return editor.getEditedPostAttribute(attr);
20-
};
2118

2219
/*
2320
* Subscribes function to WP's state-change listener
@@ -46,7 +43,7 @@ function notice() {
4643
// is checked
4744
let send_os_notif;
4845
const htmlElement = jQuery("#send_onesignal_notification")[0];
49-
46+
5047
if (!!htmlElement) {
5148
send_os_notif = htmlElement.checked;
5249
}
@@ -75,18 +72,19 @@ function notice() {
7572

7673
jQuery.get(ajax_object.ajax_url, data, function(response) {
7774
response = JSON.parse(response);
78-
const { recipients, status_code, response_body } = response;
75+
const { status_code, response_body } = response;
7976

8077
if(window.DEBUG_MODE){
8178
console.log(response);
8279
}
8380

8481
const is_status_empty = status_code.length == 0;
85-
const is_recipients_empty = recipients.length == 0;
8682

87-
if(!is_status_empty && !is_recipients_empty){
83+
if(!is_status_empty){
84+
status_code = parseInt(status_code);
85+
8886
// status 0: HTTP request failed
89-
if (status_code === "0") {
87+
if (status_code === 0) {
9088
error_notice("OneSignal Push: request failed with status code 0. "+response_body);
9189
reset_state();
9290
return;
@@ -108,16 +106,8 @@ function notice() {
108106
return;
109107
}
110108

111-
if (recipients === "0") {
112-
error_notice(
113-
"OneSignal Push: there were no recipients."
114-
);
115-
reset_state();
116-
117-
} else if (recipients) {
118-
show_notice(recipients);
119-
reset_state();
120-
}
109+
show_notice();
110+
reset_state();
121111
}
122112
});
123113

@@ -128,29 +118,28 @@ function notice() {
128118
);
129119
reset_state();
130120
}
131-
121+
132122
state.interval_count += 1;
133123
};
134124

135125
/*
136126
* Gets recipient count and shows notice
137127
*/
138-
const show_notice = recipients => {
139-
const plural = recipients == 1 ? "" : "s";
128+
const show_notice = () => {
140129
var delivery_link_text = "";
141130

142131
if (state.status === "publish") {
143-
var notice_text = "OneSignal Push: Successfully sent a notification to ";
144-
delivery_link_text = ". Go to your app's \"Delivery\" tab to check sent messages: https://app.onesignal.com/apps";
132+
var notice_text = "OneSignal Push: Successfully sent a notification.";
133+
delivery_link_text = " Go to your app's Delivery tab to check sent messages: https://dashboard.onesignal.com/apps/";
145134
} else if (state.status === "future"){
146-
var notice_text = "OneSignal Push: Successfully scheduled a notification for ";
135+
var notice_text = "OneSignal Push: Successfully scheduled a notification.";
147136
}
148137

149138
wp.data
150139
.dispatch("core/notices")
151140
.createNotice(
152141
"info",
153-
notice_text + recipients + " recipient" + plural + delivery_link_text,
142+
notice_text + delivery_link_text,
154143
{
155144
id:'onesignal-notice',
156145
isDismissible: true

onesignal-admin.php

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -949,34 +949,16 @@ public static function send_notification_on_wp_post($new_status, $old_status, $p
949949
}
950950
} else {
951951
if (!empty($response)) {
952-
953-
// API can send a 200 OK even if the notification failed to send
954-
if (isset($response['body'])) {
955-
$response_body = json_decode($response['body'], true);
956-
if (isset($response_body['recipients'])) {
957-
$recipient_count = $response_body['recipients'];
958-
}
959-
}
960-
961-
// updates meta so that recipient count is available for GET request from client
962-
update_post_meta($post->ID, 'recipients', $recipient_count);
963-
964-
$sent_or_scheduled = array_key_exists('send_after', $fields) ? 'scheduled' : 'sent';
965952
$config_show_notification_send_status_message = $onesignal_wp_settings['show_notification_send_status_message'] === true;
966953

967954
if ($config_show_notification_send_status_message) {
968-
if ($recipient_count !== 0) {
969-
$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>' : '';
970-
set_transient('onesignal_transient_success', '<div class="updated notice notice-success is-dismissible">
971-
<div class="components-notice__content">
972-
<p><strong>OneSignal Push:</strong><em> Successfully '.$sent_or_scheduled.' a notification to '.$recipient_count.' recipients.'.$delivery_link_text.'</em></p>
973-
</div>
974-
</div>', 86400);
975-
} else {
976-
set_transient('onesignal_transient_success', '<div class="updated notice notice-success is-dismissible">
977-
<p><strong>OneSignal Push:</strong><em>There were no recipients. You likely have no subscribers.</em></p>
978-
</div>', 86400);
979-
}
955+
$app_id = $onesignal_wp_settings['app_id'];
956+
$delivery_link_text = ' Go to your app\'s Delivery tab to check sent messages: </em><a target="_blank" href="https://dashboard.onesignal.com/apps/' . $app_id . '/notifications">https://dashboard.onesignal.com/apps/' . $app_id . '/notifications</a><em>';
957+
set_transient('onesignal_transient_success', '<div class="updated notice notice-success is-dismissible">
958+
<div class="components-notice__content">
959+
<p><strong>OneSignal Push:</strong><em> Successfully scheduled a notification.' . $delivery_link_text . '</em></p>
960+
</div>
961+
</div>', 86400);
980962
}
981963
}
982964
}

onesignal-public.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function add_async_for_script($url)
99
else if (is_admin())
1010
return str_replace('#asyncload', '', $url);
1111
else
12-
return str_replace('#asyncload', '', $url)."' async='async";
12+
return str_replace('#asyncload', '', $url)."' async='async";
1313
}
1414

1515
class OneSignal_Public
@@ -321,15 +321,15 @@ public static function onesignal_header()
321321
OneSignal.init(window._oneSignalInitOptions);
322322
<?php
323323
}
324-
324+
325325
if (array_key_exists('prompt_auto_register', $onesignal_wp_settings) && $onesignal_wp_settings['prompt_auto_register'] === true) {
326326
echo "OneSignal.showSlidedownPrompt();";
327327
}
328328

329329
if (array_key_exists('use_native_prompt', $onesignal_wp_settings) && $onesignal_wp_settings['use_native_prompt'] === true) {
330330
echo "OneSignal.showNativePrompt();";
331331
}
332-
332+
333333
} else {
334334
?>
335335
/* OneSignal: Using custom SDK initialization. */

onesignal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Plugin Name: OneSignal Push Notifications
77
* Plugin URI: https://onesignal.com/
88
* Description: Free web push notifications.
9-
* Version: 2.3.3
9+
* Version: 2.4.0
1010
* Author: OneSignal
1111
* Author URI: https://onesignal.com
1212
* License: MIT

readme.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Contributors: OneSignal
33
Donate link: https://onesignal.com
44
Tags: push notification, push notifications, desktop notifications, mobile notifications, chrome push, android, android notification, android notifications, android push, desktop notification, firefox, firefox push, mobile, mobile notification, notification, notifications, notify, onesignal, push, push messages, safari, safari push, web push, chrome
55
Requires at least: 3.8
6-
Tested up to: 6.1
7-
Stable tag: 2.3.3
6+
Tested up to: 6.3
7+
Stable tag: 2.4.0
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -23,7 +23,7 @@ You can configure notification delivery at preset intervals, create user segment
2323
OneSignal’s free plan allows targeting up to 10,000 subscribers with push notifications. Contact support@onesignal.com if you have any questions. We’d love to hear from you!
2424

2525
= Company =
26-
OneSignal is trusted by over 1,800,000 developers and marketing strategists. We power push notifications for everyone from early stage startups to Fortune 500 Companies, sending over 6 billion notifications per day. It is the most popular push notification plugin on Wordpress with 100,000+ installations.
26+
OneSignal is trusted by over 1.8M+ developers and marketing strategists. We power push notifications for everyone from early stage startups to Fortune 500 Companies, sending over 6 billion notifications per day. It is the most popular push notification plugin on Wordpress with 100,000+ installations.
2727

2828
= Features =
2929
* **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.
@@ -67,6 +67,9 @@ HTTPS Setup Video: [youtube https://www.youtube.com/watch?v=BeTZ2KgytC0]
6767

6868
== Changelog ==
6969

70+
= 2.4.0 =
71+
- Remove recipient count after post publishing.
72+
7073
= 2.3.3 =
7174
- Update "Tested up to" Wordpress version 6.1
7275

0 commit comments

Comments
 (0)