Version Description
- Date: 14.December.2021
- Bug Fixed : Fixed Manifest Warnings Regarding Icon Purpose Value#237
- Enhancement : Added AMP Support with Official AMP and AMPforWP Plugins#218
- Enhancement : Added New option to Reset Settings#233
Download this release
Release Info
Developer | superpwa |
Plugin | Super Progressive Web Apps |
Version | 2.2 |
Comparing to | |
See all releases |
Code changes from version 2.1.19 to 2.2
- 3rd-party/amp.php +115 -0
- admin/admin-ui-render-settings.php +9 -0
- admin/admin-ui-setup.php +56 -1
- admin/basic-setup.php +6 -0
- admin/js/main.js +26 -1
- functions/common.php +85 -0
- loader.php +2 -0
- public/amphtml.php +36 -0
- public/manifest.php +14 -1
- readme.txt +6 -0
- superpwa.php +2 -2
3rd-party/amp.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* AMP Support Implementation
|
4 |
+
*
|
5 |
+
* @since 2.2
|
6 |
+
*/
|
7 |
+
|
8 |
+
// Exit if accessed directly
|
9 |
+
if ( ! defined('ABSPATH') ) exit;
|
10 |
+
|
11 |
+
class SUPERPWA_AMP_SW{
|
12 |
+
|
13 |
+
public $is_amp = false;
|
14 |
+
/**
|
15 |
+
* Initialize whole front end system
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
/* Check & initialize AMP is Activated or not*/
|
19 |
+
$this->superpwa_is_amp_activated();
|
20 |
+
|
21 |
+
// Change service worker filename to match OneSignal's service worker
|
22 |
+
add_filter( 'superpwa_sw_filename', array($this, 'superpwa_amp_sw_filename') );
|
23 |
+
|
24 |
+
add_action('pre_amp_render_post', array($this, 'superpwa_amp_entry_point'));
|
25 |
+
//Automattic AMP will be done here
|
26 |
+
add_action('wp', array($this, 'superpwa_automattic_amp_entry_point'));
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
public function superpwa_amp_sw_filename( $sw_filename ) {
|
31 |
+
return 'superpwa-amp-sw' . superpwa_multisite_filename_postfix() . '.js';
|
32 |
+
}
|
33 |
+
|
34 |
+
public function superpwa_amp_entry_point(){
|
35 |
+
|
36 |
+
add_action('amp_post_template_footer',array($this, 'superpwa_amp_service_worker'), 15);
|
37 |
+
add_filter('amp_post_template_data',array($this, 'superpwa_service_worker_script'),35);
|
38 |
+
add_action('amp_post_template_head',array($this, 'superpwa_amp_manifest_json_relink'),1);
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
public function superpwa_automattic_amp_entry_point(){
|
43 |
+
if ( superpwa_is_automattic_amp() ) {
|
44 |
+
|
45 |
+
add_action('wp_footer',array($this, 'superpwa_amp_service_worker'));
|
46 |
+
add_filter('amp_post_template_data',array($this, 'superpwa_service_worker_script'),35);
|
47 |
+
//add_action('wp_head',array($this, 'pwaforwp_paginated_post_add_homescreen_amp'),1);
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
public function superpwa_amp_service_worker(){
|
53 |
+
|
54 |
+
$url = superpwa_site_url();
|
55 |
+
$home_url = superpwa_home_url();
|
56 |
+
$swhtml = $url.'superpwa-amp-sw'.superpwa_multisite_filename_postfix().'.html';
|
57 |
+
$swjs_path_amp = $url.'superpwa-amp-sw'.superpwa_multisite_filename_postfix().'.js';
|
58 |
+
?>
|
59 |
+
<amp-install-serviceworker data-scope="<?php echo trailingslashit($home_url); ?>"
|
60 |
+
src="<?php echo esc_url_raw($swjs_path_amp); ?>"
|
61 |
+
data-iframe-src="<?php echo esc_url_raw($swhtml); ?>"
|
62 |
+
layout="nodisplay">
|
63 |
+
</amp-install-serviceworker>
|
64 |
+
|
65 |
+
<?php
|
66 |
+
}
|
67 |
+
|
68 |
+
public function superpwa_amp_manifest_json_relink(){
|
69 |
+
|
70 |
+
|
71 |
+
$tags = '<!-- Manifest added by SuperPWA - Progressive Web Apps Plugin For WordPress -->' . PHP_EOL;
|
72 |
+
$tags .= '<link rel="manifest" href="'. parse_url( superpwa_manifest( 'src' ), PHP_URL_PATH ) . '">' . PHP_EOL;
|
73 |
+
|
74 |
+
// theme-color meta tag
|
75 |
+
if ( apply_filters( 'superpwa_add_theme_color', true ) ) {
|
76 |
+
|
77 |
+
// Get Settings
|
78 |
+
$settings = superpwa_get_settings();
|
79 |
+
$tags .= '<meta name="theme-color" content="'. $settings['theme_color'] .'">' . PHP_EOL;
|
80 |
+
}
|
81 |
+
|
82 |
+
$tags = apply_filters( 'superpwa_wp_head_tags', $tags );
|
83 |
+
|
84 |
+
$tags .= '<!-- / SuperPWA.com -->' . PHP_EOL;
|
85 |
+
|
86 |
+
echo $tags;
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
public function superpwa_service_worker_script( $data ){
|
92 |
+
|
93 |
+
if ( empty( $data['amp_component_scripts']['amp-install-serviceworker'] ) ) {
|
94 |
+
$data['amp_component_scripts']['amp-install-serviceworker'] = 'https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js';
|
95 |
+
}
|
96 |
+
return $data;
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
public function superpwa_is_amp_activated() {
|
101 |
+
|
102 |
+
if ( function_exists( 'ampforwp_is_amp_endpoint' ) || function_exists( 'is_amp_endpoint' ) ) {
|
103 |
+
$this->is_amp = true;
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
// Initiate SUPERPWA_AMP_SW Class
|
111 |
+
function superpwa_amp_sw_init() {
|
112 |
+
|
113 |
+
new SUPERPWA_AMP_SW();
|
114 |
+
}
|
115 |
+
add_action( 'init', 'superpwa_amp_sw_init' );
|
admin/admin-ui-render-settings.php
CHANGED
@@ -522,6 +522,15 @@ function superpwa_exclude_add_to_homescreen_cb(){
|
|
522 |
<?php
|
523 |
}
|
524 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
/**
|
526 |
* Force Update Service Worker
|
527 |
*
|
522 |
<?php
|
523 |
}
|
524 |
|
525 |
+
function superpwa_reset_settings_cb(){
|
526 |
+
?>
|
527 |
+
<button class="button superpwa-reset-settings">
|
528 |
+
<?php echo esc_html__('Reset','super-progressive-web-apps'); ?>
|
529 |
+
</button>
|
530 |
+
|
531 |
+
<?php
|
532 |
+
}
|
533 |
+
|
534 |
/**
|
535 |
* Force Update Service Worker
|
536 |
*
|
admin/admin-ui-setup.php
CHANGED
@@ -318,6 +318,14 @@ function superpwa_register_settings() {
|
|
318 |
'superpwa_exclude_add_to_homescreen_cb', // CB
|
319 |
'superpwa_pwa_advance_section', // Page slug
|
320 |
'superpwa_pwa_advance_section' // Settings Section ID
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
);
|
322 |
}
|
323 |
add_action( 'admin_init', 'superpwa_register_settings' );
|
@@ -412,12 +420,49 @@ function superpwa_get_settings() {
|
|
412 |
'is_static_manifest'=> 0,
|
413 |
'is_static_sw' => 0,
|
414 |
'disable_add_to_home'=> 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
);
|
416 |
|
417 |
$settings = get_option( 'superpwa_settings', $defaults );
|
418 |
|
419 |
return $settings;
|
420 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
|
422 |
/**
|
423 |
* Todo list after saving admin options
|
@@ -461,7 +506,17 @@ function superpwa_enqueue_css_js( $hook ) {
|
|
461 |
wp_enqueue_media();
|
462 |
|
463 |
// Main JS
|
464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
if( defined('SUPERPWA_PRO_VERSION') ){
|
466 |
if ($hook == 'toplevel_page_superpwa') {
|
467 |
wp_enqueue_style('superpwa-admin-panel-css', SUPERPWA_PATH_SRC . 'admin/css/admin-panel.css', array(), SUPERPWA_PRO_VERSION, 'all');
|
318 |
'superpwa_exclude_add_to_homescreen_cb', // CB
|
319 |
'superpwa_pwa_advance_section', // Page slug
|
320 |
'superpwa_pwa_advance_section' // Settings Section ID
|
321 |
+
);
|
322 |
+
// Exclude Urls from Cache list
|
323 |
+
add_settings_field(
|
324 |
+
'superpwa_reset_settings_shortcut', // ID
|
325 |
+
__('Reset Settings', 'super-progressive-web-apps'), // Title
|
326 |
+
'superpwa_reset_settings_cb', // CB
|
327 |
+
'superpwa_pwa_advance_section', // Page slug
|
328 |
+
'superpwa_pwa_advance_section' // Settings Section ID
|
329 |
);
|
330 |
}
|
331 |
add_action( 'admin_init', 'superpwa_register_settings' );
|
420 |
'is_static_manifest'=> 0,
|
421 |
'is_static_sw' => 0,
|
422 |
'disable_add_to_home'=> 0,
|
423 |
+
'analytics_support'=> 1,
|
424 |
+
'cache_external_urls'=> 0,
|
425 |
+
'yandex_support'=> 0,
|
426 |
+
'force_update_sw_setting'=> SUPERPWA_VERSION,
|
427 |
+
'excluded_urls'=> '',
|
428 |
+
'exclude_homescreen'=> '',
|
429 |
);
|
430 |
|
431 |
$settings = get_option( 'superpwa_settings', $defaults );
|
432 |
|
433 |
return $settings;
|
434 |
}
|
435 |
+
/***
|
436 |
+
Returns default Superpwa settings
|
437 |
+
***/
|
438 |
+
function superpwa_get_default_settings() {
|
439 |
+
|
440 |
+
$defaults = array(
|
441 |
+
'app_name' => get_bloginfo( 'name' ),
|
442 |
+
'app_short_name' => function_exists('mb_substr') ? mb_substr( get_bloginfo( 'name' ), 0, 15 ) : substr( get_bloginfo( 'name' ), 0, 15 ),
|
443 |
+
'description' => get_bloginfo( 'description' ),
|
444 |
+
'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
|
445 |
+
'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
|
446 |
+
'background_color' => '#D5E0EB',
|
447 |
+
'theme_color' => '#D5E0EB',
|
448 |
+
'start_url' => 0,
|
449 |
+
'start_url_amp' => 0,
|
450 |
+
'offline_page' => 0,
|
451 |
+
'orientation' => 1,
|
452 |
+
'display' => 1,
|
453 |
+
'is_static_manifest'=> 0,
|
454 |
+
'is_static_sw' => 0,
|
455 |
+
'disable_add_to_home'=> 0,
|
456 |
+
'analytics_support'=> 1,
|
457 |
+
'cache_external_urls'=> 0,
|
458 |
+
'yandex_support'=> 0,
|
459 |
+
'force_update_sw_setting'=> SUPERPWA_VERSION,
|
460 |
+
'excluded_urls'=> '',
|
461 |
+
'exclude_homescreen'=> '',
|
462 |
+
);
|
463 |
+
|
464 |
+
return $settings;
|
465 |
+
}
|
466 |
|
467 |
/**
|
468 |
* Todo list after saving admin options
|
506 |
wp_enqueue_media();
|
507 |
|
508 |
// Main JS
|
509 |
+
wp_register_script( 'superpwa-main-js', SUPERPWA_PATH_SRC . 'admin/js/main.js', array( 'wp-color-picker' ), SUPERPWA_VERSION, true );
|
510 |
+
|
511 |
+
$object_name = array(
|
512 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
513 |
+
'superpwa_security_nonce' => wp_create_nonce('superpwa_ajax_check_nonce'),
|
514 |
+
);
|
515 |
+
$object_name = apply_filters('superpwa_localize_filter',$object_name,'superpwa_obj');
|
516 |
+
|
517 |
+
wp_localize_script('superpwa-main-js', 'superpwa_obj', $object_name);
|
518 |
+
wp_enqueue_script('superpwa-main-js');
|
519 |
+
|
520 |
if( defined('SUPERPWA_PRO_VERSION') ){
|
521 |
if ($hook == 'toplevel_page_superpwa') {
|
522 |
wp_enqueue_style('superpwa-admin-panel-css', SUPERPWA_PATH_SRC . 'admin/css/admin-panel.css', array(), SUPERPWA_PRO_VERSION, 'all');
|
admin/basic-setup.php
CHANGED
@@ -434,6 +434,7 @@ function superpwa_generate_sw_and_manifest_on_fly( $query ) {
|
|
434 |
$query_vars_as_string = http_build_query( $query->query_vars );
|
435 |
$manifest_filename = superpwa_get_manifest_filename();
|
436 |
$sw_filename = superpwa_get_sw_filename();
|
|
|
437 |
|
438 |
if ( strpos( $query_vars_as_string, $manifest_filename ) !== false ) {
|
439 |
// Generate manifest from Settings and send the response w/ header.
|
@@ -454,6 +455,11 @@ function superpwa_generate_sw_and_manifest_on_fly( $query ) {
|
|
454 |
echo superpwa_sw_template();
|
455 |
exit();
|
456 |
}
|
|
|
|
|
|
|
|
|
|
|
457 |
}
|
458 |
|
459 |
/**
|
434 |
$query_vars_as_string = http_build_query( $query->query_vars );
|
435 |
$manifest_filename = superpwa_get_manifest_filename();
|
436 |
$sw_filename = superpwa_get_sw_filename();
|
437 |
+
$amphtml_filename = 'superpwa-amp-sw.html';
|
438 |
|
439 |
if ( strpos( $query_vars_as_string, $manifest_filename ) !== false ) {
|
440 |
// Generate manifest from Settings and send the response w/ header.
|
455 |
echo superpwa_sw_template();
|
456 |
exit();
|
457 |
}
|
458 |
+
if ( strpos( $query_vars_as_string, $amphtml_filename ) !== false ) {
|
459 |
+
header( 'Content-Type: text/html' );
|
460 |
+
echo amp_service_worker_template();
|
461 |
+
exit();
|
462 |
+
}
|
463 |
}
|
464 |
|
465 |
/**
|
admin/js/main.js
CHANGED
@@ -218,4 +218,29 @@ function superpwaGetZip() {
|
|
218 |
|
219 |
});
|
220 |
}
|
221 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
|
219 |
});
|
220 |
}
|
221 |
+
}
|
222 |
+
|
223 |
+
//Reset settings
|
224 |
+
jQuery(document).on("click",".superpwa-reset-settings", function(e){
|
225 |
+
//$('.superpwa-reset-settings').click(function(e){
|
226 |
+
e.preventDefault();
|
227 |
+
|
228 |
+
var reset_confirm = confirm("Are you sure?");
|
229 |
+
|
230 |
+
if(reset_confirm == true){
|
231 |
+
|
232 |
+
jQuery.ajax({
|
233 |
+
type: "POST",
|
234 |
+
url:ajaxurl,
|
235 |
+
dataType: "json",
|
236 |
+
data:{action:"superpwa_reset_all_settings", superpwa_security_nonce:superpwa_obj.superpwa_security_nonce},
|
237 |
+
success:function(response){
|
238 |
+
setTimeout(function(){ location.reload(); }, 1000);
|
239 |
+
},
|
240 |
+
error: function(response){
|
241 |
+
console.log(response);
|
242 |
+
}
|
243 |
+
});
|
244 |
+
|
245 |
+
}
|
246 |
+
});
|
functions/common.php
CHANGED
@@ -241,6 +241,91 @@ function superpwa_get_bloginfo( $file = 'sw' ) {
|
|
241 |
|
242 |
return get_bloginfo( 'url' );
|
243 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
/**
|
245 |
* Returns Superpwa setting tabs html
|
246 |
*/
|
241 |
|
242 |
return get_bloginfo( 'url' );
|
243 |
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* only for Automattic amp Support
|
247 |
+
* When user enabled Standard & Transitional mode
|
248 |
+
* it will check and give respective values
|
249 |
+
*/
|
250 |
+
|
251 |
+
function superpwa_is_automattic_amp($case=null){
|
252 |
+
//Check if current theme support amp
|
253 |
+
switch ($case) {
|
254 |
+
case 'amp_support':
|
255 |
+
if(class_exists('AMP_Theme_Support')){
|
256 |
+
return current_theme_supports( AMP_Theme_Support::SLUG );
|
257 |
+
}
|
258 |
+
break;
|
259 |
+
default:
|
260 |
+
if ( current_theme_supports( 'amp' ) && function_exists('is_amp_endpoint') && is_amp_endpoint() ) {
|
261 |
+
return true;
|
262 |
+
}
|
263 |
+
break;
|
264 |
+
}
|
265 |
+
return false;
|
266 |
+
}
|
267 |
+
|
268 |
+
function superpwa_home_url(){
|
269 |
+
|
270 |
+
if ( is_multisite() ) {
|
271 |
+
$link = get_site_url();
|
272 |
+
}
|
273 |
+
else {
|
274 |
+
$link = home_url();
|
275 |
+
}
|
276 |
+
$link = superpwa_httpsify($link);
|
277 |
+
|
278 |
+
return trailingslashit($link);
|
279 |
+
}
|
280 |
+
function superpwa_site_url(){
|
281 |
+
|
282 |
+
if (is_multisite() ) {
|
283 |
+
|
284 |
+
$link = get_site_url();
|
285 |
+
|
286 |
+
}
|
287 |
+
else {
|
288 |
+
$link = site_url();
|
289 |
+
}
|
290 |
+
$link = superpwa_httpsify($link);
|
291 |
+
|
292 |
+
return trailingslashit($link);
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Reset Settings Ajax Callback
|
297 |
+
*/
|
298 |
+
function superpwa_reset_all_settings(){
|
299 |
+
|
300 |
+
if ( ! isset( $_POST['superpwa_security_nonce'] ) ){
|
301 |
+
return;
|
302 |
+
}
|
303 |
+
if ( !wp_verify_nonce( $_POST['superpwa_security_nonce'], 'superpwa_ajax_check_nonce' ) ){
|
304 |
+
return;
|
305 |
+
}
|
306 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
307 |
+
return;
|
308 |
+
}
|
309 |
+
|
310 |
+
$default = superpwa_get_default_settings();
|
311 |
+
|
312 |
+
$result = update_option('superpwa_settings', $default);
|
313 |
+
// delete_transient('pwaforwp_restapi_check');
|
314 |
+
|
315 |
+
if($result){
|
316 |
+
|
317 |
+
echo json_encode(array('status'=>'t'));
|
318 |
+
|
319 |
+
}else{
|
320 |
+
|
321 |
+
echo json_encode(array('status'=>'f'));
|
322 |
+
|
323 |
+
}
|
324 |
+
wp_die();
|
325 |
+
}
|
326 |
+
|
327 |
+
add_action('wp_ajax_superpwa_reset_all_settings', 'superpwa_reset_all_settings');
|
328 |
+
|
329 |
/**
|
330 |
* Returns Superpwa setting tabs html
|
331 |
*/
|
loader.php
CHANGED
@@ -18,6 +18,7 @@ require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-upgrade.php' );
|
|
18 |
// 3rd party compatibility
|
19 |
require_once( SUPERPWA_PATH_ABS . '3rd-party/onesignal.php' );
|
20 |
require_once( SUPERPWA_PATH_ABS . '3rd-party/yandex.php' );
|
|
|
21 |
|
22 |
// Load functions
|
23 |
require_once( SUPERPWA_PATH_ABS . 'functions/common.php' );
|
@@ -27,6 +28,7 @@ require_once( SUPERPWA_PATH_ABS . 'functions/multisite.php' );
|
|
27 |
// Public folder
|
28 |
require_once( SUPERPWA_PATH_ABS . 'public/manifest.php' );
|
29 |
require_once( SUPERPWA_PATH_ABS . 'public/sw.php' );
|
|
|
30 |
|
31 |
// Load bundled add-ons
|
32 |
if ( superpwa_addons_status( 'utm_tracking' ) == 'active' ) require_once( SUPERPWA_PATH_ABS . 'addons/utm-tracking.php' );
|
18 |
// 3rd party compatibility
|
19 |
require_once( SUPERPWA_PATH_ABS . '3rd-party/onesignal.php' );
|
20 |
require_once( SUPERPWA_PATH_ABS . '3rd-party/yandex.php' );
|
21 |
+
require_once( SUPERPWA_PATH_ABS . '3rd-party/amp.php' );
|
22 |
|
23 |
// Load functions
|
24 |
require_once( SUPERPWA_PATH_ABS . 'functions/common.php' );
|
28 |
// Public folder
|
29 |
require_once( SUPERPWA_PATH_ABS . 'public/manifest.php' );
|
30 |
require_once( SUPERPWA_PATH_ABS . 'public/sw.php' );
|
31 |
+
require_once( SUPERPWA_PATH_ABS . 'public/amphtml.php' );
|
32 |
|
33 |
// Load bundled add-ons
|
34 |
if ( superpwa_addons_status( 'utm_tracking' ) == 'active' ) require_once( SUPERPWA_PATH_ABS . 'addons/utm-tracking.php' );
|
public/amphtml.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function amp_service_worker_template(){
|
4 |
+
$url = superpwa_site_url();
|
5 |
+
$home_url = superpwa_home_url();
|
6 |
+
$swjs_path_amp = $url.'superpwa-amp-sw'.superpwa_multisite_filename_postfix().'.js';
|
7 |
+
?>
|
8 |
+
<!doctype html>
|
9 |
+
<html>
|
10 |
+
<head>
|
11 |
+
<title>Installing service worker</title>
|
12 |
+
<script type="text/javascript">
|
13 |
+
var swsource = "<?php echo $swjs_path_amp; ?>";
|
14 |
+
if("serviceWorker" in navigator) {
|
15 |
+
navigator.serviceWorker.register(swsource, {scope: '<?php echo $home_url; ?>'}).then(function(reg){
|
16 |
+
console.log('Congratulations!!Service Worker Registered ServiceWorker scope: ', reg.scope);
|
17 |
+
}).catch(function(err) {
|
18 |
+
console.log('ServiceWorker registration failed: ', err);
|
19 |
+
});
|
20 |
+
};
|
21 |
+
|
22 |
+
window.addEventListener('beforeinstallprompt', (e) => {
|
23 |
+
{{swdefaultaddtohomebar}}
|
24 |
+
deferredPrompt = e;
|
25 |
+
})
|
26 |
+
|
27 |
+
</script>
|
28 |
+
<meta name="robots" content="noindex">
|
29 |
+
</head>
|
30 |
+
<body>
|
31 |
+
Installing service worker...
|
32 |
+
</body>
|
33 |
+
</html>
|
34 |
+
|
35 |
+
<?php
|
36 |
+
}
|
public/manifest.php
CHANGED
@@ -282,7 +282,13 @@ function superpwa_get_pwa_icons() {
|
|
282 |
'src' => $settings['icon'],
|
283 |
'sizes' => '192x192', // must be 192x192. Todo: use getimagesize($settings['icon'])[0].'x'.getimagesize($settings['icon'])[1] in the future
|
284 |
'type' => 'image/png', // must be image/png. Todo: use getimagesize($settings['icon'])['mime']
|
285 |
-
'purpose'=> 'any
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
);
|
287 |
|
288 |
// Splash screen icon - Added since 1.3
|
@@ -292,6 +298,13 @@ function superpwa_get_pwa_icons() {
|
|
292 |
'src' => $settings['splash_icon'],
|
293 |
'sizes' => '512x512', // must be 512x512.
|
294 |
'type' => 'image/png', // must be image/png
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
);
|
296 |
}
|
297 |
|
282 |
'src' => $settings['icon'],
|
283 |
'sizes' => '192x192', // must be 192x192. Todo: use getimagesize($settings['icon'])[0].'x'.getimagesize($settings['icon'])[1] in the future
|
284 |
'type' => 'image/png', // must be image/png. Todo: use getimagesize($settings['icon'])['mime']
|
285 |
+
'purpose'=> 'any', // any maskable to support adaptive icons
|
286 |
+
);
|
287 |
+
$icons_array[] = array(
|
288 |
+
'src' => $settings['icon'],
|
289 |
+
'sizes' => '192x192', // must be 192x192. Todo: use getimagesize($settings['icon'])[0].'x'.getimagesize($settings['icon'])[1] in the future
|
290 |
+
'type' => 'image/png', // must be image/png. Todo: use getimagesize($settings['icon'])['mime']
|
291 |
+
'purpose'=> 'maskable', // any maskable to support adaptive icons
|
292 |
);
|
293 |
|
294 |
// Splash screen icon - Added since 1.3
|
298 |
'src' => $settings['splash_icon'],
|
299 |
'sizes' => '512x512', // must be 512x512.
|
300 |
'type' => 'image/png', // must be image/png
|
301 |
+
'purpose'=> 'any',
|
302 |
+
);
|
303 |
+
$icons_array[] = array(
|
304 |
+
'src' => $settings['splash_icon'],
|
305 |
+
'sizes' => '512x512', // must be 512x512.
|
306 |
+
'type' => 'image/png', // must be image/png
|
307 |
+
'purpose'=> 'maskable',
|
308 |
);
|
309 |
}
|
310 |
|
readme.txt
CHANGED
@@ -186,6 +186,12 @@ Feel free to get in touch if you have any questions.
|
|
186 |
|
187 |
== Changelog ==
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
= 2.1.19 =
|
190 |
* Date: [23.November.2021](https://superpwa.com/superpwa-2-1-19-release-note/?utm_source=wordpress.org&utm_medium=changelog)
|
191 |
* Enhancement : Added New option to exclude Add to homescreen banner on particular pages #232
|
186 |
|
187 |
== Changelog ==
|
188 |
|
189 |
+
= 2.2 =
|
190 |
+
* Date: [14.December.2021](https://superpwa.com/superpwa-2-2-release-note/?utm_source=wordpress.org&utm_medium=changelog)
|
191 |
+
* Bug Fixed : Fixed Manifest Warnings Regarding Icon Purpose Value#237
|
192 |
+
* Enhancement : Added AMP Support with Official AMP and AMPforWP Plugins#218
|
193 |
+
* Enhancement : Added New option to Reset Settings#233
|
194 |
+
|
195 |
= 2.1.19 =
|
196 |
* Date: [23.November.2021](https://superpwa.com/superpwa-2-1-19-release-note/?utm_source=wordpress.org&utm_medium=changelog)
|
197 |
* Enhancement : Added New option to exclude Add to homescreen banner on particular pages #232
|
superpwa.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Author: SuperPWA
|
7 |
* Author URI: https://profiles.wordpress.org/superpwa/
|
8 |
* Contributors: SuperPWA
|
9 |
-
* Version: 2.
|
10 |
* Text Domain: super-progressive-web-apps
|
11 |
* Domain Path: /languages
|
12 |
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
@@ -43,7 +43,7 @@ if ( ! defined('ABSPATH') ) exit;
|
|
43 |
* @since 1.0
|
44 |
*/
|
45 |
if ( ! defined( 'SUPERPWA_VERSION' ) ) {
|
46 |
-
define( 'SUPERPWA_VERSION' , '2.
|
47 |
}
|
48 |
|
49 |
/**
|
6 |
* Author: SuperPWA
|
7 |
* Author URI: https://profiles.wordpress.org/superpwa/
|
8 |
* Contributors: SuperPWA
|
9 |
+
* Version: 2.2
|
10 |
* Text Domain: super-progressive-web-apps
|
11 |
* Domain Path: /languages
|
12 |
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
43 |
* @since 1.0
|
44 |
*/
|
45 |
if ( ! defined( 'SUPERPWA_VERSION' ) ) {
|
46 |
+
define( 'SUPERPWA_VERSION' , '2.2' );
|
47 |
}
|
48 |
|
49 |
/**
|