Super Progressive Web Apps - Version 2.1.13

Version Description

  • Date: 15.June.2021 BugFixed: iOS Splash Screen Images are not getting saved #191
Download this release

Release Info

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

Code changes from version 2.1.12 to 2.1.13

Files changed (5) hide show
  1. addons/apple-touch-icons.php +28 -14
  2. admin/js/main.js +9 -7
  3. public/sw.php +2 -0
  4. readme.txt +4 -0
  5. superpwa.php +2 -2
addons/apple-touch-icons.php CHANGED
@@ -115,7 +115,7 @@ function superpwa_apple_icons_register_settings() {
115
  // Splash screen URL
116
  add_settings_field(
117
  'superpwa_apple_icons_splash_screen', // ID
118
- esc_html__('Splash Screens Image', 'super-progressive-web-apps'), // Title
119
  'superpwa_apple_icons_splash_screen_cb', // CB
120
  'superpwa_apple_icons_section', // Page slug
121
  'superpwa_apple_icons_section' // Settings Section ID
@@ -124,7 +124,7 @@ function superpwa_apple_icons_register_settings() {
124
  // Splash screen URL
125
  add_settings_field(
126
  'superpwa_apple_icons_splash_screen_center_background_color', // ID
127
- esc_html__('Center with Background Color', 'super-progressive-web-apps'), // Title
128
  'superpwa_apple_icons_splash_with_centre_screen_cb', // CB
129
  'superpwa_apple_icons_section', // Page slug
130
  'superpwa_apple_icons_section' // Settings Section ID
@@ -132,7 +132,7 @@ function superpwa_apple_icons_register_settings() {
132
  // Splash screen URL
133
  add_settings_field(
134
  'superpwa_apple_icons_splash_color_screen', // ID
135
- esc_html__('Splash Screens Background Color', 'super-progressive-web-apps'), // Title
136
  'superpwa_apple_icons_splash_color_screen_cb', // CB
137
  'superpwa_apple_icons_section', // Page slug
138
  'superpwa_apple_icons_section' // Settings Section ID
@@ -168,9 +168,11 @@ function superpwa_apple_icons_splash_screen_cb() {
168
  $src = end($iosScreenSetting['ios_splash_icon']);
169
  }
170
  ?>
 
171
  <img src="<?php echo $src; ?>" id="thumbnail" title="<?php echo esc_attr__('Currently selected splash screen', 'super-progressive-web-apps'); ?>" width="100">
172
 
173
  <script id="iosScreen-data" type="application/json"><?php echo json_encode($splashIconsScreens);?></script>
 
174
  <?php
175
  }
176
 
@@ -268,7 +270,7 @@ function superpwa_apple_icons_interface_render() {
268
  if ( isset( $_GET['settings-updated'] ) ) {
269
 
270
  // Add settings saved message with the class of "updated"
271
- add_settings_error( 'superpwa_settings_group', 'superpwa_apple_icons_settings_saved_message', __( 'Settings saved.', 'super-progressive-web-apps' ), 'updated' );
272
 
273
  // Show Settings Saved Message
274
  settings_errors( 'superpwa_settings_group' );
@@ -278,8 +280,10 @@ function superpwa_apple_icons_interface_render() {
278
 
279
  ?>
280
 
281
- <div class="wrap">
282
- <h1><?php _e( 'Apple touch icons & splash screen', 'super-progressive-web-apps' ); ?> <small><sub>(<a href="<?php echo esc_url($addon_utm_tracking['link']) . '?utm_source=superpwa-plugin&utm_medium=utm-tracking-settings'?>"><?php echo esc_html__( 'Docs', 'super-progressive-web-apps' ); ?></a>)</sub></small></h1>
 
 
283
 
284
  <form action="options.php" method="post" enctype="multipart/form-data">
285
  <?php
@@ -324,15 +328,8 @@ function superpwa_splashscreen_uploader(){
324
  WP_Filesystem();
325
  $zipFileName = $path."/splashScreen.zip";
326
  $moveFile = move_uploaded_file($_FILES['file']['tmp_name'], $zipFileName);
327
- if($moveFile){
328
  $result = unzip_file($zipFileName, $path);
329
- $file_ext = list_files($subpath);
330
- foreach ($file_ext as $key => $value) {
331
- $ext = wp_check_filetype($value);
332
- if(!in_array(strtolower($ext['ext']), array('png','html'))){
333
- unlink($value);
334
- }
335
- }
336
  unlink($zipFileName);
337
  }else{
338
  echo json_encode(array('status'=>500, 'message'=>'Files are not uploading'));die;
@@ -349,4 +346,21 @@ function superpwa_splashscreen_uploader(){
349
  echo json_encode(array("status"=>200, "message"=> "Splash screen uploaded successfully"));
350
  die;
351
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  add_action('wp_ajax_superpwa_splashscreen_uploader', 'superpwa_splashscreen_uploader');
115
  // Splash screen URL
116
  add_settings_field(
117
  'superpwa_apple_icons_splash_screen', // ID
118
+ esc_html__('Splash Screen Image', 'super-progressive-web-apps'), // Title
119
  'superpwa_apple_icons_splash_screen_cb', // CB
120
  'superpwa_apple_icons_section', // Page slug
121
  'superpwa_apple_icons_section' // Settings Section ID
124
  // Splash screen URL
125
  add_settings_field(
126
  'superpwa_apple_icons_splash_screen_center_background_color', // ID
127
+ esc_html__('Centralize Image with Background Color', 'super-progressive-web-apps'), // Title
128
  'superpwa_apple_icons_splash_with_centre_screen_cb', // CB
129
  'superpwa_apple_icons_section', // Page slug
130
  'superpwa_apple_icons_section' // Settings Section ID
132
  // Splash screen URL
133
  add_settings_field(
134
  'superpwa_apple_icons_splash_color_screen', // ID
135
+ esc_html__('Background Color', 'super-progressive-web-apps'), // Title
136
  'superpwa_apple_icons_splash_color_screen_cb', // CB
137
  'superpwa_apple_icons_section', // Page slug
138
  'superpwa_apple_icons_section' // Settings Section ID
168
  $src = end($iosScreenSetting['ios_splash_icon']);
169
  }
170
  ?>
171
+ <p id="aft_img_gen"> </p>
172
  <img src="<?php echo $src; ?>" id="thumbnail" title="<?php echo esc_attr__('Currently selected splash screen', 'super-progressive-web-apps'); ?>" width="100">
173
 
174
  <script id="iosScreen-data" type="application/json"><?php echo json_encode($splashIconsScreens);?></script>
175
+ <br/>
176
  <?php
177
  }
178
 
270
  if ( isset( $_GET['settings-updated'] ) ) {
271
 
272
  // Add settings saved message with the class of "updated"
273
+ add_settings_error( 'superpwa_settings_group', 'superpwa_apple_icons_settings_saved_message', __( 'Settings Saved.', 'super-progressive-web-apps' ), 'updated' );
274
 
275
  // Show Settings Saved Message
276
  settings_errors( 'superpwa_settings_group' );
280
 
281
  ?>
282
 
283
+ <div class="wrap">
284
+ <!--Duplicate h1 To show saved settings message above h1 tag -->
285
+ <h1 style="display: none" ><?php _e( 'Apple touch icons & Splash Screen', 'super-progressive-web-apps' ); ?> <small>(<a href="<?php echo esc_url($addon_utm_tracking['link']) . '?utm_source=superpwa-plugin&utm_medium=utm-tracking-settings'?>"><?php echo esc_html__( 'Docs', 'super-progressive-web-apps' ); ?></a>)</small></h1>
286
+ <h1><?php _e( 'Apple touch icons & Splash Screen', 'super-progressive-web-apps' ); ?> <small>(<a href="<?php echo esc_url($addon_utm_tracking['link']) . '?utm_source=superpwa-plugin&utm_medium=utm-tracking-settings'?>"><?php echo esc_html__( 'Docs', 'super-progressive-web-apps' ); ?></a>)</small></h1>
287
 
288
  <form action="options.php" method="post" enctype="multipart/form-data">
289
  <?php
328
  WP_Filesystem();
329
  $zipFileName = $path."/splashScreen.zip";
330
  $moveFile = move_uploaded_file($_FILES['file']['tmp_name'], $zipFileName);
331
+ if($moveFile && spwa_zip_allowed_extensions($zipFileName,['png'])){
332
  $result = unzip_file($zipFileName, $path);
 
 
 
 
 
 
 
333
  unlink($zipFileName);
334
  }else{
335
  echo json_encode(array('status'=>500, 'message'=>'Files are not uploading'));die;
346
  echo json_encode(array("status"=>200, "message"=> "Splash screen uploaded successfully"));
347
  die;
348
  }
349
+ function spwa_zip_allowed_extensions($zip_path, array $allowed_extensions) {
350
+ $zip = new ZipArchive;
351
+ $zip->open($zip_path);
352
+
353
+ for ($i = 0; $i < $zip->numFiles; $i++) {
354
+ $stat = $zip->statIndex( $i );
355
+ $ext = pathinfo($stat['name'], PATHINFO_EXTENSION);
356
+
357
+ // Skip folders name (but their content will be checked)
358
+ if ($ext === '' && substr($stat['name'], -1) === '/')
359
+ continue;
360
+
361
+ if (!in_array(strtolower($ext), $allowed_extensions))
362
+ return false;
363
+ }
364
+ return true;
365
+ }
366
  add_action('wp_ajax_superpwa_splashscreen_uploader', 'superpwa_splashscreen_uploader');
admin/js/main.js CHANGED
@@ -63,10 +63,6 @@ jQuery(document).ready(function($){
63
  var heading = $('.wrap').find('h1').html()
64
  $('.wrap').find('h1').html('<a href="./admin.php?page=superpwa-addons" style="text-decoration:none;color: #5b5b5d;">SuperPWA Add-ons</a> > ' + heading)
65
  }
66
- $("#submit_splash_screen").click(function(e){
67
- $('#superpwa-apple-splash-message').text("Please wait...");
68
- superpwaGetZip();
69
- });
70
  });
71
  var image = '';
72
  document.addEventListener('DOMContentLoaded', function() {
@@ -82,13 +78,15 @@ function superpwaOnFileUploadChange(e) {
82
  fr.onload = function(e) {
83
  image = e.target.result;
84
  document.getElementById('thumbnail').src = e.target.result;
85
- document.getElementById('thumbnail').style.display = 'block';
86
  };
87
  fr.readAsDataURL(file);
 
 
88
  }
89
 
90
  function superpwaGetZip() {
91
- jQuery('#superpwa-apple-splash-message').text("Please wait...");
92
  if(image==''){
93
  alert("Please Select Image"); jQuery('#superpwa-apple-splash-message').text("");
94
  return;
@@ -152,7 +150,11 @@ function superpwaGetZip() {
152
  dataType: 'json',
153
  success: function (data) {
154
  console.log(data)
155
- window.location.reload();
 
 
 
 
156
  },
157
  cache: false,
158
  contentType: false,
63
  var heading = $('.wrap').find('h1').html()
64
  $('.wrap').find('h1').html('<a href="./admin.php?page=superpwa-addons" style="text-decoration:none;color: #5b5b5d;">SuperPWA Add-ons</a> > ' + heading)
65
  }
 
 
 
 
66
  });
67
  var image = '';
68
  document.addEventListener('DOMContentLoaded', function() {
78
  fr.onload = function(e) {
79
  image = e.target.result;
80
  document.getElementById('thumbnail').src = e.target.result;
81
+ document.getElementById('thumbnail').style.display = 'none';
82
  };
83
  fr.readAsDataURL(file);
84
+ document.getElementById('aft_img_gen').innerHTML = "Generating Images Please Wait...";
85
+ setTimeout(function(){ superpwaGetZip(); }, 300);
86
  }
87
 
88
  function superpwaGetZip() {
89
+ jQuery('#aft_img_gen').text("Generating Images Please Wait...");
90
  if(image==''){
91
  alert("Please Select Image"); jQuery('#superpwa-apple-splash-message').text("");
92
  return;
150
  dataType: 'json',
151
  success: function (data) {
152
  console.log(data)
153
+ jQuery('#thumbnail').css("display", "block");
154
+ jQuery('#aft_img_gen').text("Splash Screen Images Generated Successfully");
155
+ jQuery('#aft_img_gen').css({"color":"green","margin-bottom":"20px"});
156
+ jQuery('#submit_splash_screen').trigger('click');
157
+ //window.location.reload();
158
  },
159
  cache: false,
160
  contentType: false,
public/sw.php CHANGED
@@ -370,6 +370,8 @@ function superpwa_exclude_urls_cache_sw($never_cacheurls){
370
 
371
  $exclude_from_cache = str_replace('\/endslash', '/', $exclude_from_cache);
372
 
 
 
373
  $never_cacheurls .= ','.$exclude_from_cache;
374
  }
375
 
370
 
371
  $exclude_from_cache = str_replace('\/endslash', '/', $exclude_from_cache);
372
 
373
+ $exclude_from_cache = str_replace('endslash', '', $exclude_from_cache);
374
+
375
  $never_cacheurls .= ','.$exclude_from_cache;
376
  }
377
 
readme.txt CHANGED
@@ -186,6 +186,10 @@ Feel free to get in touch if you have any questions.
186
 
187
  == Changelog ==
188
 
 
 
 
 
189
  = 2.1.12 =
190
  * Date: [29.May.2021](https://superpwa.com/superpwa-2-1-12-release-note/?utm_source=wordpress.org&utm_medium=changelog)
191
  Enhancement: Need An Option to exclude the URL #183
186
 
187
  == Changelog ==
188
 
189
+ = 2.1.13 =
190
+ * Date: [15.June.2021](https://superpwa.com/superpwa-2-1-13-release-note/?utm_source=wordpress.org&utm_medium=changelog)
191
+ BugFixed: iOS Splash Screen Images are not getting saved #191
192
+
193
  = 2.1.12 =
194
  * Date: [29.May.2021](https://superpwa.com/superpwa-2-1-12-release-note/?utm_source=wordpress.org&utm_medium=changelog)
195
  Enhancement: Need An Option to exclude the URL #183
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.12
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.12' );
47
  }
48
 
49
  /**
6
  * Author: SuperPWA
7
  * Author URI: https://profiles.wordpress.org/superpwa/
8
  * Contributors: SuperPWA
9
+ * Version: 2.1.13
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.13' );
47
  }
48
 
49
  /**