Super Progressive Web Apps - Version 2.1.16

Version Description

  • Date: 26.August.2021
  • Bug Fixed : "Add to homescreen" banner was not showing when Wp fastest cache plugin is active #209
  • Enhancement : Added an Option to Re-Install Service Worker #211
  • Enhancement : Added an Option to Cache External Origin URLs by Service Worker #213
Download this release

Release Info

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

Code changes from version 2.1.15 to 2.1.16

admin/admin-ui-render-settings.php CHANGED
@@ -474,6 +474,20 @@ function superpwa_analytics_support_cb() {
474
  <?php
475
  }
476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
  /**
478
  * Exclude Urls from Cache list of service worker
479
  *
@@ -491,6 +505,28 @@ function superpwa_exclude_url_cache_cb(){
491
  <?php
492
  }
493
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
494
 
495
  /**
496
  * Admin interface renderer
474
  <?php
475
  }
476
 
477
+ /**
478
+ * Enable or disable cache external urls support
479
+ *
480
+ * @since 2.1.6
481
+ */
482
+ function superpwa_cache_external_urls_support_cb() {
483
+ // Get Settings
484
+ $settings = superpwa_get_settings();
485
+ ?><input type="checkbox" name="superpwa_settings[cache_external_urls]" id="superpwa_settings[cache_external_urls]" value="1"
486
+ <?php if ( isset( $settings['cache_external_urls'] ) ) { checked( '1', $settings['cache_external_urls'] ); } ?>>
487
+ <br>
488
+ <?php
489
+ }
490
+
491
  /**
492
  * Exclude Urls from Cache list of service worker
493
  *
505
  <?php
506
  }
507
 
508
+ /**
509
+ * Force Update Service Worker
510
+ *
511
+ * @since 2.1.6
512
+ */
513
+
514
+ function superpwa_force_update_sw_cb(){
515
+ // Get Settings
516
+ $settings = superpwa_get_settings();
517
+ ?>
518
+ <label><input type="text" id="superpwa_settings[force_update_sw_setting]" name="superpwa_settings[force_update_sw_setting]" value="<?php if(isset($settings['force_update_sw_setting'])){
519
+ if(!version_compare($settings['force_update_sw_setting'],SUPERPWA_VERSION, '>=') ){
520
+ $settings['force_update_sw_setting'] = SUPERPWA_VERSION;
521
+ }
522
+ echo esc_attr($settings['force_update_sw_setting']);
523
+ }else{ echo SUPERPWA_VERSION; } ?>"></label>
524
+ <code>Current Version <?php echo SUPERPWA_VERSION; ?></code>
525
+ <p><?php echo esc_html__('Update the version number. It will automatically re-install the service worker for all the users', 'super-progressive-web-apps'); ?></p>
526
+
527
+ <?php
528
+ }
529
+
530
 
531
  /**
532
  * Admin interface renderer
admin/admin-ui-setup.php CHANGED
@@ -254,6 +254,22 @@ function superpwa_register_settings() {
254
  'superpwa_analytics_support_cb', // CB
255
  'superpwa_pwa_advance_section', // Page slug
256
  'superpwa_pwa_advance_section' // Settings Section ID
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  );
258
  // Exclude Urls from Cache list
259
  add_settings_field(
254
  'superpwa_analytics_support_cb', // CB
255
  'superpwa_pwa_advance_section', // Page slug
256
  'superpwa_pwa_advance_section' // Settings Section ID
257
+ );
258
+ // Cache External Origin URLs
259
+ add_settings_field(
260
+ 'superpwa_cache_external_urls_shortcut', // ID
261
+ __('Cache External Origin URLs', 'super-progressive-web-apps'), // Title
262
+ 'superpwa_cache_external_urls_support_cb', // CB
263
+ 'superpwa_pwa_advance_section', // Page slug
264
+ 'superpwa_pwa_advance_section' // Settings Section ID
265
+ );
266
+ // Force Update Service Worker
267
+ add_settings_field(
268
+ 'superpwa_force_update_sw_shortcut', // ID
269
+ __('Re-Install Service Worker', 'super-progressive-web-apps'), // Title
270
+ 'superpwa_force_update_sw_cb', // CB
271
+ 'superpwa_pwa_advance_section', // Page slug
272
+ 'superpwa_pwa_advance_section' // Settings Section ID
273
  );
274
  // Exclude Urls from Cache list
275
  add_settings_field(
admin/basic-setup.php CHANGED
@@ -441,6 +441,14 @@ function superpwa_generate_sw_and_manifest_on_fly( $query ) {
441
  echo json_encode( superpwa_manifest_template() );
442
  exit();
443
  }
 
 
 
 
 
 
 
 
444
  if ( strpos( $query_vars_as_string, $sw_filename ) !== false ) {
445
  header( 'Content-Type: text/javascript' );
446
  echo superpwa_sw_template();
441
  echo json_encode( superpwa_manifest_template() );
442
  exit();
443
  }
444
+ // Needed new query_vars of pagename for Wp Fastest Cache
445
+ if(class_exists('WpFastestCache')){
446
+ $query_vars_as_string = isset($query->query_vars['pagename']) ? $query->query_vars['pagename'] : false;
447
+ if($query_vars_as_string == false){
448
+ $query_vars_as_string = isset($query->query_vars['name']) ? $query->query_vars['name'] : '';
449
+ }
450
+ }
451
+
452
  if ( strpos( $query_vars_as_string, $sw_filename ) !== false ) {
453
  header( 'Content-Type: text/javascript' );
454
  echo superpwa_sw_template();
public/sw.php CHANGED
@@ -154,7 +154,16 @@ function superpwa_sw_template() {
154
 
155
  // Get Settings
156
  $settings = superpwa_get_settings();
157
-
 
 
 
 
 
 
 
 
 
158
  // Start output buffer. Everything from here till ob_get_clean() is returned
159
  ob_start(); ?>
160
  'use strict';
@@ -164,7 +173,7 @@ function superpwa_sw_template() {
164
  * To learn more and add one to your website, visit - https://superpwa.com
165
  */
166
 
167
- const cacheName = '<?php echo parse_url( get_bloginfo( 'url' ), PHP_URL_HOST ) . '-superpwa-' . SUPERPWA_VERSION; ?>';
168
  const startPage = '<?php echo superpwa_get_start_url(); ?>';
169
  const offlinePage = '<?php echo superpwa_get_offline_page(); ?>';
170
  const filesToCache = [<?php echo apply_filters( 'superpwa_sw_files_to_cache', 'startPage, offlinePage' ); ?>];
@@ -214,10 +223,11 @@ self.addEventListener('fetch', function(e) {
214
  if ( ! e.request.url.match(/^(http|https):\/\//i) )
215
  return;
216
 
 
217
  // Return if request url is from an external domain.
218
  if ( new URL(e.request.url).origin !== location.origin )
219
  return;
220
-
221
  // For POST requests, do not use the cache. Serve offline page if offline.
222
  if ( e.request.method !== 'GET' ) {
223
  e.respondWith(
@@ -395,4 +405,29 @@ function superpwa_get_offline_page() {
395
  $settings = superpwa_get_settings();
396
 
397
  return get_permalink( $settings['offline_page'] ) ? superpwa_httpsify( get_permalink( $settings['offline_page'] ) ) : superpwa_httpsify( superpwa_get_bloginfo( 'sw' ) );
398
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
  // Get Settings
156
  $settings = superpwa_get_settings();
157
+
158
+ $cache_version = SUPERPWA_VERSION;
159
+
160
+ if(isset($settings['force_update_sw_setting']) && $settings['force_update_sw_setting'] !=''){
161
+ $cache_version = $settings['force_update_sw_setting'];
162
+ if(!version_compare($cache_version,SUPERPWA_VERSION, '>=') ){
163
+ $cache_version = SUPERPWA_VERSION;
164
+ }
165
+ }
166
+
167
  // Start output buffer. Everything from here till ob_get_clean() is returned
168
  ob_start(); ?>
169
  'use strict';
173
  * To learn more and add one to your website, visit - https://superpwa.com
174
  */
175
 
176
+ const cacheName = '<?php echo parse_url( get_bloginfo( 'url' ), PHP_URL_HOST ) . '-superpwa-' . $cache_version; ?>';
177
  const startPage = '<?php echo superpwa_get_start_url(); ?>';
178
  const offlinePage = '<?php echo superpwa_get_offline_page(); ?>';
179
  const filesToCache = [<?php echo apply_filters( 'superpwa_sw_files_to_cache', 'startPage, offlinePage' ); ?>];
223
  if ( ! e.request.url.match(/^(http|https):\/\//i) )
224
  return;
225
 
226
+ <?php if(!isset($settings['cache_external_urls']) || (isset($settings['cache_external_urls']) && $settings['cache_external_urls'] !== '1')){ ?>
227
  // Return if request url is from an external domain.
228
  if ( new URL(e.request.url).origin !== location.origin )
229
  return;
230
+ <?php } ?>
231
  // For POST requests, do not use the cache. Serve offline page if offline.
232
  if ( e.request.method !== 'GET' ) {
233
  e.respondWith(
405
  $settings = superpwa_get_settings();
406
 
407
  return get_permalink( $settings['offline_page'] ) ? superpwa_httpsify( get_permalink( $settings['offline_page'] ) ) : superpwa_httpsify( superpwa_get_bloginfo( 'sw' ) );
408
+ }
409
+
410
+ /**
411
+ * Change superpwa_sw_filename When WP Fastest Cache is active.
412
+ * @since 2.1.6
413
+ */
414
+ function superpwa_wp_fastest_cache_sw_filename( $sw_filename ) {
415
+ return 'superpwa-sw' . superpwa_multisite_filename_postfix() . '.js&action=wpfastestcache';
416
+ }
417
+
418
+ function superpwa_third_party_plugins_sw_filename(){
419
+ /**
420
+ * Change superpwa_sw_filename When WP Fastest Cache is active.
421
+ *
422
+ * @since 2.1.6
423
+ */
424
+ if ( class_exists('WpFastestCache') ) {
425
+
426
+ // Change service worker filename to match WP Fastest Cache action type for js.
427
+
428
+ add_filter( 'superpwa_sw_filename', 'superpwa_wp_fastest_cache_sw_filename',99 );
429
+ }
430
+
431
+ }
432
+
433
+ add_action('plugins_loaded','superpwa_third_party_plugins_sw_filename');
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.7.2
6
  Requires PHP: 5.3
7
  Stable tag: trunk
8
  License: GPLv2 or later
@@ -186,18 +186,24 @@ Feel free to get in touch if you have any questions.
186
 
187
  == Changelog ==
188
 
 
 
 
 
 
 
189
  = 2.1.15 =
190
  * Date: [12.July.2021](https://superpwa.com/superpwa-2-1-15-release-note/?utm_source=wordpress.org&utm_medium=changelog)
191
- Bug Fixed : User end issue: Apple splash icon not working properly #200
192
- Bug Fixed : Centralize image with background color not getting saved. #205
193
 
194
  = 2.1.14 =
195
  * Date: [30.June.2021](https://superpwa.com/superpwa-2-1-14-release-note/?utm_source=wordpress.org&utm_medium=changelog)
196
- Enhancement: Need to Improve Admin UI #196
197
 
198
  = 2.1.13 =
199
  * Date: [15.June.2021](https://superpwa.com/superpwa-2-1-13-release-note/?utm_source=wordpress.org&utm_medium=changelog)
200
- BugFixed: iOS Splash Screen Images are not getting saved #191
201
 
202
  = 2.1.12 =
203
  * Date: [29.May.2021](https://superpwa.com/superpwa-2-1-12-release-note/?utm_source=wordpress.org&utm_medium=changelog)
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.8
6
  Requires PHP: 5.3
7
  Stable tag: trunk
8
  License: GPLv2 or later
186
 
187
  == Changelog ==
188
 
189
+ = 2.1.16 =
190
+ * Date: [26.August.2021](https://superpwa.com/superpwa-2-1-16-release-note/?utm_source=wordpress.org&utm_medium=changelog)
191
+ * Bug Fixed : "Add to homescreen" banner was not showing when Wp fastest cache plugin is active #209
192
+ * Enhancement : Added an Option to Re-Install Service Worker #211
193
+ * Enhancement : Added an Option to Cache External Origin URLs by Service Worker #213
194
+
195
  = 2.1.15 =
196
  * Date: [12.July.2021](https://superpwa.com/superpwa-2-1-15-release-note/?utm_source=wordpress.org&utm_medium=changelog)
197
+ * Bug Fixed : User end issue: Apple splash icon not working properly #200
198
+ * Bug Fixed : Centralize image with background color not getting saved. #205
199
 
200
  = 2.1.14 =
201
  * Date: [30.June.2021](https://superpwa.com/superpwa-2-1-14-release-note/?utm_source=wordpress.org&utm_medium=changelog)
202
+ * Enhancement: Need to Improve Admin UI #196
203
 
204
  = 2.1.13 =
205
  * Date: [15.June.2021](https://superpwa.com/superpwa-2-1-13-release-note/?utm_source=wordpress.org&utm_medium=changelog)
206
+ * BugFixed: iOS Splash Screen Images are not getting saved #191
207
 
208
  = 2.1.12 =
209
  * Date: [29.May.2021](https://superpwa.com/superpwa-2-1-12-release-note/?utm_source=wordpress.org&utm_medium=changelog)
superpwa.php CHANGED
@@ -6,7 +6,7 @@
6
  * Author: SuperPWA
7
  * Author URI: https://profiles.wordpress.org/superpwa/
8
  * Contributors: SuperPWA
9
- * Version: 2.1.15
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.1.15' );
47
  }
48
 
49
  /**
6
  * Author: SuperPWA
7
  * Author URI: https://profiles.wordpress.org/superpwa/
8
  * Contributors: SuperPWA
9
+ * Version: 2.1.16
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.1.16' );
47
  }
48
 
49
  /**