Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion onesignal.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* Author: OneSignal
* Author URI: https://onesignal.com
* License: MIT
* Text Domain: onesignal-free-web-push-notifications
* Domain Path: /languages
*/

// Define plugin constants
Expand Down Expand Up @@ -69,7 +71,7 @@ function migration_notice() {
$screen = get_current_screen();
if ($screen && $screen->id === 'plugins') {
echo '<div class="notice notice-warning is-dismissible">
<p><strong>OneSignal Migration Needed:</strong> All OneSignal prompt configurations are moving to OneSignal.com. See the plugin page for more info.</p>
<p><strong>' . esc_html__( 'OneSignal Migration Needed:', 'onesignal-free-web-push-notifications' ) . '</strong> ' . esc_html__( 'All OneSignal prompt configurations are moving to OneSignal.com. See the plugin page for more info.', 'onesignal-free-web-push-notifications' ) . '</p>
</div>';
}
}
49 changes: 30 additions & 19 deletions v2/onesignal-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function admin_notice_error()

// Add our meta box for the "post" post type (default)
add_meta_box('onesignal_notif_on_post',
'OneSignal Push Notifications',
__( 'OneSignal Push Notifications', 'onesignal-free-web-push-notifications' ),
array(__CLASS__, 'onesignal_notif_on_post_html_view'),
'post',
'side',
Expand All @@ -260,7 +260,7 @@ function admin_notice_error()
foreach ($post_types as $post_type) {
add_meta_box(
'onesignal_notif_on_post',
'OneSignal Push Notifications',
__( 'OneSignal Push Notifications', 'onesignal-free-web-push-notifications' ),
array(__CLASS__, 'onesignal_notif_on_post_html_view'),
$post_type,
'side',
Expand Down Expand Up @@ -319,9 +319,11 @@ public static function onesignal_notif_on_post_html_view($post)
} ?>></input>

<?php if ($post->post_status === 'publish') {
echo esc_attr('Send notification on '.$post_type.' update');
/* translators: %s: post type (e.g. post, page) */
echo esc_attr( sprintf( __( 'Send notification on %s update', 'onesignal-free-web-push-notifications' ), $post_type ) );
} else {
echo esc_attr('Send notification on '.$post_type.' publish');
/* translators: %s: post type (e.g. post, page) */
echo esc_attr( sprintf( __( 'Send notification on %s publish', 'onesignal-free-web-push-notifications' ), $post_type ) );

} ?>
</label>
Expand All @@ -330,21 +332,21 @@ public static function onesignal_notif_on_post_html_view($post)
<div id="onesignal_custom_contents_preferences">
<input type="checkbox" id="onesignal_modify_title_and_content" value="true" name="onesignal_modify_title_and_content" <?php if ($onesignal_customize_content_checked) {
echo 'checked';
} ?>></input> Customize notification content</label>
} ?>></input> <?php esc_html_e( 'Customize notification content', 'onesignal-free-web-push-notifications' ); ?></label>

<div id="onesignal_custom_contents" style="display:none;padding-top:10px;">
<div>
<label>Notification Title<br/>
<label><?php esc_html_e( 'Notification Title', 'onesignal-free-web-push-notifications' ); ?><br/>
<input type="text" size="16" style="width:220px;" name="onesignal_notification_custom_heading" value="<?php
echo esc_attr(OneSignalUtils::decode_entities($onesignal_notification_custom_heading));
?>" id="onesignal_notification_custom_heading" placeholder="<?php echo esc_attr(OneSignalUtils::decode_entities($onesignal_wp_settings['notification_title'])); ?>"></input>
</label>
</div>
<div style="padding-top:10px">
<label>Notification Text<br/>
<label><?php esc_html_e( 'Notification Text', 'onesignal-free-web-push-notifications' ); ?><br/>
<input type="text" size="16" style="width:220px;" name="onesignal_notification_custom_content" value="<?php
echo esc_attr(OneSignalUtils::decode_entities($onesignal_notification_custom_content));
?>" id="onesignal_notification_custom_content" placeholder="The Post's Current Title"></input>
?>" id="onesignal_notification_custom_content" placeholder="<?php echo esc_attr( __( "The Post's Current Title", 'onesignal-free-web-push-notifications' ) ); ?>"></input>
</label>
</div>
</div>
Expand Down Expand Up @@ -384,7 +386,7 @@ public static function save_config_page($config)
{
if (!OneSignalUtils::can_modify_plugin_settings()) {
set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
<p><strong>OneSignal Push:</strong><em> Only administrators are allowed to save plugin settings.</em></p>
<p><strong>' . esc_html__( 'OneSignal Push:', 'onesignal-free-web-push-notifications' ) . '</strong><em> ' . esc_html__( 'Only administrators are allowed to save plugin settings.', 'onesignal-free-web-push-notifications' ) . '</em></p>
</div>', 86400);

return;
Expand Down Expand Up @@ -573,7 +575,7 @@ function admin_notice_setup_not_complete()
});
</script>
<div class="error notice onesignal-error-notice">
<p><strong>OneSignal Push:</strong> <em>Your setup is not complete. Please follow the Setup guide to set up web push notifications. Both the App ID and REST API Key fields are required.</em></p>
<p><strong><?php esc_html_e( 'OneSignal Push:', 'onesignal-free-web-push-notifications' ); ?></strong> <em><?php esc_html_e( 'Your setup is not complete. Please follow the Setup guide to set up web push notifications. Both the App ID and REST API Key fields are required.', 'onesignal-free-web-push-notifications' ); ?></em></p>
</div>
<?php
}
Expand All @@ -586,7 +588,7 @@ function admin_notice_curl_not_installed()
{
?>
<div class="error notice onesignal-error-notice">
<p><strong>OneSignal Push:</strong> <em>cURL is not installed on this server. cURL is required to send notifications. Please make sure cURL is installed on your server before continuing.</em></p>
<p><strong><?php esc_html_e( 'OneSignal Push:', 'onesignal-free-web-push-notifications' ); ?></strong> <em><?php esc_html_e( 'cURL is not installed on this server. cURL is required to send notifications. Please make sure cURL is installed on your server before continuing.', 'onesignal-free-web-push-notifications' ); ?></em></p>
</div>
<?php
}
Expand Down Expand Up @@ -697,8 +699,14 @@ public static function send_notification_on_wp_post($new_status, $old_status, $p

$time_to_wait = self::get_sending_rate_limit_wait_time();
if ($time_to_wait > 0) {
/* translators: 1: Number of seconds to wait, 2: API rate limit in seconds */
$error_message = sprintf(
__( 'Please try again in %1$d seconds. Only one notification can be sent every %2$d seconds.', 'onesignal-free-web-push-notifications' ),
$time_to_wait,
ONESIGNAL_API_RATE_LIMIT_SECONDS
);
set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
<p><strong>OneSignal Push:</strong><em> Please try again in '.$time_to_wait.' seconds. Only one notification can be sent every '.ONESIGNAL_API_RATE_LIMIT_SECONDS.' seconds.</em></p>
<p><strong>' . esc_html__( 'OneSignal Push:', 'onesignal-free-web-push-notifications' ) . '</strong><em> ' . esc_html( $error_message ) . '</em></p>
</div>', 86400);

return;
Expand Down Expand Up @@ -826,7 +834,7 @@ public static function send_notification_on_wp_post($new_status, $old_status, $p
$site_title = qtrans_use($qtransLang, $site_title, false);
$notif_content = qtrans_use($qtransLang, $notif_content, false);
} catch (Exception $e) {
return new WP_Error('err', __( "OneSignal: There was a problem sending a notification"));
return new WP_Error('err', __( 'OneSignal: There was a problem sending a notification', 'onesignal-free-web-push-notifications' ));
}
}

Expand Down Expand Up @@ -923,7 +931,7 @@ public static function send_notification_on_wp_post($new_status, $old_status, $p

if (is_null($response)) {
set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
<p><strong>OneSignal Push:</strong><em> There was a problem sending your notification.</em></p>
<p><strong>' . esc_html__( 'OneSignal Push:', 'onesignal-free-web-push-notifications' ) . '</strong><em> ' . esc_html__( 'There was a problem sending your notification.', 'onesignal-free-web-push-notifications' ) . '</em></p>
</div>', 86400);
return;
}
Expand All @@ -941,13 +949,15 @@ public static function send_notification_on_wp_post($new_status, $old_status, $p

if ($status !== 200) {
if ($status !== 0) {
/* translators: %d: HTTP status code */
$error_message = sprintf( __( 'There was a %d error sending your notification.', 'onesignal-free-web-push-notifications' ), $status );
set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
<p><strong>OneSignal Push:</strong><em> There was a '.$status.' error sending your notification.</em></p>
<p><strong>' . esc_html__( 'OneSignal Push:', 'onesignal-free-web-push-notifications' ) . '</strong><em> ' . esc_html( $error_message ) . '</em></p>
</div>', 86400);
} else {
// A 0 HTTP status code means the connection couldn't be established
set_transient('onesignal_transient_error', '<div class="error notice onesignal-error-notice">
<p><strong>OneSignal Push:</strong><em> There was an error establishing a network connection. Please make sure outgoing network connections from cURL are allowed.</em></p>
<p><strong>' . esc_html__( 'OneSignal Push:', 'onesignal-free-web-push-notifications' ) . '</strong><em> ' . esc_html__( 'There was an error establishing a network connection. Please make sure outgoing network connections from cURL are allowed.', 'onesignal-free-web-push-notifications' ) . '</em></p>
</div>', 86400);
}
} else {
Expand All @@ -956,10 +966,11 @@ public static function send_notification_on_wp_post($new_status, $old_status, $p

if ($config_show_notification_send_status_message) {
$app_id = $onesignal_wp_settings['app_id'];
$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>';
$delivery_link_url = esc_url( 'https://dashboard.onesignal.com/apps/' . $app_id . '/notifications' );
$delivery_link_text = ' ' . __( "Go to your app's Delivery tab to check sent messages:", 'onesignal-free-web-push-notifications' ) . '<a target="_blank" href="' . $delivery_link_url . '"> ' . $delivery_link_url . '</a>';
set_transient('onesignal_transient_success', '<div class="updated notice notice-success is-dismissible">
<div class="components-notice__content">
<p><strong>OneSignal Push:</strong><em> Successfully scheduled a notification.' . $delivery_link_text . '</em></p>
<p><strong>' . esc_html__( 'OneSignal Push:', 'onesignal-free-web-push-notifications' ) . '</strong><em> ' . esc_html__( 'Successfully scheduled a notification.', 'onesignal-free-web-push-notifications' ) . $delivery_link_text . '</em></p>
</div>
</div>', 86400);
}
Expand All @@ -974,7 +985,7 @@ public static function send_notification_on_wp_post($new_status, $old_status, $p
return $response;
}
} catch (Exception $e) {
return new WP_Error('err', __( "OneSignal: There was a problem sending a notification"));
return new WP_Error('err', __( 'OneSignal: There was a problem sending a notification', 'onesignal-free-web-push-notifications' ));
} }

public static function was_post_restored_from_trash($old_status, $new_status)
Expand Down
4 changes: 2 additions & 2 deletions v2/onesignal-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,15 @@ public static function insert_amp_one_signal_widget() {
<amp-web-push-widget visibility="unsubscribed" layout="fixed" width="245" height="45">
<button class="subscribe has-background has-text-color" on="tap:amp-web-push.subscribe">
<svg class="onesignal-bell-svg" xmlns="http://www.w3.org/2000/svg" width="99.7" height="99.7" viewBox="0 0 99.7 99.7" style="filter: drop-shadow(0 2px 4px rgba(34,36,38,0.35));; -webkit-filter: drop-shadow(0 2px 4px rgba(34,36,38,0.35));;"><circle class="background" cx="49.9" cy="49.9" r="49.9" style=""></circle><path class="foreground" d="M50.1 66.2H27.7s-2-.2-2-2.1c0-1.9 1.7-2 1.7-2s6.7-3.2 6.7-5.5S33 52.7 33 43.3s6-16.6 13.2-16.6c0 0 1-2.4 3.9-2.4 2.8 0 3.8 2.4 3.8 2.4 7.2 0 13.2 7.2 13.2 16.6s-1 11-1 13.3c0 2.3 6.7 5.5 6.7 5.5s1.7.1 1.7 2c0 1.8-2.1 2.1-2.1 2.1H50.1zm-7.2 2.3h14.5s-1 6.3-7.2 6.3-7.3-6.3-7.3-6.3z" style=""></path><ellipse class="stroke" cx="49.9" cy="49.9" rx="37.4" ry="36.9" style=""></ellipse></svg>
<span class="tooltiptext"><?php esc_html_e( 'Subscribe to notifications' ); ?></span>
<span class="tooltiptext"><?php esc_html_e( 'Subscribe to notifications', 'onesignal-free-web-push-notifications' ); ?></span>
</button>
</amp-web-push-widget>

<!-- An unsubscription widget -->
<amp-web-push-widget visibility="subscribed" layout="fixed" width="230" height="45">
<button class="unsubscribe has-background has-text-color" on="tap:amp-web-push.unsubscribe">
<svg class="onesignal-bell-svg" xmlns="http://www.w3.org/2000/svg" width="99.7" height="99.7" viewBox="0 0 99.7 99.7" style="filter: drop-shadow(0 2px 4px rgba(34,36,38,0.35));; -webkit-filter: drop-shadow(0 2px 4px rgba(34,36,38,0.35));;"><circle class="background" cx="49.9" cy="49.9" r="49.9" style=""></circle><path class="foreground" d="M50.1 66.2H27.7s-2-.2-2-2.1c0-1.9 1.7-2 1.7-2s6.7-3.2 6.7-5.5S33 52.7 33 43.3s6-16.6 13.2-16.6c0 0 1-2.4 3.9-2.4 2.8 0 3.8 2.4 3.8 2.4 7.2 0 13.2 7.2 13.2 16.6s-1 11-1 13.3c0 2.3 6.7 5.5 6.7 5.5s1.7.1 1.7 2c0 1.8-2.1 2.1-2.1 2.1H50.1zm-7.2 2.3h14.5s-1 6.3-7.2 6.3-7.3-6.3-7.3-6.3z" style=""></path><ellipse class="stroke" cx="49.9" cy="49.9" rx="37.4" ry="36.9" style=""></ellipse></svg>
<span class="tooltiptext"><?php esc_html_e( 'Your\'e subscribed to notifications' ); ?></span>
<span class="tooltiptext"><?php esc_html_e( "You're subscribed to notifications", 'onesignal-free-web-push-notifications' ); ?></span>
</button>
</amp-web-push-widget>
<?php
Expand Down
10 changes: 5 additions & 5 deletions v2/onesignal-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
class OneSignalWidget extends WP_Widget {

function __construct() {
parent::__construct('OneSignalWidget', 'OneSignal', array( 'description' => 'Subscribe to notifications'));
parent::__construct('OneSignalWidget', 'OneSignal', array( 'description' => __( 'Subscribe to notifications', 'onesignal-free-web-push-notifications' ) ));
}

// Admin editor
function form($instance) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : 'Follow';
$text = ! empty( $instance['text'] ) ? $instance['text'] : 'Subscribe to notifications';
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Follow', 'onesignal-free-web-push-notifications' );
$text = ! empty( $instance['text'] ) ? $instance['text'] : __( 'Subscribe to notifications', 'onesignal-free-web-push-notifications' );
?>
<p>
<label for="<?php echo esc_attr($this->get_field_id( 'title' )); ?>"><?php esc_attr_e( 'Title:' ); ?></label>
<label for="<?php echo esc_attr($this->get_field_id( 'title' )); ?>"><?php esc_attr_e( 'Title:', 'onesignal-free-web-push-notifications' ); ?></label>
<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 ); ?>">
<label for="<?php echo esc_attr($this->get_field_id( 'text' )); ?>"><?php esc_attr_e( 'Body:' ); ?></label>
<label for="<?php echo esc_attr($this->get_field_id( 'text' )); ?>"><?php esc_attr_e( 'Body:', 'onesignal-free-web-push-notifications' ); ?></label>
<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 ); ?>">
</p>
<?php
Expand Down
Loading