From e2d651b3d645ab2f73c8b01cc31d10b932a78dc5 Mon Sep 17 00:00:00 2001 From: Marc Lucraft Date: Thu, 14 Nov 2024 22:47:30 +0000 Subject: [PATCH] Add configuration export Update tweaked deprecation message Update tested to 6.7 --- configuration-export.php | 58 +++++++++ deprecation-notice.php | 2 +- onesignal.php | 1 + readme.txt | 7 +- views/config.php | 249 +++------------------------------------ 5 files changed, 80 insertions(+), 237 deletions(-) create mode 100644 configuration-export.php diff --git a/configuration-export.php b/configuration-export.php new file mode 100644 index 0000000..6fac462 --- /dev/null +++ b/configuration-export.php @@ -0,0 +1,58 @@ + '/^app_id/', + 'General Options' => '/^(chrome_auto_|persist_|default_|utm_additional_)/', + 'Slide Prompt Customizations' => '/^(prompt_customize_|prompt_action_|prompt_accept_|prompt_cancel_|prompt_auto_register)/', + 'Subscription Bell Customizations' => '/^notifyButton_/', + 'Welcome Notification Customizations' => '/^(send_welcome_|welcome_)/', + 'Plugin Settings & HTTP Setup - NO LONGER REQUIRED / DEPRECATED' => '/^(allowed_custom_|customize_http_|custom_manifest_|gcm_|is_site_|notification_on_|notification_title|onesignal_sw_|origin|prompt_auto_accept_title|prompt_example_|prompt_site_name|send_to_mobile_|showNotification|show_gcm_|how_notification_send_|subdomain|use_)/' + ]; + + // sort settings into the defined groups + foreach ($settings as $key => $value) { + foreach ($groups as $group_name => $pattern) { + if (preg_match($pattern, $key)) { + $grouped_settings[$group_name][$key] = is_array($value) ? json_encode($value) : $value; + break; + } + } + } + + // create txt file with main title, group names, and settings. + $txt_data = "OneSignal Push Configuration Export\n\n\n"; + + foreach ($groups as $group_name => $pattern) { + if (isset($grouped_settings[$group_name])) { + $txt_data .= "=== $group_name ===\n"; + + foreach ($grouped_settings[$group_name] as $key => $value) { + $txt_data .= "$key: $value\n"; + } + + $txt_data .= "\n\n"; + } + } + + header('Content-Type: text/plain'); + header('Content-Disposition: attachment; filename="onesignal-configuration-export.txt"'); + header('Content-Length: ' . strlen($txt_data)); + header('Pragma: public'); + + echo $txt_data; + exit; + } +} + +add_action('admin_init', 'onesignal_handle_export'); diff --git a/deprecation-notice.php b/deprecation-notice.php index 35b39cf..7a8da25 100644 --- a/deprecation-notice.php +++ b/deprecation-notice.php @@ -13,7 +13,7 @@ function notify_plugin_update() {

OneSignal Push Important Update: - Before updating to Version 3 of the OneSignal WordPress plugin you must migrate your configuration to dashboard.onesignal.com. + We are soon releasing Version 3 of the OneSignal WordPress Plugin. Before updating, you must migrate your configuration to dashboard.onesignal.com. Learn More.

'; diff --git a/onesignal.php b/onesignal.php index a166b59..245fc3d 100644 --- a/onesignal.php +++ b/onesignal.php @@ -25,6 +25,7 @@ require_once plugin_dir_path(__FILE__).'onesignal-settings.php'; require_once plugin_dir_path(__FILE__).'onesignal-widget.php'; include_once plugin_dir_path(__FILE__).'deprecation-notice.php'; +include_once plugin_dir_path(__FILE__).'configuration-export.php'; if (file_exists(plugin_dir_path(__FILE__).'onesignal-extra.php')) { require_once plugin_dir_path(__FILE__).'onesignal-extra.php'; diff --git a/readme.txt b/readme.txt index 5a71e1f..3b0166d 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: OneSignal Donate link: https://onesignal.com 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 Requires at least: 3.8 -Tested up to: 6.5 -Stable tag: 2.4.4 +Tested up to: 6.7 +Stable tag: 2.4.5 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -66,7 +66,8 @@ OneSignal is trusted by over 1.8M+ developers and marketing strategists. We powe = 2.4.5 = - Add v2 plugin deprecation warning -- Update "Tested up to" Wordpress version to 6.6 +- Add export current configuration +- Update "Tested up to" Wordpress version to 6.7 = 2.4.4 = - Update "Tested up to" Wordpress version to 6.5 diff --git a/views/config.php b/views/config.php index 09e7e84..d738927 100644 --- a/views/config.php +++ b/views/config.php @@ -3,8 +3,8 @@ defined('ABSPATH') or die('This page may not be accessed directly.'); if (!OneSignalUtils::can_modify_plugin_settings()) { - // Exit if the current user does not have permission - die('Insufficient permissions to access config page.'); + // Exit if the current user does not have permission + die('Insufficient permissions to access config page.'); } // The user is just viewing the config page; this page cannot be accessed directly @@ -20,239 +20,22 @@
- - -
-
- -
-

Follow these steps to add Web Push to your Wordpress blog:

-
-
-
1
-
-

Create a OneSignal account or log in to your existing account.

-
-
-
-
2
-
-

- Create a Web Push app in OneSignal, following the instructions in our - Web Push Quickstart guide. -

-
-
-
-
3
-
-

- Set up your Web Push app following the instructions in OneSignal's Web Push Editor. -

-
-
-
- -
- -

Troubleshooting

-

- If you run into issues or need extra guidance, you can follow along each step of our - Wordpress Setup Guide. -

-

- If you're ever stuck or have questions, email us! -

-

- If you run into issues getting your plugin to work, you can also browse our - Troubleshooting Website Push documentation. -

-
-
- -
-

If you've finished the guide up to here, push notifications already work on your site. But your users still need a way to subscribe to your site's notifications. There are a couple ways: -

HTTP Sites:

-
-
- " width="100%"> -
-
- " width="60%"> -
-
-
-
-

Slide Prompt

-
-
-

Subscription Bell

-
-
-

HTTPS Sites:

-
-
- " width="100%"> -
-
- " width="60%"> -
-
-
-
-

Browser Permission Request HTTPS Only

-
-
-

Subscription Bell

-
-
-
    -
  1. Subscription Bell: Enable it in Configuration -> Prompt Settings & Subscription Bell -> Enable the Subscription Bell
  2. -
      -
    1. The Subscription Bell is an interactive site widget.
    2. -
    3. Users see the Subscription Bell on the bottom right corner of your site. They can click the Subscription Bell to subscribe.
    4. -
    5. The Subscription Bell is custom developed by us and does all the work for you! It detects when users are unsubscribed, already subscribed, or have blocked your site and show instructions to unblock. It allows users to easily temporarily subscribe from and resubscribe to notifications.
    6. -
    -
  3. HTTP/HTTPS Prompt: Enable it in Configuration -> Prompt Settings & Subscription Bell -> Automatically prompt new site visitors to subscribe to push notifications
  4. -
      -
    1. Read more about it at our documentation.
    2. -
    -
-

If you're a technical user and would like to implement your own subscription process, this is entirely possible. Please see this guide on how to subscribe user with a link using HTML and JavaScript. Our web SDK JavaScript API is also available and can be called anywhere on the page.

-

- -
-
-

You're done setting up your site for Chrome & Firefox push!

-

Your site works completely with Chrome & Firefox push now. You can learn how to add Safari web push.

-
-
-
-
-
-
- -

Safari on Windows Not Supported

-

Safari on Windows does not support web push notifications. Please use Safari on Mac OS X. Apple also does not support web push notifications on iOS yet.

-
-
-
1
-
-

Log in to your OneSignal account, and navigate to the App Settings page of the app you configured in this guide.

-

You should be on this page:

- "> -

Click Configure on the platform Apple Safari.

-
-
-
-
2
-
-

In this step, we'll focus on filling out the Site Name and Site URL fields.

- "> -

For the Site Name, enter a name you'd like your users to see.

-

In the following sample image, OneSignal is the site name:

- " width="450"> -

For the Site URL, enter the URL to your site's domain. The purpose of this field is to prevent other sites from hijacking your keys to impersonate you and send push notifications on your behalf. Please note:

-
    -
  • -

    Don't include trailing slashes

    -

    Instead of using http://domain.com/, use http://domain.com instead.

    -

    -
  • -
  • -

    Don't include subfolders

    -

    Even if your WordPress blog is hosted on http://domain.com/resource/blog, use http://domain.com

    -

    -
  • -
  • -

    Include the correct protocol

    -

    If your site uses HTTPS, use https://domain.com. If your site uses a mix of HTTPS/HTTP or only HTTP, use http://domain.com..

    -

    -
  • -
-
-
-
-
3
-
-

In this step, we'll focus on uploading your Safari notification icons.

- "> -

Please have your icon in the following sizes:

-
    -
  • 16 × 16
  • -
  • 32 × 32
  • -
  • 64 × 64
  • -
  • 128 × 128
  • -
  • 256 × 256
  • -
-

The different sizes are used in different places (e.g. the 64 × 64 icon is used in the allow notification prompt). If you don't have these different sizes, you may simply upload one 256 × 256 icon into each entry, and we will resize them for you to the appropriate size.

-
-
-
-
4
-
-

Click Save to commit your Safari push settings and then exit the dialog.

-

If you get errors please follow the instructions to fix them. If you're still experiencing problems, email us for support.

-
-
-
-
5
-
-

Refresh the page, and then copy the Safari Web ID you see to the Configuration tab.

- "> -

That's it for setting up Safari push!

-
-
-
- -

Safari Web ID (optional)

-

Copy the Safari Web ID to the Configuration tab.

-
-
-
-
-

This section shows push notifications working for Chrome, Safari, and Firefox in HTTP and HTTPS mode.

- "> -

-
-
Subscription Bell
- "> -
Chrome (HTTP)
- "> -
Chrome (HTTPS)
- "> -
Safari (HTTP & HTTPS)
- "> -
Firefox (HTTP)
- "> -
Firefox (HTTPS)
- "> -
-
-
-
-
+
+ +
-
+ \ No newline at end of file