Version Description
- Date: 23.October.2021
- Bug Fixed : Resolved the issue of Invalid regular expression error when exclude cache URL is placed without end slash #216
- Bug Fixed : Added Seperate caching for range header request urls to aviod 206 type error #220
- Enhancement : Added Pre Caching Feature in Caching Strategies Addon. #222
- Enhancement : Updated License Page to display Complete License Information. #227
- Enhancement : Added Status bar style option for apple icons. #210
- Enhancement : Added Proper Method to render Application name and shortname of PWA App even with non-standard characters. #112
Download this release
Release Info
Developer | superpwa |
Plugin | Super Progressive Web Apps |
Version | 2.1.17 |
Comparing to | |
See all releases |
Code changes from version 2.1.16 to 2.1.17
- addons/apple-touch-icons.php +46 -3
- addons/caching-strategies.php +219 -1
- admin/admin-ui-render-settings.php +35 -2
- admin/admin-ui-setup.php +43 -3
- admin/js/main.js +2 -2
- admin/js/pre-cache.js +25 -0
- functions/common.php +27 -4
- public/sw.php +70 -35
- readme.txt +10 -1
- superpwa.php +2 -2
addons/apple-touch-icons.php
CHANGED
@@ -28,13 +28,20 @@ function superpwa_ati_add_apple_touch_icons( $tags ) {
|
|
28 |
$icons = superpwa_get_pwa_icons();
|
29 |
// Get settings
|
30 |
$settings = superpwa_get_settings();
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
$tags .= '<meta name="mobile-web-app-capable" content="yes">' . PHP_EOL;
|
33 |
$tags .= '<meta name="apple-touch-fullscreen" content="yes">' . PHP_EOL;
|
34 |
$tags .= '<meta name="apple-mobile-web-app-title" content="'.esc_attr($settings['app_name']).'">' . PHP_EOL;
|
35 |
$tags .= '<meta name="application-name" content="'.esc_attr($settings['app_name']).'">' . PHP_EOL;
|
36 |
$tags .= '<meta name="apple-mobile-web-app-capable" content="yes">' . PHP_EOL;
|
37 |
-
$tags .= '<meta name="apple-mobile-web-app-status-bar-style" content="
|
38 |
|
39 |
foreach( $icons as $icon ) {
|
40 |
$tags .= '<link rel="apple-touch-icon" sizes="' . $icon['sizes'] . '" href="' . $icon['src'] . '">' . PHP_EOL;
|
@@ -87,7 +94,8 @@ function superpwa_apple_icons_get_settings() {
|
|
87 |
|
88 |
$defaults = array(
|
89 |
'background_color' => '#cdcdcd',
|
90 |
-
'screen_centre_icon'=> ''
|
|
|
91 |
);
|
92 |
|
93 |
return get_option( 'superpwa_apple_icons_settings',$defaults);
|
@@ -137,6 +145,14 @@ function superpwa_apple_icons_register_settings() {
|
|
137 |
'superpwa_apple_icons_section', // Page slug
|
138 |
'superpwa_apple_icons_section' // Settings Section ID
|
139 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
add_action( 'admin_init', 'superpwa_apple_icons_register_settings' );
|
142 |
|
@@ -194,6 +210,31 @@ function superpwa_apple_icons_splash_color_screen_cb() {
|
|
194 |
<?php
|
195 |
}
|
196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
/**
|
198 |
* Apple Touch Icon & splash screen require tags data
|
199 |
*
|
@@ -253,6 +294,8 @@ function superpwa_apple_icons_validater_sanitizer( $settings ) {
|
|
253 |
|
254 |
$settings['screen_centre_icon'] = sanitize_text_field( $settings['screen_centre_icon'] ) == '' ? '' : sanitize_text_field( $settings['screen_centre_icon'] );
|
255 |
|
|
|
|
|
256 |
return $settings;
|
257 |
}
|
258 |
/**
|
28 |
$icons = superpwa_get_pwa_icons();
|
29 |
// Get settings
|
30 |
$settings = superpwa_get_settings();
|
31 |
+
|
32 |
+
$splashIcons = superpwa_apple_icons_get_settings();
|
33 |
+
|
34 |
+
if(isset($splashIcons['status_bar_style']) && !empty($splashIcons['status_bar_style'])){
|
35 |
+
$status_bar_style = $splashIcons['status_bar_style'];
|
36 |
+
}else{
|
37 |
+
$status_bar_style = 'default';
|
38 |
+
}
|
39 |
$tags .= '<meta name="mobile-web-app-capable" content="yes">' . PHP_EOL;
|
40 |
$tags .= '<meta name="apple-touch-fullscreen" content="yes">' . PHP_EOL;
|
41 |
$tags .= '<meta name="apple-mobile-web-app-title" content="'.esc_attr($settings['app_name']).'">' . PHP_EOL;
|
42 |
$tags .= '<meta name="application-name" content="'.esc_attr($settings['app_name']).'">' . PHP_EOL;
|
43 |
$tags .= '<meta name="apple-mobile-web-app-capable" content="yes">' . PHP_EOL;
|
44 |
+
$tags .= '<meta name="apple-mobile-web-app-status-bar-style" content="'.esc_attr($status_bar_style).'">' . PHP_EOL;
|
45 |
|
46 |
foreach( $icons as $icon ) {
|
47 |
$tags .= '<link rel="apple-touch-icon" sizes="' . $icon['sizes'] . '" href="' . $icon['src'] . '">' . PHP_EOL;
|
94 |
|
95 |
$defaults = array(
|
96 |
'background_color' => '#cdcdcd',
|
97 |
+
'screen_centre_icon'=> '',
|
98 |
+
'status_bar_style' => 'default'
|
99 |
);
|
100 |
|
101 |
return get_option( 'superpwa_apple_icons_settings',$defaults);
|
145 |
'superpwa_apple_icons_section', // Page slug
|
146 |
'superpwa_apple_icons_section' // Settings Section ID
|
147 |
);
|
148 |
+
// Display
|
149 |
+
add_settings_field(
|
150 |
+
'superpwa_apple_icons_status_bar_style', // ID
|
151 |
+
__('Mobile App Status Bar Style', 'super-progressive-web-apps'), // Title
|
152 |
+
'superpwa_apple_icons_status_bar_style_cb', // CB
|
153 |
+
'superpwa_apple_icons_section', // Page slug
|
154 |
+
'superpwa_apple_icons_section' // Settings Section ID
|
155 |
+
);
|
156 |
}
|
157 |
add_action( 'admin_init', 'superpwa_apple_icons_register_settings' );
|
158 |
|
210 |
<?php
|
211 |
}
|
212 |
|
213 |
+
/**
|
214 |
+
* Splash Screen Pro
|
215 |
+
*
|
216 |
+
* @since 2.1.17
|
217 |
+
*/
|
218 |
+
function superpwa_apple_icons_status_bar_style_cb() {
|
219 |
+
$splashIcons = superpwa_apple_icons_get_settings();
|
220 |
+
?>
|
221 |
+
<!-- Display Dropdown -->
|
222 |
+
<label for="superpwa_apple_icons_settings[status_bar_style]">
|
223 |
+
<select name="superpwa_apple_icons_settings[status_bar_style]" id="superpwa_apple_icons_settings[status_bar_style]">
|
224 |
+
<option value="default" <?php if ( isset( $splashIcons['status_bar_style'] ) ) { selected( $splashIcons['status_bar_style'], 'default' ); } ?>>
|
225 |
+
<?php _e( 'Default', 'super-progressive-web-apps' ); ?>
|
226 |
+
</option>
|
227 |
+
<option value="black" <?php if ( isset( $splashIcons['status_bar_style'] ) ) { selected( $splashIcons['status_bar_style'], 'black' ); } ?>>
|
228 |
+
<?php _e( 'Black', 'super-progressive-web-apps' ); ?>
|
229 |
+
</option>
|
230 |
+
<option value="black-translucent" <?php if ( isset( $splashIcons['status_bar_style'] ) ) { selected( $splashIcons['status_bar_style'], 'black-translucent' ); } ?>>
|
231 |
+
<?php _e( 'Black translucent', 'super-progressive-web-apps' ); ?>
|
232 |
+
</option>
|
233 |
+
</select>
|
234 |
+
</label>
|
235 |
+
<?php
|
236 |
+
}
|
237 |
+
|
238 |
/**
|
239 |
* Apple Touch Icon & splash screen require tags data
|
240 |
*
|
294 |
|
295 |
$settings['screen_centre_icon'] = sanitize_text_field( $settings['screen_centre_icon'] ) == '' ? '' : sanitize_text_field( $settings['screen_centre_icon'] );
|
296 |
|
297 |
+
$settings['status_bar_style'] = sanitize_text_field( $settings['status_bar_style'] ) == '' ? 'default' : sanitize_text_field( $settings['status_bar_style'] );
|
298 |
+
|
299 |
return $settings;
|
300 |
}
|
301 |
/**
|
addons/caching-strategies.php
CHANGED
@@ -19,6 +19,12 @@ function superpwa_caching_strategies_get_settings() {
|
|
19 |
|
20 |
$defaults = array(
|
21 |
'caching_type' => 'network_first',
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
);
|
23 |
|
24 |
return get_option( 'superpwa_caching_strategies_settings', $defaults );
|
@@ -105,6 +111,101 @@ function superpwa_caching_strategies_sw_template($file_string){
|
|
105 |
}
|
106 |
add_filter( 'superpwa_sw_template', 'superpwa_caching_strategies_sw_template', 10, 1 );
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
/**
|
109 |
* Todo list after saving caching_strategies settings
|
110 |
*
|
@@ -114,7 +215,7 @@ add_filter( 'superpwa_sw_template', 'superpwa_caching_strategies_sw_template', 1
|
|
114 |
* @since 1.7
|
115 |
*/
|
116 |
function superpwa_caching_strategies_save_settings_todo() {
|
117 |
-
|
118 |
// Regenerate manifest
|
119 |
superpwa_generate_sw();
|
120 |
}
|
@@ -167,6 +268,14 @@ function superpwa_caching_strategies_settings(){
|
|
167 |
'superpwa_caching_strategies_section', // Page slug
|
168 |
'superpwa_caching_strategies_section' // Settings Section ID
|
169 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
}
|
171 |
add_action( 'admin_init', 'superpwa_caching_strategies_settings' );
|
172 |
|
@@ -211,6 +320,115 @@ function superpwa_caching_strategies_caching_type_cb() {
|
|
211 |
';
|
212 |
}
|
213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
/**
|
215 |
* Caching Strategies UI renderer
|
216 |
*
|
19 |
|
20 |
$defaults = array(
|
21 |
'caching_type' => 'network_first',
|
22 |
+
'precaching_automatic' => '0',
|
23 |
+
'precaching_manual' => '0',
|
24 |
+
'precaching_automatic_post' => '0',
|
25 |
+
'precaching_automatic_page' => '0',
|
26 |
+
'precaching_post_count' => '5',
|
27 |
+
'precaching_urls' => '',
|
28 |
);
|
29 |
|
30 |
return get_option( 'superpwa_caching_strategies_settings', $defaults );
|
111 |
}
|
112 |
add_filter( 'superpwa_sw_template', 'superpwa_caching_strategies_sw_template', 10, 1 );
|
113 |
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Adding Pre Cache Urls in Service Worker Js
|
117 |
+
* @since 2.1.17
|
118 |
+
*/
|
119 |
+
function superpwa_pre_caching_urls_sw( $files_to_cache ) {
|
120 |
+
|
121 |
+
$settings = superpwa_caching_strategies_get_settings();
|
122 |
+
$pre_cache_urls = $manual_urls = '';
|
123 |
+
if(isset($settings['precaching_manual']) && $settings['precaching_manual'] == '1' && !empty($settings['precaching_urls'])){
|
124 |
+
$manual_urls = str_replace(',', '\',\'', $settings['precaching_urls']);
|
125 |
+
$files_to_cache = '\''.$manual_urls.'\','.$files_to_cache;
|
126 |
+
}
|
127 |
+
|
128 |
+
|
129 |
+
$store_post_id = array();
|
130 |
+
$store_post_id = json_decode(get_transient('superpwa_pre_cache_post_ids'));
|
131 |
+
|
132 |
+
if(!empty($store_post_id) && isset($settings['precaching_automatic']) && $settings['precaching_automatic']==1){
|
133 |
+
$files_to_cache .= ',';
|
134 |
+
foreach ($store_post_id as $post_id){
|
135 |
+
|
136 |
+
$files_to_cache .= "'".trim(get_permalink($post_id))."',\n";
|
137 |
+
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
return $files_to_cache;
|
142 |
+
}
|
143 |
+
add_filter( 'superpwa_sw_files_to_cache', 'superpwa_pre_caching_urls_sw' );
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Getting Post Ids for Automatic Pre-Caching
|
147 |
+
* @since 2.1.17
|
148 |
+
*/
|
149 |
+
|
150 |
+
add_action( 'publish_post', 'superpwa_store_latest_post_ids', 10, 2 );
|
151 |
+
add_action( 'publish_page', 'superpwa_store_latest_post_ids', 10, 2 );
|
152 |
+
|
153 |
+
function superpwa_store_latest_post_ids(){
|
154 |
+
|
155 |
+
if ( ! current_user_can( 'edit_posts' ) ) {
|
156 |
+
return;
|
157 |
+
}
|
158 |
+
|
159 |
+
$post_ids = array();
|
160 |
+
$settings = superpwa_caching_strategies_get_settings();
|
161 |
+
|
162 |
+
if(isset($settings['precaching_automatic']) && $settings['precaching_automatic']==1){
|
163 |
+
|
164 |
+
$post_count = 10;
|
165 |
+
|
166 |
+
if(isset($settings['precaching_post_count']) && $settings['precaching_post_count'] !=''){
|
167 |
+
$post_count =$settings['precaching_post_count'];
|
168 |
+
}
|
169 |
+
$post_args = array( 'numberposts' => $post_count, 'post_status'=> 'publish', 'post_type'=> 'post' );
|
170 |
+
$page_args = array( 'number' => $post_count, 'post_status'=> 'publish', 'post_type'=> 'page' );
|
171 |
+
|
172 |
+
if(isset($settings['precaching_automatic_post']) && $settings['precaching_automatic_post']==1){
|
173 |
+
$postslist = get_posts( $post_args );
|
174 |
+
if($postslist){
|
175 |
+
foreach ($postslist as $post){
|
176 |
+
$post_ids[] = $post->ID;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}else{
|
180 |
+
delete_transient('superpwa_pre_cache_post_ids');
|
181 |
+
}
|
182 |
+
|
183 |
+
if(isset($settings['precaching_automatic_page']) && $settings['precaching_automatic_page']==1){
|
184 |
+
$pageslist = get_pages( $page_args );
|
185 |
+
if($pageslist){
|
186 |
+
foreach ($pageslist as $post){
|
187 |
+
$post_ids[] = $post->ID;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}else{
|
191 |
+
delete_transient('superpwa_pre_cache_post_ids');
|
192 |
+
}
|
193 |
+
$previousIds = get_transient('superpwa_pre_cache_post_ids');
|
194 |
+
if($post_ids){
|
195 |
+
if($previousIds){
|
196 |
+
$previousIds = json_decode($previousIds);
|
197 |
+
if(array_diff($post_ids, $previousIds)){
|
198 |
+
set_transient('superpwa_pre_cache_post_ids', json_encode($post_ids));
|
199 |
+
}
|
200 |
+
}else{
|
201 |
+
set_transient('superpwa_pre_cache_post_ids', json_encode($post_ids));
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
/**
|
210 |
* Todo list after saving caching_strategies settings
|
211 |
*
|
215 |
* @since 1.7
|
216 |
*/
|
217 |
function superpwa_caching_strategies_save_settings_todo() {
|
218 |
+
|
219 |
// Regenerate manifest
|
220 |
superpwa_generate_sw();
|
221 |
}
|
268 |
'superpwa_caching_strategies_section', // Page slug
|
269 |
'superpwa_caching_strategies_section' // Settings Section ID
|
270 |
);
|
271 |
+
// Pre Caching Feature
|
272 |
+
add_settings_field(
|
273 |
+
'superpwa_caching_strategies_pre_caching', // ID
|
274 |
+
__('Pre Caching', 'super-progressive-web-apps'), // Title
|
275 |
+
'superpwa_caching_strategies_pre_caching_cb', // CB
|
276 |
+
'superpwa_caching_strategies_section', // Page slug
|
277 |
+
'superpwa_caching_strategies_section' // Settings Section ID
|
278 |
+
);
|
279 |
}
|
280 |
add_action( 'admin_init', 'superpwa_caching_strategies_settings' );
|
281 |
|
320 |
';
|
321 |
}
|
322 |
|
323 |
+
/**
|
324 |
+
* Pre Caching Callback function
|
325 |
+
*
|
326 |
+
* @since 2.1.17
|
327 |
+
*/
|
328 |
+
function superpwa_caching_strategies_pre_caching_cb() {
|
329 |
+
$cachingSettings = superpwa_caching_strategies_get_settings();
|
330 |
+
|
331 |
+
$settings = superpwa_caching_strategies_get_settings();
|
332 |
+
|
333 |
+
$arrayOPT = array(
|
334 |
+
'automatic'=>'Automatic',
|
335 |
+
'manual'=>'Manual',
|
336 |
+
);
|
337 |
+
?>
|
338 |
+
|
339 |
+
<style type="text/css">.pre-manual-suboption span {display: table-cell;margin-bottom: 9px;padding: 15px 10px;line-height: 1.3;vertical-align: middle;}.show{display: block;}.hide{display: none}
|
340 |
+
</style>
|
341 |
+
|
342 |
+
<div class="pre-cache-main">
|
343 |
+
<div class="pre-cache-automatic">
|
344 |
+
<div class="pre-automatic-checkbox" style="margin-bottom: 10px;">
|
345 |
+
<input type="checkbox" name="superpwa_caching_strategies_settings[precaching_automatic]" id="precaching_automatic" class="" <?php echo (isset( $settings['precaching_automatic'] ) && $settings['precaching_automatic'] == 1 ? 'checked="checked"' : ''); ?> data-uncheck-val="0" value="1">
|
346 |
+
|
347 |
+
<strong><?php echo esc_html__('Automatic', 'super-progressive-web-apps'); ?></strong>
|
348 |
+
<!-- <span class="pwafw-tooltip"><i class="dashicons dashicons-editor-help"></i>
|
349 |
+
<span class="pwafw-help-subtitle"><a href="https://pwa-for-wp.com/docs/article/setting-up-precaching-in-pwa/"><?php //echo esc_html__('For details click here', 'pwa-for-wp'); ?></a></span>
|
350 |
+
</span> -->
|
351 |
+
</div>
|
352 |
+
<div id="pre-automatic-suboption" class="pre-automatic-suboption <?php echo (isset( $settings['precaching_automatic'] ) && $settings['precaching_automatic'] == 1 ? ' show' : ' hide'); ?>" style="margin-bottom: 30px;margin-left: 40px;">
|
353 |
+
<table class="pre-automatic-cache-table" style="margin-bottom: 12px;">
|
354 |
+
<tr>
|
355 |
+
<td>
|
356 |
+
<?php echo esc_html__('Post', 'super-progressive-web-apps') ?>
|
357 |
+
</td>
|
358 |
+
<td>
|
359 |
+
<input type="checkbox" name="superpwa_caching_strategies_settings[precaching_automatic_post]" id="superpwa_settings_precaching_automatic_post" class="" <?php echo (isset( $settings['precaching_automatic_post'] ) && $settings['precaching_automatic_post'] == 1 ? 'checked="checked"' : ''); ?> data-uncheck-val="0" value="1">
|
360 |
+
</td>
|
361 |
+
<td>
|
362 |
+
<?php echo esc_html__('Page', 'super-progressive-web-apps') ?>
|
363 |
+
</td>
|
364 |
+
<td>
|
365 |
+
<input type="checkbox" name="superpwa_caching_strategies_settings[precaching_automatic_page]" id="superpwa_settings_precaching_automatic_page" class="" <?php echo (isset( $settings['precaching_automatic_page'] ) && $settings['precaching_automatic_page'] == 1 ? 'checked="checked"' : ''); ?> data-uncheck-val="0" value="1">
|
366 |
+
</td>
|
367 |
+
<td>
|
368 |
+
<?php echo esc_html__('Custom Post', 'super-progressive-web-apps') ?>
|
369 |
+
</td>
|
370 |
+
<td>
|
371 |
+
<input type="checkbox" name="superpwa_caching_strategies_settings[precaching_automatic_custom_post]" id="superpwa_settings_precaching_automatic_custom_post" class="" <?php echo (isset( $settings['precaching_automatic_custom_post'] ) && $settings['precaching_automatic_custom_post'] == 1 ? 'checked="checked"' : ''); ?> data-uncheck-val="0" value="1">
|
372 |
+
</td>
|
373 |
+
</tr>
|
374 |
+
|
375 |
+
</table>
|
376 |
+
|
377 |
+
<span style="margin-left: 12px;"><strong><?php echo esc_html__('Enter Post Count', 'super-progressive-web-apps'); ?></strong></span>
|
378 |
+
<span style="margin-left: 14px;">
|
379 |
+
<input id="superpwa_settings_precaching_post_count" name="superpwa_caching_strategies_settings[precaching_post_count]" value="<?php if(isset($settings['precaching_post_count'])){ echo esc_attr($settings['precaching_post_count']);} ?>" type="number" min="0">
|
380 |
+
</span>
|
381 |
+
</div>
|
382 |
+
</div> <!-- automatic wrap ends here -->
|
383 |
+
|
384 |
+
|
385 |
+
|
386 |
+
<div class="pre-cache-manual" style="margin-top: 20px;">
|
387 |
+
<div class="pre-manual-checkbox" style="margin-bottom: 10px;">
|
388 |
+
<input type="checkbox" name="superpwa_caching_strategies_settings[precaching_manual]" id="precaching_manual" class="" <?php echo (isset( $settings['precaching_manual'] ) && $settings['precaching_manual'] == 1 ? 'checked="checked"' : ''); ?> data-uncheck-val="0" value="1">
|
389 |
+
|
390 |
+
<strong><?php echo esc_html__('Manual', 'super-progressive-web-apps'); ?></strong>
|
391 |
+
<!-- <span class="pwafw-tooltip"><i class="dashicons dashicons-editor-help"></i>
|
392 |
+
<span class="pwafw-help-subtitle"><a href="https://pwa-for-wp.com/docs/article/setting-up-precaching-in-pwa/"><?php //echo esc_html__('For details click here', 'pwa-for-wp'); ?></a></span>
|
393 |
+
</span> -->
|
394 |
+
|
395 |
+
</div>
|
396 |
+
<div id="pre-manual-suboption" class="pre-manual-suboption <?php echo (isset( $settings['precaching_manual'] ) && $settings['precaching_manual'] == 1 ? ' show' : ' hide'); ?>" style="margin-left: 45px;">
|
397 |
+
<span class="pre-manual-label"> <strong> <?php echo esc_html__('Enter Urls To Be Cached', 'super-progressive-web-apps'); ?> </strong></span>
|
398 |
+
<span class="pre-manual-textarea">
|
399 |
+
<label><textarea placeholder="https://example.com/2019/06/06/hello-world/, https://example.com/2019/06/06/hello-world-2/ " rows="4" cols="50" id="superpwa_settings_precaching_urls" name="superpwa_caching_strategies_settings[precaching_urls]"><?php if(isset($settings['precaching_urls'])){ echo esc_attr($settings['precaching_urls']);} ?></textarea></label>
|
400 |
+
<p><?php echo esc_html__('Note: Seperate the URLs using Comma(,)', 'super-progressive-web-apps'); ?></p>
|
401 |
+
<p><?php echo esc_html__('Place the list of URLs which you want to pre cache by service worker', 'super-progressive-web-apps'); ?></p>
|
402 |
+
</span>
|
403 |
+
</div>
|
404 |
+
|
405 |
+
</div> <!-- Manual wrap ends here -->
|
406 |
+
</div> <!-- Main wrap ends here -->
|
407 |
+
|
408 |
+
|
409 |
+
|
410 |
+
<?php
|
411 |
+
|
412 |
+
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Caching Strategies Admin Scripts
|
416 |
+
*
|
417 |
+
* @since 2.1.17
|
418 |
+
*/
|
419 |
+
|
420 |
+
function superpwa_precache_load_admin_scripts($hooks){
|
421 |
+
if( !in_array($hooks, array('superpwa_page_superpwa-caching-strategies', 'super-pwa_page_superpwa-caching-strategies')) ) {
|
422 |
+
return false;
|
423 |
+
}
|
424 |
+
|
425 |
+
wp_register_script('superpwa-admin-precache-script',SUPERPWA_PATH_SRC .'/admin/js/pre-cache.js', array('superpwa-main-js'), SUPERPWA_VERSION, true);
|
426 |
+
|
427 |
+
wp_enqueue_script('superpwa-admin-precache-script');
|
428 |
+
|
429 |
+
}
|
430 |
+
add_action( 'admin_enqueue_scripts', 'superpwa_precache_load_admin_scripts' );
|
431 |
+
|
432 |
/**
|
433 |
* Caching Strategies UI renderer
|
434 |
*
|
admin/admin-ui-render-settings.php
CHANGED
@@ -555,6 +555,22 @@ function superpwa_admin_interface_render() {
|
|
555 |
<style type="text/css">.spwa-tab {overflow: hidden;border: 1px solid #ccc;background-color: #fff;margin-top: 15px;}.spwa-tab a {background-color: inherit;text-decoration: none;float: left;border: none;outline: none;cursor: pointer;padding: 14px 16px;transition: 0s;font-size: 15px;color: #2271b1;}.spwa-tab a:hover {color: #0a4b78;}.spwa-tab a.active {box-shadow: none;border-bottom: 4px solid #646970;color: #1d2327;}.spwa-tab a:focus {box-shadow: none;outline: none;}.spwa-tabcontent {display: none;padding: 6px 12px;border-top: none; animation: fadeEffect 1s; }p.support-cont {font-size: 14px;font-weight: 500;color: #646970;}#support{margin-top: 1em;} @keyframes fadeEffect { from {opacity: 0;} to {opacity: 1;} }</style>
|
556 |
|
557 |
<div class="wrap">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
<h1>Super Progressive Web Apps <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
|
559 |
|
560 |
<form action="options.php" method="post" enctype="multipart/form-data">
|
@@ -565,9 +581,13 @@ function superpwa_admin_interface_render() {
|
|
565 |
?>
|
566 |
<div class="spwa-tab">
|
567 |
<a id="spwa-default" class="spwa-tablinks" data-href="no" href="#general-settings" onclick="openCity(event, 'settings')">Settings</a>
|
568 |
-
<a class="spwa-tablinks" id="spwa-feature" href="<?php echo $addon_page; ?>" data-href="yes">
|
569 |
<a class="spwa-tablinks" id="spwa-advance" href="#advance-settings" onclick="openCity(event, 'advance')" data-href="no">Advanced</a>
|
570 |
<a class="spwa-tablinks" id="spwa-support" href="#support-settings" onclick="openCity(event, 'support')" data-href="no">Help & Support</a>
|
|
|
|
|
|
|
|
|
571 |
</div>
|
572 |
<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>
|
573 |
<div id="settings" class="spwa-tabcontent">
|
@@ -616,7 +636,18 @@ function superpwa_admin_interface_render() {
|
|
616 |
<h1>4) Report a Bug</h1>
|
617 |
<p class="support-cont">If you found any bug or having issues with any third party plugins you can contact us <b><a href="https://superpwa.com/contact/" target="_blank">Bug Report</a></b></p>
|
618 |
</div>
|
619 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
620 |
</div>
|
621 |
<?php superpwa_newsletter_form(); ?>
|
622 |
<script type="text/javascript">function openCity(evt, cityName) {var i, tabcontent, tablinks;tabcontent = document.getElementsByClassName("spwa-tabcontent");for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("spwa-tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " active"; }
|
@@ -625,6 +656,8 @@ function superpwa_admin_interface_render() {
|
|
625 |
document.getElementById("spwa-advance").click();
|
626 |
}else if(url.indexOf('#support-settings') > -1){
|
627 |
document.getElementById("spwa-support").click();
|
|
|
|
|
628 |
}else{
|
629 |
document.getElementById("spwa-default").click();
|
630 |
}
|
555 |
<style type="text/css">.spwa-tab {overflow: hidden;border: 1px solid #ccc;background-color: #fff;margin-top: 15px;}.spwa-tab a {background-color: inherit;text-decoration: none;float: left;border: none;outline: none;cursor: pointer;padding: 14px 16px;transition: 0s;font-size: 15px;color: #2271b1;}.spwa-tab a:hover {color: #0a4b78;}.spwa-tab a.active {box-shadow: none;border-bottom: 4px solid #646970;color: #1d2327;}.spwa-tab a:focus {box-shadow: none;outline: none;}.spwa-tabcontent {display: none;padding: 6px 12px;border-top: none; animation: fadeEffect 1s; }p.support-cont {font-size: 14px;font-weight: 500;color: #646970;}#support{margin-top: 1em;} @keyframes fadeEffect { from {opacity: 0;} to {opacity: 1;} }</style>
|
556 |
|
557 |
<div class="wrap">
|
558 |
+
<?php
|
559 |
+
if ( defined('SUPERPWA_PRO_VERSION') ) {
|
560 |
+
wp_enqueue_script('superpwa-pro-admin', trailingslashit(SUPERPWA_PRO_PATH_SRC).'assets/js/admin.js', array('jquery'), SUPERPWA_PRO_VERSION, true);
|
561 |
+
$array = array('security_nonce'=>wp_create_nonce('superpwa_pro_post_nonce'));
|
562 |
+
wp_localize_script('superpwa-pro-admin', 'superpwa_pro_var', $array);
|
563 |
+
$license_info = get_option("superpwa_pro_upgrade_license");
|
564 |
+
if ( defined('SUPERPWA_PRO_PLUGIN_DIR_NAME') && !empty($license_info) ){
|
565 |
+
$superpwa_pro_manager = SUPERPWA_PRO_PLUGIN_DIR_NAME.'/assets/inc/superpwa-pro-license-data.php';
|
566 |
+
if( file_exists($superpwa_pro_manager) ){
|
567 |
+
require_once $superpwa_pro_manager;
|
568 |
+
if( $_GET['page'] == 'superpwa' ) {
|
569 |
+
wp_enqueue_style( 'superpwa-license-panel-css', SUPERPWA_PRO_PATH_SRC . '/assets/inc/css/superpwa-pro-license-data.css', array() , SUPERPWA_PRO_VERSION );
|
570 |
+
}
|
571 |
+
}
|
572 |
+
}
|
573 |
+
} ?>
|
574 |
<h1>Super Progressive Web Apps <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
|
575 |
|
576 |
<form action="options.php" method="post" enctype="multipart/form-data">
|
581 |
?>
|
582 |
<div class="spwa-tab">
|
583 |
<a id="spwa-default" class="spwa-tablinks" data-href="no" href="#general-settings" onclick="openCity(event, 'settings')">Settings</a>
|
584 |
+
<a class="spwa-tablinks" id="spwa-feature" href="<?php echo $addon_page; ?>" data-href="yes">Features (Addons)</a>
|
585 |
<a class="spwa-tablinks" id="spwa-advance" href="#advance-settings" onclick="openCity(event, 'advance')" data-href="no">Advanced</a>
|
586 |
<a class="spwa-tablinks" id="spwa-support" href="#support-settings" onclick="openCity(event, 'support')" data-href="no">Help & Support</a>
|
587 |
+
<?php if( defined('SUPERPWA_PRO_VERSION') ){ ?>
|
588 |
+
<!-- <a class="spwa-tablinks" id="spwa-license" href="<?php echo admin_url('admin.php?page=superpwa-upgrade')?> " data-href="no">License</a> -->
|
589 |
+
<a class="spwa-tablinks" id="spwa-license" href="#license-settings" onclick="openCity(event, 'superpwa_pro_license')" data-href="no">License</a>
|
590 |
+
<?php } ?>
|
591 |
</div>
|
592 |
<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>
|
593 |
<div id="settings" class="spwa-tabcontent">
|
636 |
<h1>4) Report a Bug</h1>
|
637 |
<p class="support-cont">If you found any bug or having issues with any third party plugins you can contact us <b><a href="https://superpwa.com/contact/" target="_blank">Bug Report</a></b></p>
|
638 |
</div>
|
639 |
+
|
640 |
+
<div id="superpwa_pro_license" class="spwa-tabcontent">
|
641 |
+
|
642 |
+
<?php
|
643 |
+
if ( function_exists('superpwa_pro_upgrade_license_page') ) {
|
644 |
+
superpwa_pro_upgrade_license_page();
|
645 |
+
}
|
646 |
+
?>
|
647 |
+
|
648 |
+
</div>
|
649 |
+
|
650 |
+
</form>
|
651 |
</div>
|
652 |
<?php superpwa_newsletter_form(); ?>
|
653 |
<script type="text/javascript">function openCity(evt, cityName) {var i, tabcontent, tablinks;tabcontent = document.getElementsByClassName("spwa-tabcontent");for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("spwa-tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " active"; }
|
656 |
document.getElementById("spwa-advance").click();
|
657 |
}else if(url.indexOf('#support-settings') > -1){
|
658 |
document.getElementById("spwa-support").click();
|
659 |
+
}else if(url.indexOf('#license-settings') > -1){
|
660 |
+
document.getElementById("spwa-license").click();
|
661 |
}else{
|
662 |
document.getElementById("spwa-default").click();
|
663 |
}
|
admin/admin-ui-setup.php
CHANGED
@@ -50,8 +50,39 @@ function superpwa_add_menu_links() {
|
|
50 |
|
51 |
// Upgrade to pro page
|
52 |
$textlicense = "<span style='color: #ff4c4c;font-weight: 700;font-size: 15px;'>".__( 'Upgrade to Pro', 'super-progressive-web-apps' )."</span>";
|
53 |
-
if(defined('SUPERPWA_PRO_VERSION')){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), $textlicense, 'manage_options', 'superpwa-upgrade', 'superpwa_upgread_pro_interface_render' , 9999999);
|
|
|
55 |
|
56 |
}
|
57 |
add_action( 'admin_menu', 'superpwa_add_menu_links' );
|
@@ -301,7 +332,11 @@ function superpwa_validater_and_sanitizer( $settings ) {
|
|
301 |
$settings['app_name'] = sanitize_text_field( $settings['app_name'] ) == '' ? get_bloginfo( 'name' ) : sanitize_text_field( $settings['app_name'] );
|
302 |
|
303 |
// Sanitize Application Short Name
|
304 |
-
|
|
|
|
|
|
|
|
|
305 |
|
306 |
// Sanitize description
|
307 |
$settings['description'] = sanitize_text_field( $settings['description'] );
|
@@ -354,7 +389,7 @@ function superpwa_get_settings() {
|
|
354 |
|
355 |
$defaults = array(
|
356 |
'app_name' => get_bloginfo( 'name' ),
|
357 |
-
'app_short_name' => substr( get_bloginfo( 'name' ), 0, 15 ),
|
358 |
'description' => get_bloginfo( 'description' ),
|
359 |
'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
|
360 |
'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
|
@@ -418,6 +453,11 @@ function superpwa_enqueue_css_js( $hook ) {
|
|
418 |
|
419 |
// Main JS
|
420 |
wp_enqueue_script( 'superpwa-main-js', SUPERPWA_PATH_SRC . 'admin/js/main.js', array( 'wp-color-picker' ), SUPERPWA_VERSION, true );
|
|
|
|
|
|
|
|
|
|
|
421 |
}
|
422 |
add_action( 'admin_enqueue_scripts', 'superpwa_enqueue_css_js' );
|
423 |
|
50 |
|
51 |
// Upgrade to pro page
|
52 |
$textlicense = "<span style='color: #ff4c4c;font-weight: 700;font-size: 15px;'>".__( 'Upgrade to Pro', 'super-progressive-web-apps' )."</span>";
|
53 |
+
if( defined('SUPERPWA_PRO_VERSION') ){
|
54 |
+
|
55 |
+
$license_alert = $days = '';
|
56 |
+
$license_info = get_option("superpwa_pro_upgrade_license");
|
57 |
+
if (isset($license_info)) {
|
58 |
+
|
59 |
+
$license_exp = date('Y-m-d', strtotime($license_info['pro']['license_key_expires']));
|
60 |
+
$license_info_lifetime = $license_info['pro']['license_key_expires'];
|
61 |
+
$today = date('Y-m-d');
|
62 |
+
$exp_date = $license_exp;
|
63 |
+
$date1 = date_create($today);
|
64 |
+
$date2 = date_create($exp_date);
|
65 |
+
$diff = date_diff($date1,$date2);
|
66 |
+
$days = $diff->format("%a");
|
67 |
+
if( $license_info_lifetime == 'lifetime' ){
|
68 |
+
$days = 'Lifetime';
|
69 |
+
if ($days == 'Lifetime') {
|
70 |
+
$expire_msg = " Your License is Valid for Lifetime ";
|
71 |
+
}
|
72 |
+
}
|
73 |
+
else if($today > $exp_date){
|
74 |
+
$days = -$days;
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
$license_alert = isset($days) && $days!==0 && $days<=30 && $days!=='Lifetime' ? "<span class='superpwa_pro_icon dashicons dashicons-warning superpwa_pro_alert' style='color: #ffb229;left: 3px;position: relative;'></span>": "" ;
|
80 |
+
$textlicense = __( 'License', 'super-progressive-web-apps' );
|
81 |
+
|
82 |
+
add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), $textlicense.$license_alert, 'manage_options', 'superpwa#license-settings', 'superpwa_upgread_pro_interface_render' , 9999999);
|
83 |
+
}else{
|
84 |
add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), $textlicense, 'manage_options', 'superpwa-upgrade', 'superpwa_upgread_pro_interface_render' , 9999999);
|
85 |
+
}
|
86 |
|
87 |
}
|
88 |
add_action( 'admin_menu', 'superpwa_add_menu_links' );
|
332 |
$settings['app_name'] = sanitize_text_field( $settings['app_name'] ) == '' ? get_bloginfo( 'name' ) : sanitize_text_field( $settings['app_name'] );
|
333 |
|
334 |
// Sanitize Application Short Name
|
335 |
+
if(function_exists('mb_substr')){
|
336 |
+
$settings['app_short_name'] = mb_substr( sanitize_text_field( $settings['app_short_name'] ) == '' ? get_bloginfo( 'name' ) : sanitize_text_field( $settings['app_short_name'] ), 0, 15 );
|
337 |
+
} else {
|
338 |
+
$settings['app_short_name'] = substr( sanitize_text_field( $settings['app_short_name'] ) == '' ? get_bloginfo( 'name' ) : sanitize_text_field( $settings['app_short_name'] ), 0, 15 );
|
339 |
+
}
|
340 |
|
341 |
// Sanitize description
|
342 |
$settings['description'] = sanitize_text_field( $settings['description'] );
|
389 |
|
390 |
$defaults = array(
|
391 |
'app_name' => get_bloginfo( 'name' ),
|
392 |
+
'app_short_name' => function_exists('mb_substr') ? mb_substr( get_bloginfo( 'name' ), 0, 15 ) : substr( get_bloginfo( 'name' ), 0, 15 ),
|
393 |
'description' => get_bloginfo( 'description' ),
|
394 |
'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
|
395 |
'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
|
453 |
|
454 |
// Main JS
|
455 |
wp_enqueue_script( 'superpwa-main-js', SUPERPWA_PATH_SRC . 'admin/js/main.js', array( 'wp-color-picker' ), SUPERPWA_VERSION, true );
|
456 |
+
if( defined('SUPERPWA_PRO_VERSION') ){
|
457 |
+
if ($hook == 'toplevel_page_superpwa') {
|
458 |
+
wp_enqueue_style('superpwa-admin-panel-css', SUPERPWA_PATH_SRC . 'admin/css/admin-panel.css', array(), SUPERPWA_PRO_VERSION, 'all');
|
459 |
+
}
|
460 |
+
}
|
461 |
}
|
462 |
add_action( 'admin_enqueue_scripts', 'superpwa_enqueue_css_js' );
|
463 |
|
admin/js/main.js
CHANGED
@@ -185,9 +185,9 @@ function superpwaGetZip() {
|
|
185 |
if(input_tag){
|
186 |
for(var h=0; h<input_tag.length;h++ ){
|
187 |
input_tag[h].addEventListener( 'change', function(e) {
|
188 |
-
console.log(changes);
|
189 |
changes = true;
|
190 |
-
|
191 |
});
|
192 |
}
|
193 |
}
|
185 |
if(input_tag){
|
186 |
for(var h=0; h<input_tag.length;h++ ){
|
187 |
input_tag[h].addEventListener( 'change', function(e) {
|
188 |
+
//console.log(changes);
|
189 |
changes = true;
|
190 |
+
// console.log(changes);
|
191 |
});
|
192 |
}
|
193 |
}
|
admin/js/pre-cache.js
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($){
|
2 |
+
$('#precaching_automatic').click(function(e){
|
3 |
+
|
4 |
+
if(e.target.checked == true){
|
5 |
+
// Code in the case checkbox is checked.
|
6 |
+
console.log('checked');
|
7 |
+
$('#pre-automatic-suboption').removeClass('hide').addClass('show');
|
8 |
+
} else {
|
9 |
+
// Code in the case checkbox is NOT checked.
|
10 |
+
$('#pre-automatic-suboption').removeClass('show').addClass('hide');
|
11 |
+
}
|
12 |
+
});
|
13 |
+
|
14 |
+
$('#precaching_manual').click(function(e){
|
15 |
+
|
16 |
+
if(e.target.checked == true){
|
17 |
+
// Code in the case checkbox is checked.
|
18 |
+
$('#pre-manual-suboption').removeClass('hide').addClass('show');
|
19 |
+
} else {
|
20 |
+
// Code in the case checkbox is NOT checked.
|
21 |
+
$('#pre-manual-suboption').removeClass('show').addClass('hide');
|
22 |
+
}
|
23 |
+
});
|
24 |
+
|
25 |
+
});
|
functions/common.php
CHANGED
@@ -249,13 +249,36 @@ function superpwa_setting_tabs_html(){
|
|
249 |
$general_settings = admin_url( 'admin.php?page=superpwa#general-settings');
|
250 |
$advance_settings = admin_url( 'admin.php?page=superpwa#advance-settings');
|
251 |
$support_settings = admin_url( 'admin.php?page=superpwa#support-settings');
|
252 |
-
|
253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
<div class="spwa-tab">
|
255 |
<a id="spwa-default" class="spwa-tablinks" href="<?php echo esc_url_raw($general_settings); ?>" data-href="yes">Settings</a>
|
256 |
-
<a class="spwa-tablinks
|
257 |
<a class="spwa-tablinks" href="<?php echo esc_url_raw($advance_settings); ?>" data-href="yes">Advanced</a>
|
258 |
<a class="spwa-tablinks" href="<?php echo esc_url_raw($support_settings); ?>" data-href="yes">Help & Support</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
</div>
|
260 |
<?php
|
261 |
}
|
@@ -264,7 +287,7 @@ function superpwa_setting_tabs_html(){
|
|
264 |
*/
|
265 |
function superpwa_setting_tabs_styles(){
|
266 |
?>
|
267 |
-
<style type="text/css">.spwa-tab {overflow: hidden;border: 1px solid #ccc;background-color: #fff;margin-top: 15px;margin-bottom:
|
268 |
<?php
|
269 |
}
|
270 |
/**
|
249 |
$general_settings = admin_url( 'admin.php?page=superpwa#general-settings');
|
250 |
$advance_settings = admin_url( 'admin.php?page=superpwa#advance-settings');
|
251 |
$support_settings = admin_url( 'admin.php?page=superpwa#support-settings');
|
252 |
+
$license_settings = admin_url( 'admin.php?page=superpwa#license-settings');
|
253 |
+
$addon_page = admin_url( 'admin.php?page=superpwa-addons');
|
254 |
+
if( $_GET['page'] == 'superpwa-upgrade' ) {
|
255 |
+
$license_settings_class = $addon_page_class = '' ;
|
256 |
+
if( isset( $_GET['page'] ) && $_GET['page'] == 'superpwa-upgrade' ) {
|
257 |
+
$license_settings_class = 'active';
|
258 |
+
}else{
|
259 |
+
$addon_page_class = 'active';
|
260 |
+
}
|
261 |
+
}
|
262 |
+
if( $_GET['page'] == 'superpwa-addons' ) {
|
263 |
+
$license_settings_class = $addon_page_class = '' ;
|
264 |
+
if( isset( $_GET['page'] ) && $_GET['page'] == 'superpwa-upgrade' ) {
|
265 |
+
$license_settings_class = 'active';
|
266 |
+
}else{
|
267 |
+
$addon_page_class = 'active';
|
268 |
+
}
|
269 |
+
} ?>
|
270 |
<div class="spwa-tab">
|
271 |
<a id="spwa-default" class="spwa-tablinks" href="<?php echo esc_url_raw($general_settings); ?>" data-href="yes">Settings</a>
|
272 |
+
<a class="spwa-tablinks <?php echo $addon_page_class; ?>" href="<?php echo esc_url_raw($addon_page); ?>" data-href="yes">Features (Addons)</a>
|
273 |
<a class="spwa-tablinks" href="<?php echo esc_url_raw($advance_settings); ?>" data-href="yes">Advanced</a>
|
274 |
<a class="spwa-tablinks" href="<?php echo esc_url_raw($support_settings); ?>" data-href="yes">Help & Support</a>
|
275 |
+
<?php if( defined('SUPERPWA_PRO_VERSION') && $_GET['page'] !== 'superpwa-upgrade' ) { ?>
|
276 |
+
<a class="spwa-tablinks" href="<?php echo esc_url_raw($license_settings); ?>" data-href="yes">License</a>
|
277 |
+
<?php } ?>
|
278 |
+
<?php if( $_GET['page'] == 'superpwa-upgrade' ) { ?>
|
279 |
+
<a class="spwa-tablinks <?php echo $license_settings_class; ?> " href="<?php echo esc_url_raw($license_settings); ?>" data-href="yes">License</a>
|
280 |
+
<?php } ?>
|
281 |
+
|
282 |
</div>
|
283 |
<?php
|
284 |
}
|
287 |
*/
|
288 |
function superpwa_setting_tabs_styles(){
|
289 |
?>
|
290 |
+
<style type="text/css">.spwa-tab {overflow: hidden;border: 1px solid #ccc;background-color: #fff;margin-top: 15px;margin-bottom: 6px;}.spwa-tab a {background-color: inherit;text-decoration: none;float: left;border: none;outline: none;cursor: pointer;padding: 14px 16px;transition: 0s;font-size: 15px;color: #2271b1;}.spwa-tab a:hover {color: #0a4b78;}.spwa-tab a.active {box-shadow: none;border-bottom: 4px solid #646970;color: #1d2327;}.spwa-tab a:focus {box-shadow: none;outline: none;}.spwa-tabcontent {display: none;padding: 6px 12px;border-top: none; animation: fadeEffect 1s; } @keyframes fadeEffect { from {opacity: 0;} to {opacity: 1;} }</style>
|
291 |
<?php
|
292 |
}
|
293 |
/**
|
public/sw.php
CHANGED
@@ -210,6 +210,36 @@ self.addEventListener('activate', function(e) {
|
|
210 |
return self.clients.claim();
|
211 |
});
|
212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
// Fetch
|
214 |
self.addEventListener('fetch', function(e) {
|
215 |
|
@@ -228,41 +258,46 @@ self.addEventListener('fetch', function(e) {
|
|
228 |
if ( new URL(e.request.url).origin !== location.origin )
|
229 |
return;
|
230 |
<?php } ?>
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
|
|
|
|
|
|
|
|
253 |
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
266 |
});
|
267 |
|
268 |
// Check if current url is in the neverCacheUrls list
|
@@ -380,7 +415,7 @@ function superpwa_exclude_urls_cache_sw($never_cacheurls){
|
|
380 |
|
381 |
$exclude_from_cache = str_replace('\/endslash', '/', $exclude_from_cache);
|
382 |
|
383 |
-
$exclude_from_cache = str_replace('endslash', '', $exclude_from_cache);
|
384 |
|
385 |
$never_cacheurls .= ','.$exclude_from_cache;
|
386 |
}
|
210 |
return self.clients.claim();
|
211 |
});
|
212 |
|
213 |
+
// Range Data Code
|
214 |
+
var fetchRangeData = function(event){
|
215 |
+
var pos = Number(/^bytes\=(\d+)\-$/g.exec(event.request.headers.get('range'))[1]);
|
216 |
+
console.log('Range request for', event.request.url, ', starting position:', pos);
|
217 |
+
event.respondWith(
|
218 |
+
caches.open(cacheName)
|
219 |
+
.then(function(cache) {
|
220 |
+
return cache.match(event.request.url);
|
221 |
+
}).then(function(res) {
|
222 |
+
if (!res) {
|
223 |
+
return fetch(event.request)
|
224 |
+
.then(res => {
|
225 |
+
return res.arrayBuffer();
|
226 |
+
});
|
227 |
+
}
|
228 |
+
return res.arrayBuffer();
|
229 |
+
}).then(function(ab) {
|
230 |
+
return new Response(
|
231 |
+
ab.slice(pos),
|
232 |
+
{
|
233 |
+
status: 206,
|
234 |
+
statusText: 'Partial Content',
|
235 |
+
headers: [
|
236 |
+
// ['Content-Type', 'video/webm'],
|
237 |
+
['Content-Range', 'bytes ' + pos + '-' +
|
238 |
+
(ab.byteLength - 1) + '/' + ab.byteLength]]
|
239 |
+
});
|
240 |
+
}));
|
241 |
+
}
|
242 |
+
|
243 |
// Fetch
|
244 |
self.addEventListener('fetch', function(e) {
|
245 |
|
258 |
if ( new URL(e.request.url).origin !== location.origin )
|
259 |
return;
|
260 |
<?php } ?>
|
261 |
+
// For Range Headers
|
262 |
+
if (e.request.headers.get('range')) {
|
263 |
+
fetchRangeData(e);
|
264 |
+
} else {
|
265 |
+
// For POST requests, do not use the cache. Serve offline page if offline.
|
266 |
+
if ( e.request.method !== 'GET' ) {
|
267 |
+
e.respondWith(
|
268 |
+
fetch(e.request).catch( function() {
|
269 |
+
return caches.match(offlinePage);
|
270 |
+
})
|
271 |
+
);
|
272 |
+
return;
|
273 |
+
}
|
274 |
+
|
275 |
+
// Revving strategy
|
276 |
+
if ( e.request.mode === 'navigate' && navigator.onLine ) {
|
277 |
+
e.respondWith(
|
278 |
+
fetch(e.request).then(function(response) {
|
279 |
+
return caches.open(cacheName).then(function(cache) {
|
280 |
+
cache.put(e.request, response.clone());
|
281 |
+
return response;
|
282 |
+
});
|
283 |
+
})
|
284 |
+
);
|
285 |
+
return;
|
286 |
+
}
|
287 |
|
288 |
+
e.respondWith(
|
289 |
+
caches.match(e.request).then(function(response) {
|
290 |
+
return response || fetch(e.request).then(function(response) {
|
291 |
+
return caches.open(cacheName).then(function(cache) {
|
292 |
+
cache.put(e.request, response.clone());
|
293 |
+
return response;
|
294 |
+
});
|
295 |
+
});
|
296 |
+
}).catch(function() {
|
297 |
+
return caches.match(offlinePage);
|
298 |
+
})
|
299 |
+
);
|
300 |
+
}
|
301 |
});
|
302 |
|
303 |
// Check if current url is in the neverCacheUrls list
|
415 |
|
416 |
$exclude_from_cache = str_replace('\/endslash', '/', $exclude_from_cache);
|
417 |
|
418 |
+
$exclude_from_cache = str_replace('endslash', '/', $exclude_from_cache);
|
419 |
|
420 |
$never_cacheurls .= ','.$exclude_from_cache;
|
421 |
}
|
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.8
|
6 |
Requires PHP: 5.3
|
7 |
Stable tag: trunk
|
8 |
License: GPLv2 or later
|
@@ -186,6 +186,15 @@ Feel free to get in touch if you have any questions.
|
|
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
|
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.1
|
6 |
Requires PHP: 5.3
|
7 |
Stable tag: trunk
|
8 |
License: GPLv2 or later
|
186 |
|
187 |
== Changelog ==
|
188 |
|
189 |
+
= 2.1.17 =
|
190 |
+
* Date: [23.October.2021](https://superpwa.com/superpwa-2-1-17-release-note/?utm_source=wordpress.org&utm_medium=changelog)
|
191 |
+
* Bug Fixed : Resolved the issue of Invalid regular expression error when exclude cache URL is placed without end slash #216
|
192 |
+
* Bug Fixed : Added Seperate caching for range header request urls to aviod 206 type error #220
|
193 |
+
* Enhancement : Added Pre Caching Feature in Caching Strategies Addon. #222
|
194 |
+
* Enhancement : Updated License Page to display Complete License Information. #227
|
195 |
+
* Enhancement : Added Status bar style option for apple icons. #210
|
196 |
+
* Enhancement : Added Proper Method to render Application name and shortname of PWA App even with non-standard characters. #112
|
197 |
+
|
198 |
= 2.1.16 =
|
199 |
* Date: [26.August.2021](https://superpwa.com/superpwa-2-1-16-release-note/?utm_source=wordpress.org&utm_medium=changelog)
|
200 |
* Bug Fixed : "Add to homescreen" banner was not showing when Wp fastest cache plugin is active #209
|
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.
|
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.
|
47 |
}
|
48 |
|
49 |
/**
|
6 |
* Author: SuperPWA
|
7 |
* Author URI: https://profiles.wordpress.org/superpwa/
|
8 |
* Contributors: SuperPWA
|
9 |
+
* Version: 2.1.17
|
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.17' );
|
47 |
}
|
48 |
|
49 |
/**
|