Super Progressive Web Apps - Version 2.2.2

Version Description

  • Date: 16.March.2022
  • Enhancement : Added Compatibility with WonderPush Pushnotifications plugin #188
  • Enhancement : Improved the Design of User feedback auto email system #252
Download this release

Release Info

Developer superpwa
Plugin Icon 128x128 Super Progressive Web Apps
Version 2.2.2
Comparing to
See all releases

Code changes from version 2.2.1 to 2.2.2

3rd-party/wonderpush.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WonderPush integration
4
+ *
5
+ * @link https://wordpress.org/plugins/wonderpush-web-push-notifications/
6
+ *
7
+ * @since 2.2.2
8
+ *
9
+ * @function superpwa_wonderpush_compatibility() Compatibility with WonderPush
10
+
11
+ * @function superpwa_wonderpush_sw_filename() Change Service Worker filename to WonderPushSDKWorker.js.php
12
+ * @function superpwa_wonderpush_sw() Import WonderPush service worker in SuperPWA
13
+ */
14
+
15
+ // Exit if accessed directly
16
+ if ( ! defined('ABSPATH') ) exit;
17
+
18
+ /**
19
+ * Compatibility with WonderPush
20
+ *
21
+ * @since 2.0.2
22
+ */
23
+ function superpwa_wonderpush_compatibility() {
24
+
25
+ // If OneSignal is installed and active
26
+ if ( class_exists( 'WonderPushSettings' ) ) {
27
+
28
+
29
+ // Change service worker filename to match WonderPush's service worker
30
+ add_filter( 'superpwa_sw_filename', 'superpwa_wonderpush_sw_filename' );
31
+
32
+ // Import WonderPush service worker in SuperPWA
33
+ add_filter( 'superpwa_sw_template', 'superpwa_wonderpush_sw' );
34
+ }
35
+ }
36
+ add_action( 'plugins_loaded', 'superpwa_wonderpush_compatibility' );
37
+
38
+
39
+ /**
40
+ * Change Service Worker filename to WonderPushSDKWorker.js.php
41
+ *
42
+ * WonderPushSDKWorker.js.php is the name of the service worker of WonderPush.
43
+ * Since only one service worker is allowed in a given scope, WonderPush unregisters all other service workers and registers theirs.
44
+ * Having the same name prevents WonderPush from unregistering our service worker.
45
+ *
46
+ * @link https://documentation.onesignal.com/docs/web-push-setup-faq
47
+ *
48
+ * @param (string) $sw_filename Filename of SuperPWA service worker passed via superpwa_sw_filename filter.
49
+ *
50
+ * @return (string) Service worker filename changed to WonderPushSDKWorker.js.php
51
+ *
52
+ * @since 2.2.2
53
+ */
54
+ function superpwa_wonderpush_sw_filename( $sw_filename ) {
55
+ return 'WonderPushSDKWorker' . superpwa_multisite_filename_postfix() . '.js.php';
56
+ }
57
+
58
+ /**
59
+ * Import WonderPush service worker in SuperPWA
60
+ *
61
+ * @param (string) $sw Service worker template of SuperPWA passed via superpwa_sw_template filter
62
+ *
63
+ * @return (string) Import WonderPush's service worker into SuperPWA
64
+ *
65
+ * @author SuperPWA Team
66
+ *
67
+ * @since 2.2.2
68
+ */
69
+ function superpwa_wonderpush_sw( $sw ) {
70
+
71
+
72
+ $settings = WonderPushSettings::getSettings();
73
+ $access_token = $settings->getAccessToken();
74
+
75
+ if(class_exists('WonderPushSettings')){
76
+ try {
77
+ $app = WonderPushUtils::application_from_access_token($access_token);
78
+ } catch (Exception $e) {
79
+
80
+ return $sw;
81
+ }
82
+ if (!$app) return $sw;
83
+ $web_key = $app->getWebKey();
84
+ }else{
85
+ return $sw;
86
+ }
87
+
88
+
89
+ /**
90
+ * Checking to see if we are already sending the Content-Type header.
91
+ *
92
+ * @see superpwa_generate_sw_and_manifest_on_fly()
93
+ */
94
+ $match = preg_grep( '#Content-Type: text/javascript#i', headers_list() );
95
+
96
+ if ( ! empty ( $match ) ) {
97
+
98
+ $wonderpush = 'importScripts(\'https://cdn.by.wonderpush.com/sdk/1.1/wonderpush-loader.min.js\');
99
+ WonderPush = self.WonderPush || [];
100
+ WonderPush.push([\'init\', {
101
+ webKey: \''.$web_key.'\',
102
+ }]);' . PHP_EOL;
103
+
104
+ return $wonderpush . $sw;
105
+ }
106
+
107
+ $wonderpush = '<?php' . PHP_EOL;
108
+ $wonderpush .= 'header( "Content-Type: application/javascript" );' . PHP_EOL;
109
+ $wonderpush .= 'echo "importScripts(\'https://cdn.by.wonderpush.com/sdk/1.1/wonderpush-loader.min.js\');
110
+ WonderPush = self.WonderPush || [];
111
+ WonderPush.push([\'init\', {
112
+ webKey: \''.$web_key.'\',
113
+ }]);";' . PHP_EOL;
114
+ $wonderpush .= '?>' . PHP_EOL . PHP_EOL;
115
+
116
+ return $wonderpush . $sw;
117
+ }
admin/deactivate-feedback.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $reasons = array(
3
+ 1 => '<li><label><input type="radio" name="superpwa_disable_reason" value="temporary"/>' . __('It is only temporary', 'superpwa-for-wp') . '</label></li>',
4
+ 2 => '<li><label><input type="radio" name="superpwa_disable_reason" value="stopped"/>' . __('I stopped using superPWA on my site', 'superpwa-for-wp') . '</label></li>',
5
+ 3 => '<li><label><input type="radio" name="superpwa_disable_reason" value="missing"/>' . __('I miss a feature', 'superpwa-for-wp') . '</label></li>
6
+ <li><input class="mb-box missing" type="text" name="superpwa_disable_text[]" value="" placeholder="Please describe the feature"/></li>',
7
+ 4 => '<li><label><input type="radio" name="superpwa_disable_reason" value="technical"/>' . __('Technical Issue', 'superpwa-for-wp') . '</label></li>
8
+ <li><textarea class="mb-box technical" name="superpwa_disable_text[]" placeholder="' . __('How Can we help? Please describe your problem', 'superpwa-for-wp') . '"></textarea></li>',
9
+ 5 => '<li><label><input type="radio" name="superpwa_disable_reason" value="another"/>' . __('I switched to another plugin', 'superpwa-for-wp') . '</label></li>
10
+ <li><input class="mb-box another" type="text" name="superpwa_disable_text[]" value="" placeholder="Name of the plugin"/></li>',
11
+ 6 => '<li><label><input type="radio" name="superpwa_disable_reason" value="other"/>' . __('Other reason', 'superpwa-for-wp') . '</label></li>
12
+ <li><textarea class="mb-box other" name="superpwa_disable_text[]" placeholder="' . __('Please specify, if possible', 'superpwa-for-wp') . '"></textarea></li>',
13
+ );
14
+ shuffle($reasons);
15
+ ?>
16
+
17
+
18
+ <div id="superpwa-reloaded-feedback-overlay" style="display: none;">
19
+ <div id="superpwa-reloaded-feedback-content">
20
+ <form action="" method="post">
21
+ <h3><strong><?php _e('If you have a moment, please let us know why you are deactivating:', 'superpwa-for-wp'); ?></strong></h3>
22
+ <ul>
23
+ <?php
24
+ foreach ($reasons as $reason){
25
+ echo $reason;
26
+ }
27
+ ?>
28
+ </ul>
29
+ <?php if ($email) : ?>
30
+ <input type="hidden" name="superpwa_disable_from" value="<?php echo $email; ?>"/>
31
+ <?php endif; ?>
32
+ <input id="superpwa-reloaded-feedback-submit" class="button button-primary" type="submit" name="superpwa_disable_submit" value="<?php _e('Submit & Deactivate', 'superpwa-for-wp'); ?>"/>
33
+ <a class="button"><?php _e('Only Deactivate', 'superpwa-for-wp'); ?></a>
34
+ <a class="superpwa-for-wp-feedback-not-deactivate" href="#"><?php _e('Don\'t deactivate', 'superpwa-for-wp'); ?></a>
35
+ </form>
36
+ </div>
37
+ </div>
admin/make-better-admin.css ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* makebetter admin css*/
2
+
3
+ /**
4
+ PLUGINS ADMIN PAGE
5
+ */
6
+ #superpwa-reloaded-feedback-overlay {
7
+ /* Height & width depends on how you want to reveal the overlay (see JS below) */
8
+ height: 100%;
9
+ width: 100%;
10
+ position: fixed; /* Stay in place */
11
+ z-index: 10000; /* Sit on top */
12
+ left: 0;
13
+ top: 0;
14
+ background-color: rgb(120,120,120); /* Black fallback color */
15
+ background-color: rgba(0,0,0, 0.5); /* Black w/opacity */
16
+ }
17
+ #superpwa-reloaded-feedback-content {
18
+ position: relative;
19
+ top: 25%; /* 25% from the top */
20
+ width: 500px;
21
+ max-width: 100%;
22
+ margin: auto;
23
+ margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
24
+ max-height: 50%;
25
+ padding: 20px;
26
+ background-color: #fff;
27
+ overflow-y: auto;
28
+ }
29
+ .mb-box{display: none;width:100%;}
30
+ .superpwa-for-wp-feedback-not-deactivate { display: block; text-align: right; }
31
+
32
+ #superpwa-reloaded-feedback-content h3{
33
+ margin:5px;
34
+ font-size: 1em;
35
+ }
36
+
37
+ @media screen and (max-width:400px){
38
+ #superpwa-reloaded-feedback-content {
39
+ padding:0px;
40
+ padding-bottom:50px;
41
+ }
42
+ }
admin/make-better-admin.js ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var strict;
2
+
3
+ jQuery(document).ready(function ($) {
4
+ /**
5
+ * DEACTIVATION FEEDBACK FORM
6
+ */
7
+ // show overlay when clicked on "deactivate"
8
+ superpwa_deactivate_link = $('.wp-admin.plugins-php tr[data-slug="super-progressive-web-apps"] .row-actions .deactivate a');
9
+ superpwa_deactivate_link_url = superpwa_deactivate_link.attr('href');
10
+
11
+ superpwa_deactivate_link.click(function (e) {
12
+ e.preventDefault();
13
+
14
+ // only show feedback form once per 30 days
15
+ var c_value = superpwa_admin_get_cookie("superpwa_hide_deactivate_feedback");
16
+
17
+ if (c_value === undefined) {
18
+ $('#superpwa-reloaded-feedback-overlay').show();
19
+ } else {
20
+ // click on the link
21
+ window.location.href = superpwa_deactivate_link_url;
22
+ }
23
+ });
24
+ // show text fields
25
+ $('#superpwa-reloaded-feedback-content input[type="radio"]').click(function () {
26
+ // show text field if there is one
27
+ var inputValue = $(this).attr("value");
28
+ var targetBox = $("." + inputValue);
29
+ $(".mb-box").not(targetBox).hide();
30
+ $(targetBox).show();
31
+ });
32
+ // send form or close it
33
+ $('#superpwa-reloaded-feedback-content .button').click(function (e) {
34
+ e.preventDefault();
35
+ // set cookie for 30 days
36
+ var exdate = new Date();
37
+ exdate.setSeconds(exdate.getSeconds() + 2592000);
38
+ document.cookie = "superpwa_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
39
+
40
+ $('#superpwa-reloaded-feedback-overlay').hide();
41
+ if ('superpwa-reloaded-feedback-submit' === this.id) {
42
+ // Send form data
43
+ $.ajax({
44
+ type: 'POST',
45
+ url: ajaxurl,
46
+ dataType: 'json',
47
+ data: {
48
+ action: 'superpwa_send_feedback',
49
+ data: $('#superpwa-reloaded-feedback-content form').serialize()
50
+ },
51
+ complete: function (MLHttpRequest, textStatus, errorThrown) {
52
+ // deactivate the plugin and close the popup
53
+ $('#superpwa-reloaded-feedback-overlay').remove();
54
+ window.location.href = superpwa_deactivate_link_url;
55
+
56
+ }
57
+ });
58
+ } else {
59
+ $('#superpwa-reloaded-feedback-overlay').remove();
60
+ window.location.href = superpwa_deactivate_link_url;
61
+ }
62
+ });
63
+ // close form without doing anything
64
+ $('.superpwa-for-wp-feedback-not-deactivate').click(function (e) {
65
+ $('#superpwa-reloaded-feedback-overlay').hide();
66
+ });
67
+
68
+ function superpwa_admin_get_cookie (name) {
69
+ var i, x, y, superpwa_cookies = document.cookie.split( ";" );
70
+ for (i = 0; i < superpwa_cookies.length; i++)
71
+ {
72
+ x = superpwa_cookies[i].substr( 0, superpwa_cookies[i].indexOf( "=" ) );
73
+ y = superpwa_cookies[i].substr( superpwa_cookies[i].indexOf( "=" ) + 1 );
74
+ x = x.replace( /^\s+|\s+$/g, "" );
75
+ if (x === name)
76
+ {
77
+ return unescape( y );
78
+ }
79
+ }
80
+ }
81
+
82
+ }); // document ready
admin/mb-helper-function.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ // Exit if accessed directly
5
+ if( !defined( 'ABSPATH' ) )
6
+ exit;
7
+
8
+ /**
9
+ * Helper method to check if user is in the plugins page.
10
+ *
11
+ * @author
12
+ * @since 1.4.0
13
+ *
14
+ * @return bool
15
+ */
16
+ function superpwa_is_plugins_page() {
17
+ global $pagenow;
18
+
19
+ return ( 'plugins.php' === $pagenow );
20
+ }
21
+
22
+ /**
23
+ * display deactivation logic on plugins page
24
+ *
25
+ * @since 1.4.0
26
+ */
27
+
28
+
29
+ function superpwa_add_deactivation_feedback_modal() {
30
+
31
+
32
+ if( !is_admin() && !superpwa_is_plugins_page()) {
33
+ return;
34
+ }
35
+
36
+ $current_user = wp_get_current_user();
37
+ if( !($current_user instanceof WP_User) ) {
38
+ $email = '';
39
+ } else {
40
+ $email = trim( $current_user->user_email );
41
+ }
42
+
43
+ require_once SUPERPWA_PATH_ABS."admin/deactivate-feedback.php";
44
+
45
+ }
46
+
47
+ /**
48
+ * send feedback via email
49
+ *
50
+ * @since 1.4.0
51
+ */
52
+ function superpwa_send_feedback() {
53
+
54
+ if( isset( $_POST['data'] ) ) {
55
+ parse_str( $_POST['data'], $form );
56
+ }
57
+
58
+ $text = '';
59
+ if( isset( $form['superpwa_disable_text'] ) ) {
60
+ $text = implode( "\n\r", $form['superpwa_disable_text'] );
61
+ }
62
+
63
+ $headers = array();
64
+
65
+ $from = isset( $form['superpwa_disable_from'] ) ? $form['superpwa_disable_from'] : '';
66
+ if( $from ) {
67
+ $headers[] = "From: $from";
68
+ $headers[] = "Reply-To: $from";
69
+ }
70
+
71
+ $subject = isset( $form['superpwa_disable_reason'] ) ? $form['superpwa_disable_reason'] : '(no reason given)';
72
+
73
+ $subject = $subject.' - Super Progressive Web Apps';
74
+
75
+ if($subject == 'technical - Super Progressive Web Apps'){
76
+
77
+ $text = trim($text);
78
+
79
+ if(!empty($text)){
80
+
81
+ $text = 'technical issue description: '.$text;
82
+
83
+ }else{
84
+
85
+ $text = 'no description: '.$text;
86
+ }
87
+
88
+ }
89
+
90
+ $success = wp_mail( 'makebetter@magazine3.in', $subject, $text, $headers );
91
+
92
+ die();
93
+ }
94
+ add_action( 'wp_ajax_superpwa_send_feedback', 'superpwa_send_feedback' );
95
+
96
+
97
+
98
+ add_action( 'admin_enqueue_scripts', 'superpwa_enqueue_makebetter_email_js' );
99
+
100
+ function superpwa_enqueue_makebetter_email_js(){
101
+
102
+ if( !is_admin() && !superpwa_is_plugins_page()) {
103
+ return;
104
+ }
105
+
106
+ wp_enqueue_script( 'superpwa-make-better-js', SUPERPWA_PATH_SRC . 'admin/make-better-admin.js', array( 'jquery' ), SUPERPWA_VERSION);
107
+
108
+ wp_enqueue_style( 'superpwa-make-better-css', SUPERPWA_PATH_SRC . 'admin/make-better-admin.css', false , SUPERPWA_VERSION);
109
+ }
110
+
111
+ if( is_admin() && superpwa_is_plugins_page()) {
112
+ add_filter('admin_footer', 'superpwa_add_deactivation_feedback_modal');
113
+ }
114
+
115
+
loader.php CHANGED
@@ -14,11 +14,13 @@ require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-setup.php' );
14
  require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-settings.php' );
15
  require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-addons.php' );
16
  require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-upgrade.php' );
 
17
 
18
  // 3rd party compatibility
19
  require_once( SUPERPWA_PATH_ABS . '3rd-party/onesignal.php' );
20
  require_once( SUPERPWA_PATH_ABS . '3rd-party/yandex.php' );
21
  require_once( SUPERPWA_PATH_ABS . '3rd-party/amp.php' );
 
22
 
23
  // Load functions
24
  require_once( SUPERPWA_PATH_ABS . 'functions/common.php' );
14
  require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-settings.php' );
15
  require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-addons.php' );
16
  require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-upgrade.php' );
17
+ require_once( SUPERPWA_PATH_ABS . 'admin/mb-helper-function.php' );
18
 
19
  // 3rd party compatibility
20
  require_once( SUPERPWA_PATH_ABS . '3rd-party/onesignal.php' );
21
  require_once( SUPERPWA_PATH_ABS . '3rd-party/yandex.php' );
22
  require_once( SUPERPWA_PATH_ABS . '3rd-party/amp.php' );
23
+ require_once( SUPERPWA_PATH_ABS . '3rd-party/wonderpush.php' );
24
 
25
  // Load functions
26
  require_once( SUPERPWA_PATH_ABS . 'functions/common.php' );
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: SuperPWA
3
  Tags: pwa, progressive web apps, manifest, web manifest, android app, chrome app, add to homescreen, mobile web
4
  Requires at least: 3.6.0
5
- Tested up to: 5.9
6
  Requires PHP: 5.3
7
  Stable tag: trunk
8
  License: GPLv2 or later
@@ -186,6 +186,11 @@ Feel free to get in touch if you have any questions.
186
 
187
  == Changelog ==
188
 
 
 
 
 
 
189
  = 2.2.1 =
190
  * Date: [17.February.2022](https://superpwa.com/superpwa-2-2-1-release-note/?utm_source=wordpress.org&utm_medium=changelog)
191
  * Bug Fixed : Some extension addon features are not working properly #245
2
  Contributors: SuperPWA
3
  Tags: pwa, progressive web apps, manifest, web manifest, android app, chrome app, add to homescreen, mobile web
4
  Requires at least: 3.6.0
5
+ Tested up to: 5.9.2
6
  Requires PHP: 5.3
7
  Stable tag: trunk
8
  License: GPLv2 or later
186
 
187
  == Changelog ==
188
 
189
+ = 2.2.2 =
190
+ * Date: [16.March.2022](https://superpwa.com/superpwa-2-2-2-release-note/?utm_source=wordpress.org&utm_medium=changelog)
191
+ * Enhancement : Added Compatibility with WonderPush Pushnotifications plugin #188
192
+ * Enhancement : Improved the Design of User feedback auto email system #252
193
+
194
  = 2.2.1 =
195
  * Date: [17.February.2022](https://superpwa.com/superpwa-2-2-1-release-note/?utm_source=wordpress.org&utm_medium=changelog)
196
  * Bug Fixed : Some extension addon features are not working properly #245
superpwa.php CHANGED
@@ -6,7 +6,7 @@
6
  * Author: SuperPWA
7
  * Author URI: https://profiles.wordpress.org/superpwa/
8
  * Contributors: SuperPWA
9
- * Version: 2.2.1
10
  * Text Domain: super-progressive-web-apps
11
  * Domain Path: /languages
12
  * License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@@ -43,7 +43,7 @@ if ( ! defined('ABSPATH') ) exit;
43
  * @since 1.0
44
  */
45
  if ( ! defined( 'SUPERPWA_VERSION' ) ) {
46
- define( 'SUPERPWA_VERSION' , '2.2.1' );
47
  }
48
 
49
  /**
6
  * Author: SuperPWA
7
  * Author URI: https://profiles.wordpress.org/superpwa/
8
  * Contributors: SuperPWA
9
+ * Version: 2.2.2
10
  * Text Domain: super-progressive-web-apps
11
  * Domain Path: /languages
12
  * License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43
  * @since 1.0
44
  */
45
  if ( ! defined( 'SUPERPWA_VERSION' ) ) {
46
+ define( 'SUPERPWA_VERSION' , '2.2.2' );
47
  }
48
 
49
  /**