Super Progressive Web Apps - Version 2.2.8

Version Description

  • Date: 09.November.2022
  • Enhancement : While testing the SupwerPwa on https://www.pwabuilder.com/tool, the service for offline shows zero scores. #316 (Screenshots, Category, Direction, Offline issue)
  • Enhancement : upgrade to pro button #319
  • Enhancement : feat (issue #101): Offline Indicator Notice feature #106
  • BugFixed : issue: excluded_urls" in /wp-content/plugins/super-progressive-web-apps/public/manifest.php on line 252 #333
Download this release

Release Info

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

Code changes from version 2.2.7 to 2.2.8

.gitignore ADDED
@@ -0,0 +1 @@
 
1
+ vendor
admin/admin-ui-render-settings.php CHANGED
@@ -11,10 +11,13 @@
11
  * @function superpwa_theme_color_cb() Theme Color
12
  * @function superpwa_app_icon_cb() Application Icon
13
  * @function superpwa_app_icon_cb() Splash Screen Icon
 
14
  * @function superpwa_start_url_cb() Start URL Dropdown
 
15
  * @function superpwa_offline_page_cb() Offline Page Dropdown
16
  * @function superpwa_orientation_cb() Default Orientation Dropdown
17
  * @function superpwa_display_cb() Default Display Dropdown
 
18
  * @function superpwa_manifest_status_cb() Manifest Status
19
  * @function superpwa_sw_status_cb() Service Worker Status
20
  * @function superpwa_https_status_cb() HTTPS Status
@@ -136,6 +139,29 @@ function superpwa_splash_icon_cb() {
136
  <?php
137
  }
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  /**
140
  * Splash Screen Background Color
141
  *
@@ -239,6 +265,36 @@ function superpwa_start_url_cb() {
239
  <?php
240
  }
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  /**
243
  * Offline Page Dropdown
244
  *
@@ -336,6 +392,37 @@ function superpwa_display_cb() {
336
  <?php
337
  }
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  /**
340
  * Manifest Status
341
  *
@@ -613,8 +700,11 @@ function superpwa_admin_interface_render() {
613
  <?php if( defined('SUPERPWA_PRO_VERSION') ){
614
  $expiry_warning = superpwa_license_expire_warning();
615
  ?>
616
- <a class="spwa-tablinks" id="spwa-license" href="#license-settings" onclick="openCity(event, 'superpwa_pro_license')" data-href="no">License <?php echo $expiry_warning; ?></a>
617
- <?php } ?>
 
 
 
618
  </div>
619
  <span id="alert-warning" style=" margin-top: 10px; display: none; padding: 10px;background-color: #ff9800;color: white;"> Please Save the settings before moving to other tabs </span>
620
  <div id="settings" class="spwa-tabcontent">
11
  * @function superpwa_theme_color_cb() Theme Color
12
  * @function superpwa_app_icon_cb() Application Icon
13
  * @function superpwa_app_icon_cb() Splash Screen Icon
14
+ * @function superpwa_app_screenshots_cb() Screenshots Icon
15
  * @function superpwa_start_url_cb() Start URL Dropdown
16
+ * @function superpwa_app_category_cb() App Category Dropdown
17
  * @function superpwa_offline_page_cb() Offline Page Dropdown
18
  * @function superpwa_orientation_cb() Default Orientation Dropdown
19
  * @function superpwa_display_cb() Default Display Dropdown
20
+ * @function superpwa_text_direction_cb() Text Direction Dropdown
21
  * @function superpwa_manifest_status_cb() Manifest Status
22
  * @function superpwa_sw_status_cb() Service Worker Status
23
  * @function superpwa_https_status_cb() HTTPS Status
139
  <?php
140
  }
141
 
142
+ /**
143
+ * Screenshots Icon
144
+ *
145
+ * @since 1.0
146
+ */
147
+ function superpwa_app_screenshots_cb() {
148
+
149
+ // Get Settings
150
+ $settings = superpwa_get_settings(); ?>
151
+
152
+ <!-- Application Icon -->
153
+ <input type="text" name="superpwa_settings[screenshots]" id="superpwa_settings[screenshots]" class="superpwa-screenshots regular-text" size="50" value="<?php echo isset( $settings['screenshots'] ) ? esc_attr( $settings['screenshots']) : ''; ?>">
154
+ <button type="button" class="button superpwa-screenshots-upload" data-editor="content">
155
+ <span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> <?php _e( 'Choose Screenshots', 'super-progressive-web-apps' ); ?>
156
+ </button>
157
+
158
+ <p class="description">
159
+ <?php _e('This will be the screenshots of your app when installed on the phone. Must be a <code>PNG</code> image exactly <code>512x512</code> in size.', 'super-progressive-web-apps'); ?>
160
+ </p>
161
+
162
+ <?php
163
+ }
164
+
165
  /**
166
  * Splash Screen Background Color
167
  *
265
  <?php
266
  }
267
 
268
+ /**
269
+ * App Category Dropdown
270
+ *
271
+ * @since 1.2
272
+ */
273
+ function superpwa_app_category_cb() {
274
+
275
+ // Get Settings
276
+ $settings = superpwa_get_settings(); ?>
277
+
278
+ <fieldset>
279
+
280
+ <!-- WordPress Pages Dropdown -->
281
+ <label for="superpwa_settings[app_category]">
282
+ <?php
283
+ echo wp_dropdown_categories( array(
284
+ 'name' => 'superpwa_settings[app_category]',
285
+ 'echo' => 0,
286
+ 'show_option_none' => __( '&mdash; Default &mdash;' ),
287
+ 'taxonomy' => 'category',
288
+ 'option_none_value' => '0',
289
+ 'selected' => isset($settings['app_category']) ? $settings['app_category'] : '',
290
+ )); ?>
291
+ </label>
292
+
293
+ </fieldset>
294
+
295
+ <?php
296
+ }
297
+
298
  /**
299
  * Offline Page Dropdown
300
  *
392
  <?php
393
  }
394
 
395
+ /**
396
+ * Text Direction Dropdown
397
+ *
398
+ * @author Jose Varghese
399
+ *
400
+ * @since 2.0
401
+ */
402
+ function superpwa_text_direction_cb() {
403
+
404
+ // Get Settings
405
+ $settings = superpwa_get_settings(); ?>
406
+
407
+ <!-- Display Dropdown -->
408
+ <label for="superpwa_settings[text_dir]">
409
+ <select name="superpwa_settings[text_dir]" id="superpwa_settings[display]">
410
+ <option value="0" <?php if ( isset( $settings['text_dir'] ) ) { selected( $settings['text_dir'], 0 ); } ?>>
411
+ <?php _e( 'LTR', 'super-progressive-web-apps' ); ?>
412
+ </option>
413
+ <option value="1" <?php if ( isset( $settings['text_dir'] ) ) { selected( $settings['text_dir'], 1 ); } ?>>
414
+ <?php _e( 'RTL', 'super-progressive-web-apps' ); ?>
415
+ </option>
416
+ </select>
417
+ </label>
418
+
419
+ <p class="description">
420
+ <?php printf( __( 'The text direction of your PWA', 'super-progressive-web-apps' )); ?>
421
+ </p>
422
+
423
+ <?php
424
+ }
425
+
426
  /**
427
  * Manifest Status
428
  *
700
  <?php if( defined('SUPERPWA_PRO_VERSION') ){
701
  $expiry_warning = superpwa_license_expire_warning();
702
  ?>
703
+ <a class="spwa-tablinks" id="spwa-license" href="#license-settings" onclick="openCity(event, 'superpwa_pro_license')" data-href="no">License <?php echo $expiry_warning; ?></a>
704
+ <?php } ?>
705
+ <?php if(!defined('SUPERPWA_PRO_VERSION')){ ?>
706
+ <a class="spwa-tablinks" id="spwa-upgrade2pro" style="background: #ff4c4c;color: #ffffff;margin-right: 5px; float: right; font-weight: 700; padding: 16px 25px" href="<?php echo admin_url('admin.php?page=superpwa-upgrade'); ?>" onclick="openCity(event, 'superpwa-upgrade')" data-href="no"><?php echo __( 'Upgrade to PRO', 'super-progressive-web-apps' ); ?></a>
707
+ <?php } ?>
708
  </div>
709
  <span id="alert-warning" style=" margin-top: 10px; display: none; padding: 10px;background-color: #ff9800;color: white;"> Please Save the settings before moving to other tabs </span>
710
  <div id="settings" class="spwa-tabcontent">
admin/admin-ui-setup.php CHANGED
@@ -159,6 +159,15 @@ function superpwa_register_settings() {
159
  'superpwa_basic_settings_section', // Page slug
160
  'superpwa_basic_settings_section' // Settings Section ID
161
  );
 
 
 
 
 
 
 
 
 
162
 
163
  // Splash Screen Background Color
164
  add_settings_field(
@@ -186,6 +195,15 @@ function superpwa_register_settings() {
186
  'superpwa_basic_settings_section', // Page slug
187
  'superpwa_basic_settings_section' // Settings Section ID
188
  );
 
 
 
 
 
 
 
 
 
189
 
190
  // Offline Page
191
  add_settings_field(
@@ -214,6 +232,15 @@ function superpwa_register_settings() {
214
  'superpwa_basic_settings_section' // Settings Section ID
215
  );
216
 
 
 
 
 
 
 
 
 
 
217
  // PWA Status
218
  add_settings_section(
219
  'superpwa_pwa_status_section', // ID
@@ -371,6 +398,8 @@ function superpwa_validater_and_sanitizer( $settings ) {
371
 
372
  // Sanitize application icon
373
  $settings['icon'] = sanitize_text_field( $settings['icon'] ) == '' ? superpwa_httpsify( SUPERPWA_PATH_SRC . 'public/images/logo.png' ) : sanitize_text_field( superpwa_httpsify( $settings['icon'] ) );
 
 
374
 
375
  // Sanitize splash screen icon
376
  $settings['splash_icon'] = sanitize_text_field( superpwa_httpsify( $settings['splash_icon'] ) );
@@ -415,13 +444,16 @@ function superpwa_get_settings() {
415
  'description' => get_bloginfo( 'description' ),
416
  'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
417
  'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
 
418
  'background_color' => '#D5E0EB',
419
  'theme_color' => '#D5E0EB',
420
  'start_url' => 0,
421
  'start_url_amp' => 0,
 
422
  'offline_page' => 0,
423
  'orientation' => 1,
424
  'display' => 1,
 
425
  'is_static_manifest'=> 0,
426
  'is_static_sw' => 0,
427
  'disable_add_to_home'=> 0,
@@ -448,13 +480,16 @@ function superpwa_get_default_settings() {
448
  'description' => get_bloginfo( 'description' ),
449
  'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
450
  'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
 
451
  'background_color' => '#D5E0EB',
452
  'theme_color' => '#D5E0EB',
453
  'start_url' => 0,
454
  'start_url_amp' => 0,
455
  'offline_page' => 0,
 
456
  'orientation' => 1,
457
  'display' => 1,
 
458
  'is_static_manifest'=> 0,
459
  'is_static_sw' => 0,
460
  'disable_add_to_home'=> 0,
159
  'superpwa_basic_settings_section', // Page slug
160
  'superpwa_basic_settings_section' // Settings Section ID
161
  );
162
+
163
+ // Screenshots Icon
164
+ add_settings_field(
165
+ 'superpwa_app_screenshots', // ID
166
+ __('APP Screenshots', 'super-progressive-web-apps'), // Title
167
+ 'superpwa_app_screenshots_cb', // Callback function
168
+ 'superpwa_basic_settings_section', // Page slug
169
+ 'superpwa_basic_settings_section' // Settings Section ID
170
+ );
171
 
172
  // Splash Screen Background Color
173
  add_settings_field(
195
  'superpwa_basic_settings_section', // Page slug
196
  'superpwa_basic_settings_section' // Settings Section ID
197
  );
198
+
199
+ // App Category
200
+ add_settings_field(
201
+ 'superpwa_app_category', // ID
202
+ __('App Category', 'super-progressive-web-apps'), // Title
203
+ 'superpwa_app_category_cb', // CB
204
+ 'superpwa_basic_settings_section', // Page slug
205
+ 'superpwa_basic_settings_section' // Settings Section ID
206
+ );
207
 
208
  // Offline Page
209
  add_settings_field(
232
  'superpwa_basic_settings_section' // Settings Section ID
233
  );
234
 
235
+ // Direction
236
+ add_settings_field(
237
+ 'superpwa_text_direction', // ID
238
+ __('Text Direction', 'super-progressive-web-apps'), // Title
239
+ 'superpwa_text_direction_cb', // CB
240
+ 'superpwa_basic_settings_section', // Page slug
241
+ 'superpwa_basic_settings_section' // Settings Section ID
242
+ );
243
+
244
  // PWA Status
245
  add_settings_section(
246
  'superpwa_pwa_status_section', // ID
398
 
399
  // Sanitize application icon
400
  $settings['icon'] = sanitize_text_field( $settings['icon'] ) == '' ? superpwa_httpsify( SUPERPWA_PATH_SRC . 'public/images/logo.png' ) : sanitize_text_field( superpwa_httpsify( $settings['icon'] ) );
401
+
402
+ $settings['screenshots'] = sanitize_text_field( $settings['screenshots'] ) == '' ? superpwa_httpsify( SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png' ) : sanitize_text_field( superpwa_httpsify( $settings['screenshots'] ) );
403
 
404
  // Sanitize splash screen icon
405
  $settings['splash_icon'] = sanitize_text_field( superpwa_httpsify( $settings['splash_icon'] ) );
444
  'description' => get_bloginfo( 'description' ),
445
  'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
446
  'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
447
+ 'screenshots' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
448
  'background_color' => '#D5E0EB',
449
  'theme_color' => '#D5E0EB',
450
  'start_url' => 0,
451
  'start_url_amp' => 0,
452
+ 'app_category' => 0,
453
  'offline_page' => 0,
454
  'orientation' => 1,
455
  'display' => 1,
456
+ 'dir' => 'ltr',
457
  'is_static_manifest'=> 0,
458
  'is_static_sw' => 0,
459
  'disable_add_to_home'=> 0,
480
  'description' => get_bloginfo( 'description' ),
481
  'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
482
  'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
483
+ 'screenshots' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
484
  'background_color' => '#D5E0EB',
485
  'theme_color' => '#D5E0EB',
486
  'start_url' => 0,
487
  'start_url_amp' => 0,
488
  'offline_page' => 0,
489
+ 'app_category' => 0,
490
  'orientation' => 1,
491
  'display' => 1,
492
+ 'dir' => 'ltr',
493
  'is_static_manifest'=> 0,
494
  'is_static_sw' => 0,
495
  'disable_add_to_home'=> 0,
admin/js/main.js CHANGED
@@ -33,6 +33,21 @@ jQuery(document).ready(function($){
33
  })
34
  .open();
35
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  $('.superpwa-app-short-name').on('input', function(e) { // Warn when app_short_name exceeds 12 characters.
37
  if ( $('.superpwa-app-short-name').val().length > 15 ) {
38
  $('.superpwa-app-short-name').css({'color': '#dc3232'});
33
  })
34
  .open();
35
  });
36
+ $('.screenshots-icon-upload').click(function(e) { // Application Icon upload
37
+ e.preventDefault();
38
+ var superpwa_meda_uploader = wp.media({
39
+ title: 'Screenshots',
40
+ button: {
41
+ text: 'Select Icon'
42
+ },
43
+ multiple: false // Set this to true to allow multiple files to be selected
44
+ })
45
+ .on('select', function() {
46
+ var attachment = superpwa_meda_uploader.state().get('selection').first().toJSON();
47
+ $('.superpwa-screenshots').val(attachment.url);
48
+ })
49
+ .open();
50
+ });
51
  $('.superpwa-app-short-name').on('input', function(e) { // Warn when app_short_name exceeds 12 characters.
52
  if ( $('.superpwa-app-short-name').val().length > 15 ) {
53
  $('.superpwa-app-short-name').css({'color': '#dc3232'});
public/js/register-sw.js CHANGED
@@ -1,9 +1,182 @@
1
  if ('serviceWorker' in navigator) {
2
  window.addEventListener('load', function() {
3
  navigator.serviceWorker.register(superpwa_sw.url)
4
- .then(function(registration) { console.log('SuperPWA service worker ready'); registration.update(); })
 
 
 
5
  .catch(function(error) { console.log('Registration failed with ' + error); });
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  var deferredPrompt;
9
  window.addEventListener('beforeinstallprompt', function(e){
1
  if ('serviceWorker' in navigator) {
2
  window.addEventListener('load', function() {
3
  navigator.serviceWorker.register(superpwa_sw.url)
4
+ .then(function(registration) { console.log('SuperPWA service worker ready');
5
+ registration.update();
6
+ subOnlineOfflineIndicator();
7
+ })
8
  .catch(function(error) { console.log('Registration failed with ' + error); });
9
 
10
+ /****************** Start : Online/Offline Indicator ******************/
11
+
12
+ // Variables & default values
13
+ const snackbarTimeToHide = 5000; // 5s
14
+ let isOffline = false,
15
+ snackbarTimeoutHide = null,
16
+ goOfflineMsg = 'You\'re currently offline',
17
+ backOnlineMsg = 'You\'re back online <a href="javascript:location.reload()">refresh</a>';
18
+
19
+ /**
20
+ * Subscribe to online offline indicator
21
+ */
22
+ function subOnlineOfflineIndicator() {
23
+ injectSnackbarHtml();
24
+ injectSnackbarCss();
25
+ runOnlineOfflineIndicator();
26
+ }
27
+
28
+ /**
29
+ * Inject html of snackbar
30
+ */
31
+ function injectSnackbarHtml() {
32
+ const container = document.createElement('div');
33
+ container.className = 'snackbar';
34
+
35
+ const parag = document.createElement('p');
36
+ parag.id = 'snackbar-msg';
37
+ container.appendChild(parag);
38
+
39
+ const button = document.createElement('button');
40
+ button.type = 'button';
41
+ button.className = 'snackbar-close';
42
+ button.setAttribute('aria-label', 'snackbar-close');
43
+ button.addEventListener('click', hideSnackbar);
44
+ button.innerHTML = '&times;';
45
+
46
+ container.appendChild(button);
47
+
48
+ document.body.appendChild(container);
49
+
50
+ window.addEventListener('online', runOnlineOfflineIndicator);
51
+ window.addEventListener('offline', runOnlineOfflineIndicator);
52
+
53
+ window.addEventListener('fetch',() => console.log("fetch"));
54
+
55
+ // Clean snackbarTimeToHide varibale when user hover on the snackbar to prevent hide it
56
+ container.addEventListener('mouseover', function () {
57
+ if (snackbarTimeoutHide !== null)
58
+ clearTimeout(snackbarTimeoutHide);
59
+ });
60
+
61
+ // Call setTimeout and set snackbarTimeToHide variable to hide snackbar
62
+ container.addEventListener('mouseout', function () {
63
+ if (snackbarTimeoutHide !== null)
64
+ snackbarTimeoutHide = setTimeout(hideSnackbar, snackbarTimeToHide / 2);
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Inject style css of snackbar
70
+ */
71
+ function injectSnackbarCss() {
72
+ const css = `body.snackbar--show .snackbar {
73
+ -webkit-transform: translateY(0);
74
+ transform: translateY(0);
75
+ }
76
+ .snackbar {
77
+ box-sizing: border-box;
78
+ background-color: #121213;
79
+ color: #fff;
80
+ padding: 10px 55px 10px 10px;
81
+ position: fixed;
82
+ z-index: 9999999999999999;
83
+ left: 15px;
84
+ bottom: 15px;
85
+ border-radius: 5px 8px 8px 5px;
86
+ max-width: 90%;
87
+ min-height: 48px;
88
+ line-height: 28px;
89
+ font-size: 16px;
90
+ -webkit-transform: translateY(150%);
91
+ transform: translateY(150%);
92
+ will-change: transform;
93
+ -webkit-transition: -webkit-transform 200ms ease-in-out;
94
+ -webkit-transition-delay: 0s;
95
+ transition-delay: 0s;
96
+ -webkit-transition: -webkit-transform 200ms ease-in-out false;
97
+ transition: -webkit-transform 200ms ease-in-out false;
98
+ transition: transform 200ms ease-in-out false;
99
+ transition: transform 200ms ease-in-out false, -webkit-transform 200ms ease-in-out false;
100
+ }
101
+ .snackbar p {
102
+ margin: 0;
103
+ color: #fff;
104
+ text-align: center;
105
+ }
106
+ .snackbar .snackbar-close {
107
+ position: absolute;
108
+ top: 0;
109
+ right: 0;
110
+ width: 45px;
111
+ height: 100%;
112
+ padding: 0;
113
+ background: #2a2a2a;
114
+ border: none;
115
+ font-size: 28px;
116
+ font-weight: normal;
117
+ border-radius: 0 5px 5px 0;
118
+ color: #FFF;
119
+ font-family: Arial, Helvetica, sans-serif;
120
+ }
121
+ .snackbar .snackbar-close:hover,
122
+ .snackbar .snackbar-close:focus {
123
+ background: #3f3f3f;
124
+ }
125
+ .snackbar a {
126
+ color: #FFF;
127
+ font-weight: bold;
128
+ text-decoration: underline;
129
+ }`;
130
+
131
+ const head = document.head || document.getElementsByTagName('head')[0];
132
+ const style = document.createElement('style');
133
+
134
+ style.type = 'text/css';
135
+ if (style.styleSheet) {
136
+ // This is required for IE8 and below.
137
+ style.styleSheet.cssText = css;
138
+ } else {
139
+ style.appendChild(document.createTextNode(css));
140
+ }
141
+
142
+ head.appendChild(style);
143
+ }
144
+
145
+ /**
146
+ * Show the state of the mode of connectivity to the user : back onLine | go offLine
147
+ */
148
+ function runOnlineOfflineIndicator() {
149
+ if (navigator.onLine) {
150
+ if (isOffline === true) {
151
+ showSnackbar(backOnlineMsg);
152
+ }
153
+ isOffline = false;
154
+ } else {
155
+ showSnackbar(goOfflineMsg);
156
+ isOffline = true;
157
+ }
158
+ }
159
+
160
+ /**
161
+ * Show with the given message in the snackbar
162
+ * @param {String} msg
163
+ */
164
+ function showSnackbar(msg) {
165
+ document.getElementById('snackbar-msg').innerHTML = msg;
166
+ document.body.classList.add('snackbar--show');
167
+
168
+ clearTimeout(snackbarTimeoutHide);
169
+ snackbarTimeoutHide = setTimeout(hideSnackbar, snackbarTimeToHide);
170
+ }
171
+
172
+ /**
173
+ * Hide snackbar
174
+ */
175
+ function hideSnackbar() {
176
+ document.body.classList.remove('snackbar--show');
177
+ }
178
+
179
+ /****************** End : Online/Offline Indicator ******************/
180
 
181
  var deferredPrompt;
182
  window.addEventListener('beforeinstallprompt', function(e){
public/manifest.php CHANGED
@@ -125,15 +125,18 @@ function superpwa_manifest_template() {
125
  }
126
 
127
  $manifest['icons'] = superpwa_get_pwa_icons();
 
128
  $manifest['background_color'] = $settings['background_color'];
129
  $manifest['theme_color'] = $settings['theme_color'];
130
  $manifest['display'] = superpwa_get_display();
 
131
  $manifest['orientation'] = superpwa_get_orientation();
132
  $manifest['start_url'] = strlen( superpwa_get_start_url( true ) )>2?user_trailingslashit(superpwa_get_start_url( true )) : superpwa_get_start_url( true );
 
133
  $manifest['scope'] = strlen(superpwa_get_scope())>2? user_trailingslashit(superpwa_get_scope()) : superpwa_get_scope();
134
 
135
- if(isset($settings['shortcut_url']) && $settings['shortcut_url']!=0){
136
- $shortcut_url = get_permalink( $settings['shortcut_url'] );
137
  $shortcut_url = superpwa_httpsify( $shortcut_url );
138
  // AMP URL
139
  if ( superpwa_is_amp() !== false && isset( $settings['start_url_amp'] ) && $settings['start_url_amp'] == 1 ) {
@@ -143,16 +146,23 @@ function superpwa_manifest_template() {
143
  $shortcut_url = superpwa_utm_tracking_for_start_url($shortcut_url);
144
  }
145
 
 
146
  $manifest['shortcuts'] = array(
147
  array(
148
  'name'=>get_the_title( $settings['shortcut_url'] ),
149
  'short_name'=>get_the_title( $settings['shortcut_url'] ),
150
  'description'=>get_the_title( $settings['shortcut_url'] ),
151
  'url'=>user_trailingslashit( parse_url( trailingslashit( $shortcut_url ), PHP_URL_PATH ) ),
152
- 'icons'=>array(array('src'=>$settings['icon'], 'sizes'=>'192x192'))
 
 
 
 
 
 
153
  )
154
  );
155
- }
156
 
157
  /**
158
  * Values that go in to Manifest JSON.
@@ -248,13 +258,15 @@ function superpwa_add_manifest_to_wp_head() {
248
  echo $tags;
249
  }
250
  $settings = superpwa_get_settings();
251
- $current_page_url = home_url( $_SERVER['REQUEST_URI'] );
252
- $excluded_urls = explode(",", $settings['excluded_urls']);
253
  $show_manifest_icon = 0;
254
- if(!empty($excluded_urls)){
255
- foreach($excluded_urls as $excluded_page_url) {
256
- if(trim($excluded_page_url) == trim($current_page_url)){
257
- $show_manifest_icon = 1;
 
 
 
 
258
  }
259
  }
260
  }
@@ -320,6 +332,23 @@ function superpwa_get_pwa_icons() {
320
  'purpose'=> 'maskable',
321
  );
322
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
 
324
  return $icons_array;
325
  }
@@ -404,3 +433,35 @@ function superpwa_get_display() {
404
  return 'standalone';
405
  }
406
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  }
126
 
127
  $manifest['icons'] = superpwa_get_pwa_icons();
128
+ $manifest['screenshots'] = superpwa_get_pwa_icons();
129
  $manifest['background_color'] = $settings['background_color'];
130
  $manifest['theme_color'] = $settings['theme_color'];
131
  $manifest['display'] = superpwa_get_display();
132
+ $manifest['dir'] = superpwa_get_text_dir();
133
  $manifest['orientation'] = superpwa_get_orientation();
134
  $manifest['start_url'] = strlen( superpwa_get_start_url( true ) )>2?user_trailingslashit(superpwa_get_start_url( true )) : superpwa_get_start_url( true );
135
+ $manifest['categories'] = (!empty($settings['app_category']) ? $settings['app_category'] : '');
136
  $manifest['scope'] = strlen(superpwa_get_scope())>2? user_trailingslashit(superpwa_get_scope()) : superpwa_get_scope();
137
 
138
+ // if(isset($settings['shortcut_url']) && $settings['shortcut_url']!=0){
139
+ $shortcut_url = !empty($settings['shortcut_url']) ? get_permalink( $settings['shortcut_url'] ) : '';
140
  $shortcut_url = superpwa_httpsify( $shortcut_url );
141
  // AMP URL
142
  if ( superpwa_is_amp() !== false && isset( $settings['start_url_amp'] ) && $settings['start_url_amp'] == 1 ) {
146
  $shortcut_url = superpwa_utm_tracking_for_start_url($shortcut_url);
147
  }
148
 
149
+
150
  $manifest['shortcuts'] = array(
151
  array(
152
  'name'=>get_the_title( $settings['shortcut_url'] ),
153
  'short_name'=>get_the_title( $settings['shortcut_url'] ),
154
  'description'=>get_the_title( $settings['shortcut_url'] ),
155
  'url'=>user_trailingslashit( parse_url( trailingslashit( $shortcut_url ), PHP_URL_PATH ) ),
156
+ 'icons'=>array(array('src'=>$settings['icon'], 'sizes'=>'192x192')),
157
+ 'screenshots'=>array(array('src'=>$settings['screenshots'], 'sizes'=>'512x512')),
158
+ 'categories'=>$settings['app_category'],
159
+ 'shortcode'=>array('name'=>get_the_title( $settings['shortcut_url'] ),
160
+ 'short_name'=>get_the_title( $settings['shortcut_url'] ),
161
+ 'description'=>get_the_title( $settings['shortcut_url'] ),
162
+ 'url'=>user_trailingslashit( parse_url( trailingslashit( $shortcut_url ), PHP_URL_PATH ) ),),
163
  )
164
  );
165
+ // }
166
 
167
  /**
168
  * Values that go in to Manifest JSON.
258
  echo $tags;
259
  }
260
  $settings = superpwa_get_settings();
 
 
261
  $show_manifest_icon = 0;
262
+ $current_page_url = home_url( $_SERVER['REQUEST_URI'] );
263
+ if(!empty($settings['excluded_urls'])){
264
+ $excluded_urls = explode(",", $settings['excluded_urls']);
265
+ if(!empty($excluded_urls)){
266
+ foreach($excluded_urls as $excluded_page_url) {
267
+ if(trim($excluded_page_url) == trim($current_page_url)){
268
+ $show_manifest_icon = 1;
269
+ }
270
  }
271
  }
272
  }
332
  'purpose'=> 'maskable',
333
  );
334
  }
335
+
336
+ // Screenshots - Added since 2.2.8
337
+ if ( @$settings['screenshots'] != '' ) {
338
+
339
+ $icons_array[] = array(
340
+ 'src' => $settings['screenshots'],
341
+ 'sizes' => '512x512', // must be 512x512.
342
+ 'type' => 'image/png', // must be image/png
343
+ 'purpose'=> 'any',
344
+ );
345
+ $icons_array[] = array(
346
+ 'src' => $settings['screenshots'],
347
+ 'sizes' => '512x512', // must be 512x512.
348
+ 'type' => 'image/png', // must be image/png
349
+ 'purpose'=> 'maskable',
350
+ );
351
+ }
352
 
353
  return $icons_array;
354
  }
433
  return 'standalone';
434
  }
435
  }
436
+
437
+
438
+ /**
439
+ * Get display of PWA
440
+ *
441
+ * @return (string) Display of PWA as set in the plugin settings.
442
+ *
443
+ * @author Jose Varghese
444
+ *
445
+ * @since 2.0
446
+ */
447
+ function superpwa_get_text_dir() {
448
+
449
+ // Get Settings
450
+ $settings = superpwa_get_settings();
451
+
452
+ $display = isset( $settings['text_dir'] ) ? $settings['text_dir'] : 0;
453
+
454
+ switch ( $display ) {
455
+
456
+ case 0:
457
+ return 'ltr';
458
+ break;
459
+
460
+ case 1:
461
+ return 'rtl';
462
+ break;
463
+
464
+ default:
465
+ return 'ltr';
466
+ }
467
+ }
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: 6.0.2
6
  Requires PHP: 5.3
7
  Stable tag: trunk
8
  License: GPLv2 or later
@@ -186,6 +186,13 @@ Feel free to get in touch if you have any questions.
186
 
187
  == Changelog ==
188
 
 
 
 
 
 
 
 
189
  = 2.2.7 =
190
  * Date: [13.October.2022](https://superpwa.com/superpwa-2-2-7-release-note/?utm_source=wordpress.org&utm_medium=changelog)
191
  * BugFixed : Preloader not working in IOS device #288
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: 6.0.3
6
  Requires PHP: 5.3
7
  Stable tag: trunk
8
  License: GPLv2 or later
186
 
187
  == Changelog ==
188
 
189
+ = 2.2.8 =
190
+ * Date: [09.November.2022](https://superpwa.com/superpwa-2-2-8-release-note/?utm_source=wordpress.org&utm_medium=changelog)
191
+ * Enhancement : While testing the SupwerPwa on https://www.pwabuilder.com/tool, the service for offline shows zero scores. #316 (Screenshots, Category, Direction, Offline issue)
192
+ * Enhancement : upgrade to pro button #319
193
+ * Enhancement : feat (issue #101): Offline Indicator Notice feature #106
194
+ * BugFixed : issue: excluded_urls" in /wp-content/plugins/super-progressive-web-apps/public/manifest.php on line 252 #333
195
+
196
  = 2.2.7 =
197
  * Date: [13.October.2022](https://superpwa.com/superpwa-2-2-7-release-note/?utm_source=wordpress.org&utm_medium=changelog)
198
  * BugFixed : Preloader not working in IOS device #288
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.7
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.7' );
47
  }
48
 
49
  /**
6
  * Author: SuperPWA
7
  * Author URI: https://profiles.wordpress.org/superpwa/
8
  * Contributors: SuperPWA
9
+ * Version: 2.2.8
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.8' );
47
  }
48
 
49
  /**