Version Description
- Date: 21.February.2018
- New Feature: Added UI for default orientation of your PWA. Orientation can now be set as "any", "portrait" or "landscape". Feature request from @doofustoo.
- New Feature: Added UI for theme_color property in manifest. Feature request from @krunalsm.
- Enhancement: Improved compatibility with all major Accelerated Mobile Pages (AMP) plugins.
- Enhancement: Improved handling of external resources.
Download this release
Release Info
Developer | arunbasillal |
Plugin | Super Progressive Web Apps |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.4
- admin/admin-setup.php +24 -1
- admin/admin-ui-render.php +73 -7
- admin/basic-setup.php +20 -3
- admin/do.php +1 -1
- public/manifest.php +52 -6
- public/sw.php +2 -2
- readme.txt +28 -1
- superpwa.php +2 -2
admin/admin-setup.php
CHANGED
@@ -91,6 +91,15 @@ function superpwa_register_settings() {
|
|
91 |
'superpwa_basic_settings_section' // Settings Section ID
|
92 |
);
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
// Start URL
|
95 |
add_settings_field(
|
96 |
'superpwa_start_url', // ID
|
@@ -109,6 +118,15 @@ function superpwa_register_settings() {
|
|
109 |
'superpwa_basic_settings_section' // Settings Section ID
|
110 |
);
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
// PWA Status
|
113 |
add_settings_section(
|
114 |
'superpwa_pwa_status_section', // ID
|
@@ -159,9 +177,12 @@ function superpwa_validater_and_sanitizer( $settings ) {
|
|
159 |
// Sanitize Application Short Name
|
160 |
$settings['app_short_name'] = sanitize_text_field($settings['app_short_name']) == '' ? get_bloginfo('name') : sanitize_text_field($settings['app_short_name']);
|
161 |
|
162 |
-
// Sanitize hex color input
|
163 |
$settings['background_color'] = preg_match( '/#([a-f0-9]{3}){1,2}\b/i', $settings['background_color'] ) ? sanitize_text_field( $settings['background_color'] ) : '#D5E0EB';
|
164 |
|
|
|
|
|
|
|
165 |
// Sanitize application icon
|
166 |
$settings['icon'] = sanitize_text_field( $settings['icon'] ) == '' ? SUPERPWA_PATH_SRC . 'public/images/logo.png' : sanitize_text_field( $settings['icon'] );
|
167 |
|
@@ -185,9 +206,11 @@ function superpwa_get_settings() {
|
|
185 |
'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
|
186 |
'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
|
187 |
'background_color' => '#D5E0EB',
|
|
|
188 |
'start_url' => 0,
|
189 |
'start_url_amp' => 0,
|
190 |
'offline_page' => 0,
|
|
|
191 |
);
|
192 |
|
193 |
$settings = get_option('superpwa_settings', $defaults);
|
91 |
'superpwa_basic_settings_section' // Settings Section ID
|
92 |
);
|
93 |
|
94 |
+
// Theme Color
|
95 |
+
add_settings_field(
|
96 |
+
'superpwa_theme_color', // ID
|
97 |
+
__('Theme Color', 'super-progressive-web-apps'), // Title
|
98 |
+
'superpwa_theme_color_cb', // CB
|
99 |
+
'superpwa_basic_settings_section', // Page slug
|
100 |
+
'superpwa_basic_settings_section' // Settings Section ID
|
101 |
+
);
|
102 |
+
|
103 |
// Start URL
|
104 |
add_settings_field(
|
105 |
'superpwa_start_url', // ID
|
118 |
'superpwa_basic_settings_section' // Settings Section ID
|
119 |
);
|
120 |
|
121 |
+
// Orientation
|
122 |
+
add_settings_field(
|
123 |
+
'superpwa_orientation', // ID
|
124 |
+
__('Orientation', 'super-progressive-web-apps'), // Title
|
125 |
+
'superpwa_orientation_cb', // CB
|
126 |
+
'superpwa_basic_settings_section', // Page slug
|
127 |
+
'superpwa_basic_settings_section' // Settings Section ID
|
128 |
+
);
|
129 |
+
|
130 |
// PWA Status
|
131 |
add_settings_section(
|
132 |
'superpwa_pwa_status_section', // ID
|
177 |
// Sanitize Application Short Name
|
178 |
$settings['app_short_name'] = sanitize_text_field($settings['app_short_name']) == '' ? get_bloginfo('name') : sanitize_text_field($settings['app_short_name']);
|
179 |
|
180 |
+
// Sanitize hex color input for background_color
|
181 |
$settings['background_color'] = preg_match( '/#([a-f0-9]{3}){1,2}\b/i', $settings['background_color'] ) ? sanitize_text_field( $settings['background_color'] ) : '#D5E0EB';
|
182 |
|
183 |
+
// Sanitize hex color input for theme_color
|
184 |
+
$settings['theme_color'] = preg_match( '/#([a-f0-9]{3}){1,2}\b/i', $settings['theme_color'] ) ? sanitize_text_field( $settings['theme_color'] ) : '#D5E0EB';
|
185 |
+
|
186 |
// Sanitize application icon
|
187 |
$settings['icon'] = sanitize_text_field( $settings['icon'] ) == '' ? SUPERPWA_PATH_SRC . 'public/images/logo.png' : sanitize_text_field( $settings['icon'] );
|
188 |
|
206 |
'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
|
207 |
'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
|
208 |
'background_color' => '#D5E0EB',
|
209 |
+
'theme_color' => '#D5E0EB',
|
210 |
'start_url' => 0,
|
211 |
'start_url_amp' => 0,
|
212 |
'offline_page' => 0,
|
213 |
+
'orientation' => 1,
|
214 |
);
|
215 |
|
216 |
$settings = get_option('superpwa_settings', $defaults);
|
admin/admin-ui-render.php
CHANGED
@@ -6,10 +6,12 @@
|
|
6 |
* @function superpwa_app_name_cb() Application Name
|
7 |
* @function superpwa_app_short_name_cb() Application Short Name
|
8 |
* @function superpwa_background_color_cb() Splash Screen Background Color
|
|
|
9 |
* @function superpwa_app_icon_cb() Application Icon
|
10 |
* @function superpwa_app_icon_cb() Splash Screen Icon
|
11 |
* @function superpwa_start_url_cb() Start URL Dropdown
|
12 |
* @function superpwa_offline_page_cb() Offline Page Dropdown
|
|
|
13 |
* @function superpwa_manifest_status_cb() Manifest Status
|
14 |
* @function superpwa_sw_status_cb() Service Worker Status
|
15 |
* @function superpwa_https_status_cb() HTTPS Status
|
@@ -52,7 +54,9 @@ function superpwa_app_short_name_cb() {
|
|
52 |
|
53 |
<input type="text" name="superpwa_settings[app_short_name]" class="regular-text" value="<?php if ( isset( $settings['app_short_name'] ) && ( ! empty($settings['app_short_name']) ) ) echo esc_attr($settings['app_short_name']); ?>"/>
|
54 |
|
55 |
-
<p class="description" id="tagline-description"
|
|
|
|
|
56 |
|
57 |
</fieldset>
|
58 |
|
@@ -75,7 +79,9 @@ function superpwa_app_icon_cb() {
|
|
75 |
<span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> Choose Icon
|
76 |
</button>
|
77 |
|
78 |
-
<p class="description" id="tagline-description"
|
|
|
|
|
79 |
|
80 |
<?php
|
81 |
}
|
@@ -96,7 +102,9 @@ function superpwa_splash_icon_cb() {
|
|
96 |
<span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> Choose Icon
|
97 |
</button>
|
98 |
|
99 |
-
<p class="description" id="tagline-description"
|
|
|
|
|
100 |
|
101 |
<?php
|
102 |
}
|
@@ -114,7 +122,29 @@ function superpwa_background_color_cb() {
|
|
114 |
<!-- Background Color -->
|
115 |
<input type="text" name="superpwa_settings[background_color]" id="superpwa_settings[background_color]" class="superpwa-colorpicker" value="<?php echo isset( $settings['background_color'] ) ? esc_attr( $settings['background_color']) : '#D5E0EB'; ?>" data-default-color="#D5E0EB">
|
116 |
|
117 |
-
<p class="description" id="tagline-description"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
<?php
|
120 |
}
|
@@ -142,7 +172,9 @@ function superpwa_start_url_cb() {
|
|
142 |
)); ?>
|
143 |
</label>
|
144 |
|
145 |
-
<p class="description" id="tagline-description"
|
|
|
|
|
146 |
|
147 |
<?php if ( superpwa_is_amp() ) { ?>
|
148 |
|
@@ -162,7 +194,7 @@ function superpwa_start_url_cb() {
|
|
162 |
/**
|
163 |
* Offline Page Dropdown
|
164 |
*
|
165 |
-
* @since 1.
|
166 |
*/
|
167 |
function superpwa_offline_page_cb() {
|
168 |
|
@@ -180,7 +212,41 @@ function superpwa_offline_page_cb() {
|
|
180 |
)); ?>
|
181 |
</label>
|
182 |
|
183 |
-
<p class="description" id="tagline-description"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
<?php
|
186 |
}
|
6 |
* @function superpwa_app_name_cb() Application Name
|
7 |
* @function superpwa_app_short_name_cb() Application Short Name
|
8 |
* @function superpwa_background_color_cb() Splash Screen Background Color
|
9 |
+
* @function superpwa_theme_color_cb() Theme Color
|
10 |
* @function superpwa_app_icon_cb() Application Icon
|
11 |
* @function superpwa_app_icon_cb() Splash Screen Icon
|
12 |
* @function superpwa_start_url_cb() Start URL Dropdown
|
13 |
* @function superpwa_offline_page_cb() Offline Page Dropdown
|
14 |
+
* @function superpwa_orientation_cb() Default Orientation Dropdown
|
15 |
* @function superpwa_manifest_status_cb() Manifest Status
|
16 |
* @function superpwa_sw_status_cb() Service Worker Status
|
17 |
* @function superpwa_https_status_cb() HTTPS Status
|
54 |
|
55 |
<input type="text" name="superpwa_settings[app_short_name]" class="regular-text" value="<?php if ( isset( $settings['app_short_name'] ) && ( ! empty($settings['app_short_name']) ) ) echo esc_attr($settings['app_short_name']); ?>"/>
|
56 |
|
57 |
+
<p class="description" id="tagline-description">
|
58 |
+
<?php _e('Used when there is insufficient space to display the full name of the application.', 'super-progressive-web-apps'); ?>
|
59 |
+
</p>
|
60 |
|
61 |
</fieldset>
|
62 |
|
79 |
<span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> Choose Icon
|
80 |
</button>
|
81 |
|
82 |
+
<p class="description" id="tagline-description">
|
83 |
+
<?php _e('This will be the icon of your app when installed on the phone. Must be a <code>PNG</code> image exactly <code>192x192</code> in size.', 'super-progressive-web-apps'); ?>
|
84 |
+
</p>
|
85 |
|
86 |
<?php
|
87 |
}
|
102 |
<span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> Choose Icon
|
103 |
</button>
|
104 |
|
105 |
+
<p class="description" id="tagline-description">
|
106 |
+
<?php _e('This icon will be displayed on the splash screen of your app on supported devices. Must be a <code>PNG</code> image exactly <code>512x512</code> in size.', 'super-progressive-web-apps'); ?>
|
107 |
+
</p>
|
108 |
|
109 |
<?php
|
110 |
}
|
122 |
<!-- Background Color -->
|
123 |
<input type="text" name="superpwa_settings[background_color]" id="superpwa_settings[background_color]" class="superpwa-colorpicker" value="<?php echo isset( $settings['background_color'] ) ? esc_attr( $settings['background_color']) : '#D5E0EB'; ?>" data-default-color="#D5E0EB">
|
124 |
|
125 |
+
<p class="description" id="tagline-description">
|
126 |
+
<?php _e('Background color of the splash screen.', 'super-progressive-web-apps'); ?>
|
127 |
+
</p>
|
128 |
+
|
129 |
+
<?php
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Theme Color
|
134 |
+
*
|
135 |
+
* @since 1.4
|
136 |
+
*/
|
137 |
+
function superpwa_theme_color_cb() {
|
138 |
+
|
139 |
+
// Get Settings
|
140 |
+
$settings = superpwa_get_settings(); ?>
|
141 |
+
|
142 |
+
<!-- Theme Color -->
|
143 |
+
<input type="text" name="superpwa_settings[theme_color]" id="superpwa_settings[theme_color]" class="superpwa-colorpicker" value="<?php echo isset( $settings['theme_color'] ) ? esc_attr( $settings['theme_color']) : '#D5E0EB'; ?>" data-default-color="#D5E0EB">
|
144 |
+
|
145 |
+
<p class="description" id="tagline-description">
|
146 |
+
<?php _e('Theme color is used on supported devices to tint the UI elements of the browser and app switcher. When in doubt, use the same color as <code>Background Color</code>.', 'super-progressive-web-apps'); ?>
|
147 |
+
</p>
|
148 |
|
149 |
<?php
|
150 |
}
|
172 |
)); ?>
|
173 |
</label>
|
174 |
|
175 |
+
<p class="description" id="tagline-description">
|
176 |
+
<?php printf( __( 'Specify the page to load when the application is launched from a device. Current start page is <code>%s</code>', 'super-progressive-web-apps' ), superpwa_get_start_url() ); ?>
|
177 |
+
</p>
|
178 |
|
179 |
<?php if ( superpwa_is_amp() ) { ?>
|
180 |
|
194 |
/**
|
195 |
* Offline Page Dropdown
|
196 |
*
|
197 |
+
* @since 1.1
|
198 |
*/
|
199 |
function superpwa_offline_page_cb() {
|
200 |
|
212 |
)); ?>
|
213 |
</label>
|
214 |
|
215 |
+
<p class="description" id="tagline-description">
|
216 |
+
<?php printf( __( 'Offline page is displayed when the device is offline and the requested page is not already cached. Current offline page is <code>%s</code>', 'super-progressive-web-apps' ), get_permalink($settings['offline_page']) ? trailingslashit(get_permalink($settings['offline_page'])) : trailingslashit(get_bloginfo( 'wpurl' )) ); ?>
|
217 |
+
</p>
|
218 |
+
|
219 |
+
<?php
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Default Orientation Dropdown
|
224 |
+
*
|
225 |
+
* @since 1.4
|
226 |
+
*/
|
227 |
+
function superpwa_orientation_cb() {
|
228 |
+
|
229 |
+
// Get Settings
|
230 |
+
$settings = superpwa_get_settings(); ?>
|
231 |
+
|
232 |
+
<!-- Orientation Dropdown -->
|
233 |
+
<label for="superpwa_settings[orientation]">
|
234 |
+
<select name="superpwa_settings[orientation]" id="superpwa_settings[orientation]">
|
235 |
+
<option value="0" <?php if ( isset( $settings['orientation'] ) ) { selected( $settings['orientation'], 0 ); } ?>>
|
236 |
+
<?php _e( 'Follow Device Orientation', 'super-progressive-web-apps' ); ?>
|
237 |
+
</option>
|
238 |
+
<option value="1" <?php if ( isset( $settings['orientation'] ) ) { selected( $settings['orientation'], 1 ); } ?>>
|
239 |
+
<?php _e( 'Portrait', 'super-progressive-web-apps' ); ?>
|
240 |
+
</option>
|
241 |
+
<option value="2" <?php if ( isset( $settings['orientation'] ) ) { selected( $settings['orientation'], 2 ); } ?>>
|
242 |
+
<?php _e( 'Landscape', 'super-progressive-web-apps' ); ?>
|
243 |
+
</option>
|
244 |
+
</select>
|
245 |
+
</label>
|
246 |
+
|
247 |
+
<p class="description" id="tagline-description">
|
248 |
+
<?php _e( 'Set the orientation of your app on devices. When set to <code>Follow Device Orientation</code> your app will rotate as the device is rotated.', 'super-progressive-web-apps' ); ?>
|
249 |
+
</p>
|
250 |
|
251 |
<?php
|
252 |
}
|
admin/basic-setup.php
CHANGED
@@ -64,7 +64,8 @@ function superpwa_admin_notice_activation() {
|
|
64 |
/**
|
65 |
* Plugin upgrade todo list
|
66 |
*
|
67 |
-
* @since 1.
|
|
|
68 |
*/
|
69 |
function superpwa_upgrader() {
|
70 |
|
@@ -81,6 +82,21 @@ function superpwa_upgrader() {
|
|
81 |
return;
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
// Re-generate manifest
|
85 |
superpwa_generate_manifest();
|
86 |
|
@@ -167,8 +183,9 @@ function superpwa_footer_text( $default ) {
|
|
167 |
return $default;
|
168 |
}
|
169 |
|
170 |
-
$superpwa_footer_text = sprintf( __( 'If you like our plugin, please leave a <a href="%s" target="_blank">★★★★★</a> rating to support continued development. Thanks a bunch!', 'super-progressive-web-apps' ),
|
171 |
-
'https://
|
|
|
172 |
);
|
173 |
|
174 |
return $superpwa_footer_text;
|
64 |
/**
|
65 |
* Plugin upgrade todo list
|
66 |
*
|
67 |
+
* @since 1.3.1
|
68 |
+
* @since 1.4 Added orientation setting and theme_color to database when upgrading from pre 1.4 versions.
|
69 |
*/
|
70 |
function superpwa_upgrader() {
|
71 |
|
82 |
return;
|
83 |
}
|
84 |
|
85 |
+
if ( $current_ver < 1.4 ) {
|
86 |
+
|
87 |
+
// Get settings
|
88 |
+
$settings = superpwa_get_settings();
|
89 |
+
|
90 |
+
// Orientation was set as 'natural' until version 1.4. Set it as 1, which is 'portrait'.
|
91 |
+
$settings['orientation'] = 1;
|
92 |
+
|
93 |
+
// theme_color was same as background_color until version 1.4
|
94 |
+
$settings['theme_color'] = $settings['background_color'];
|
95 |
+
|
96 |
+
// Write settings back to database
|
97 |
+
update_option( 'superpwa_settings', $settings );
|
98 |
+
}
|
99 |
+
|
100 |
// Re-generate manifest
|
101 |
superpwa_generate_manifest();
|
102 |
|
183 |
return $default;
|
184 |
}
|
185 |
|
186 |
+
$superpwa_footer_text = sprintf( __( 'If you like our plugin, please <a href="%s" target="_blank">make a donation</a> or leave a <a href="%s" target="_blank">★★★★★</a> rating to support continued development. Thanks a bunch!', 'super-progressive-web-apps' ),
|
187 |
+
'https://millionclues.com/donate/',
|
188 |
+
'https://wordpress.org/support/plugin/super-progressive-web-apps/reviews/?rate=5#new-post'
|
189 |
);
|
190 |
|
191 |
return $superpwa_footer_text;
|
admin/do.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Operations
|
4 |
*
|
5 |
* @since 1.0
|
6 |
* @function superpwa_after_save_settings_todo() Todo list after saving admin options
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Operations and common functions of SuperPWA
|
4 |
*
|
5 |
* @since 1.0
|
6 |
* @function superpwa_after_save_settings_todo() Todo list after saving admin options
|
public/manifest.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* @since 1.0
|
6 |
* @function superpwa_generate_manifest() Generate and write manifest
|
@@ -8,6 +8,8 @@
|
|
8 |
* @function superpwa_register_service_worker() Register service worker in the footer (wp_footer)
|
9 |
* @function superpwa_delete_manifest() Delete manifest
|
10 |
* @function superpwa_get_pwa_icons() Get PWA Icons
|
|
|
|
|
11 |
*/
|
12 |
|
13 |
// Exit if accessed directly
|
@@ -29,16 +31,17 @@ function superpwa_generate_manifest() {
|
|
29 |
'short_name' => $settings['app_short_name'],
|
30 |
'icons' => superpwa_get_pwa_icons(),
|
31 |
'background_color' => $settings['background_color'],
|
32 |
-
'theme_color' => $settings['
|
33 |
'display' => 'standalone',
|
34 |
-
'orientation' =>
|
35 |
-
'start_url' => superpwa_get_start_url(true),
|
|
|
36 |
);
|
37 |
|
38 |
// Delete manifest if it exists
|
39 |
superpwa_delete_manifest();
|
40 |
|
41 |
-
if ( ! superpwa_put_contents( SUPERPWA_MANIFEST_ABS, json_encode($manifest) ) )
|
42 |
return false;
|
43 |
|
44 |
return true;
|
@@ -55,7 +58,7 @@ function superpwa_add_manifest_to_header() {
|
|
55 |
$settings = superpwa_get_settings();
|
56 |
|
57 |
echo '<!-- Manifest added by SuperPWA -->' . PHP_EOL . '<link rel="manifest" href="'. SUPERPWA_MANIFEST_SRC . '">' . PHP_EOL;
|
58 |
-
echo '<meta name="theme-color" content="'. $settings['
|
59 |
}
|
60 |
add_action( 'wp_head', 'superpwa_add_manifest_to_header' );
|
61 |
|
@@ -99,4 +102,47 @@ function superpwa_get_pwa_icons() {
|
|
99 |
}
|
100 |
|
101 |
return $icons_array;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Manifest related functions of SuperPWA
|
4 |
*
|
5 |
* @since 1.0
|
6 |
* @function superpwa_generate_manifest() Generate and write manifest
|
8 |
* @function superpwa_register_service_worker() Register service worker in the footer (wp_footer)
|
9 |
* @function superpwa_delete_manifest() Delete manifest
|
10 |
* @function superpwa_get_pwa_icons() Get PWA Icons
|
11 |
+
* @function superpwa_get_scope() Get navigation scope of PWA
|
12 |
+
* @function superpwa_get_orientation() Get orientation of PWA
|
13 |
*/
|
14 |
|
15 |
// Exit if accessed directly
|
31 |
'short_name' => $settings['app_short_name'],
|
32 |
'icons' => superpwa_get_pwa_icons(),
|
33 |
'background_color' => $settings['background_color'],
|
34 |
+
'theme_color' => $settings['theme_color'],
|
35 |
'display' => 'standalone',
|
36 |
+
'orientation' => superpwa_get_orientation(),
|
37 |
+
'start_url' => superpwa_get_start_url( true ),
|
38 |
+
'scope' => superpwa_get_scope(),
|
39 |
);
|
40 |
|
41 |
// Delete manifest if it exists
|
42 |
superpwa_delete_manifest();
|
43 |
|
44 |
+
if ( ! superpwa_put_contents( SUPERPWA_MANIFEST_ABS, json_encode( $manifest ) ) )
|
45 |
return false;
|
46 |
|
47 |
return true;
|
58 |
$settings = superpwa_get_settings();
|
59 |
|
60 |
echo '<!-- Manifest added by SuperPWA -->' . PHP_EOL . '<link rel="manifest" href="'. SUPERPWA_MANIFEST_SRC . '">' . PHP_EOL;
|
61 |
+
echo '<meta name="theme-color" content="'. $settings['theme_color'] .'">' . PHP_EOL;
|
62 |
}
|
63 |
add_action( 'wp_head', 'superpwa_add_manifest_to_header' );
|
64 |
|
102 |
}
|
103 |
|
104 |
return $icons_array;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get navigation scope of PWA
|
109 |
+
*
|
110 |
+
* @return string Relative path to the folder where WordPress is installed. Same folder as manifest and wp-config.php
|
111 |
+
* @since 1.4
|
112 |
+
*/
|
113 |
+
function superpwa_get_scope() {
|
114 |
+
|
115 |
+
return parse_url( trailingslashit( get_bloginfo( 'wpurl' ) ), PHP_URL_PATH );
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Get orientation of PWA
|
120 |
+
*
|
121 |
+
* @return string Orientation of PWA as set in the plugin settings.
|
122 |
+
* @since 1.4
|
123 |
+
*/
|
124 |
+
function superpwa_get_orientation() {
|
125 |
+
|
126 |
+
// Get Settings
|
127 |
+
$settings = superpwa_get_settings();
|
128 |
+
|
129 |
+
$orientation = isset( $settings['orientation'] ) ? $settings['orientation'] : 0;
|
130 |
+
|
131 |
+
switch ( $orientation ) {
|
132 |
+
|
133 |
+
case 0:
|
134 |
+
return 'any';
|
135 |
+
break;
|
136 |
+
|
137 |
+
case 1:
|
138 |
+
return 'portrait';
|
139 |
+
break;
|
140 |
+
|
141 |
+
case 2:
|
142 |
+
return 'landscape';
|
143 |
+
break;
|
144 |
+
|
145 |
+
default:
|
146 |
+
return 'any';
|
147 |
+
}
|
148 |
}
|
public/sw.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* @since 1.0
|
6 |
* @function superpwa_generate_sw() Generate and write service worker into sw.js
|
@@ -103,7 +103,7 @@ self.addEventListener('fetch', function(e) {
|
|
103 |
return;
|
104 |
|
105 |
// Return if request url is from an external domain.
|
106 |
-
if (
|
107 |
return;
|
108 |
|
109 |
// For POST requests, do not use the cache. Serve offline page if offline.
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Service worker related functions of SuperPWA
|
4 |
*
|
5 |
* @since 1.0
|
6 |
* @function superpwa_generate_sw() Generate and write service worker into sw.js
|
103 |
return;
|
104 |
|
105 |
// Return if request url is from an external domain.
|
106 |
+
if ( new URL(e.request.url).origin !== location.origin )
|
107 |
return;
|
108 |
|
109 |
// For POST requests, do not use the cache. Serve offline page if offline.
|
readme.txt
CHANGED
@@ -17,6 +17,18 @@ Progressive Web Apps (PWA) is a new technology that creates a middle ground betw
|
|
17 |
|
18 |
Users can come back to your website by launching the app from their home screen and interact with your website through an app-like interface. Your return visitors will experience almost-instant loading times and enjoy the great performance benefits of your PWA!
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
### What's in the box
|
21 |
|
22 |
Here are the current features of Super Progressive Web Apps:
|
@@ -31,10 +43,12 @@ Here are the current features of Super Progressive Web Apps:
|
|
31 |
* New in version 1.2: Support for theme-color.
|
32 |
* New in version 1.2: Now you can edit the Application Name and Application Short name.
|
33 |
* New in version 1.2: Set the start page of your PWA.
|
34 |
-
* New in version 1.2: Set AMP version of the start page. Supported plugins: AMP for WordPress, AMP for WP, Better AMP, AMP Supremacy, WP AMP.
|
35 |
* New in version 1.3: Added support for high-quality splash screen. You can now set the 512x512 icon for the splash screen of your Progressive Web App.
|
36 |
* New in version 1.3: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
|
37 |
* New in version 1.3: Improved in-browser service worker update handling.
|
|
|
|
|
38 |
|
39 |
**Upcoming features:**
|
40 |
|
@@ -129,6 +143,13 @@ PWA's require browsers with support for service workers and for iOS devices, sup
|
|
129 |
|
130 |
== Changelog ==
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
= 1.3.1 =
|
133 |
* Date: 15.February.2018
|
134 |
* Enhancement: Improved how Start Page url is handled in the service worker to be compatible with plugins that force SSL.
|
@@ -170,6 +191,12 @@ PWA's require browsers with support for service workers and for iOS devices, sup
|
|
170 |
|
171 |
== Upgrade Notice ==
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
= 1.3.1 =
|
174 |
* Enhancement: Improved how Start Page url is handled in the service worker to be compatible with plugins that force SSL.
|
175 |
* Enhancement: Improved how start_url is handled in the manifest.
|
17 |
|
18 |
Users can come back to your website by launching the app from their home screen and interact with your website through an app-like interface. Your return visitors will experience almost-instant loading times and enjoy the great performance benefits of your PWA!
|
19 |
|
20 |
+
Super Progressive Web Apps makes it easy for you to convert your WordPress website into a Progressive Web App easily!
|
21 |
+
|
22 |
+
Once SuperPWA is installed, users browsing your website from a supported mobile device will see a "Add To Home Screen" notice (from the bottom of the screen) and will be able to 'install your website' on the home screen of their device. Every page visited is stored locally on their device and will be available to read even when they are offline!
|
23 |
+
|
24 |
+
SuperPWA is easy to configure, it takes less than a minute to set-up your Progressive Web App! SuperPWA does a clean uninstall, by removing every database entry and file that it creates. In fact, none of the default settings are saved to the database until you manually save it the first time. Go ahead and give it a try.
|
25 |
+
|
26 |
+
And the best part? If you ever get stuck, we are here to watch your back! [Open a support](https://wordpress.org/support/plugin/super-progressive-web-apps) ticket if you have a question or need a feature. We are super excited to hear your feedback and we want to genuinely help you build the best Progressive Web App for your WordPress website!
|
27 |
+
|
28 |
+
#### Thank You PWA Enthusiasts!
|
29 |
+
|
30 |
+
We are humbled by the feedback from the community. Thanks to everyone who believed in us and tried our plugin. Your feedback has been invaluable and we have learned a lot from your experience. Thank you for your love and support and we hope to return the love by striving to bring you the best ever Progressive Web Apps plugin for WordPress!
|
31 |
+
|
32 |
### What's in the box
|
33 |
|
34 |
Here are the current features of Super Progressive Web Apps:
|
43 |
* New in version 1.2: Support for theme-color.
|
44 |
* New in version 1.2: Now you can edit the Application Name and Application Short name.
|
45 |
* New in version 1.2: Set the start page of your PWA.
|
46 |
+
* New in version 1.2: Set Accelerated Mobile Pages (AMP) version of the start page. Supported plugins: AMP for WordPress, AMP for WP, Better AMP, AMP Supremacy, WP AMP.
|
47 |
* New in version 1.3: Added support for high-quality splash screen. You can now set the 512x512 icon for the splash screen of your Progressive Web App.
|
48 |
* New in version 1.3: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
|
49 |
* New in version 1.3: Improved in-browser service worker update handling.
|
50 |
+
* New in version 1.4: You can now set the default orientation of your PWA. Choose from "any" (Follow Device Orientation), "Portrait" and "Landscape".
|
51 |
+
* New in version 1.4: You can now set the theme_color property in the manifest.
|
52 |
|
53 |
**Upcoming features:**
|
54 |
|
143 |
|
144 |
== Changelog ==
|
145 |
|
146 |
+
= 1.4 =
|
147 |
+
* Date: 21.February.2018
|
148 |
+
* New Feature: Added UI for default orientation of your PWA. Orientation can now be set as "any", "portrait" or "landscape". [Feature request from @doofustoo](https://wordpress.org/support/topic/almost-perfect-335/).
|
149 |
+
* New Feature: Added UI for theme_color property in manifest. [Feature request from @krunalsm](https://wordpress.org/support/topic/diffrent-theme_color-and-background_color/).
|
150 |
+
* Enhancement: Improved compatibility with all major Accelerated Mobile Pages (AMP) plugins.
|
151 |
+
* Enhancement: Improved handling of external resources.
|
152 |
+
|
153 |
= 1.3.1 =
|
154 |
* Date: 15.February.2018
|
155 |
* Enhancement: Improved how Start Page url is handled in the service worker to be compatible with plugins that force SSL.
|
191 |
|
192 |
== Upgrade Notice ==
|
193 |
|
194 |
+
= 1.4 =
|
195 |
+
* New Feature: Added UI for default orientation of your PWA. Orientation can now be set as "any", "portrait" or "landscape".
|
196 |
+
* New Feature: Added UI for theme_color property in manifest.
|
197 |
+
* Enhancement: Improved compatibility with all major Accelerated Mobile Pages (AMP) plugins.
|
198 |
+
* Enhancement: Improved handling of external resources.
|
199 |
+
|
200 |
= 1.3.1 =
|
201 |
* Enhancement: Improved how Start Page url is handled in the service worker to be compatible with plugins that force SSL.
|
202 |
* Enhancement: Improved how start_url is handled in the manifest.
|
superpwa.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Convert your WordPress website into a Progressive Web App
|
6 |
* Author: SuperPWA
|
7 |
* Contributors: Arun Basil Lal, Jose Varghese
|
8 |
-
* Version: 1.
|
9 |
* Text Domain: super-progressive-web-apps
|
10 |
* Domain Path: /languages
|
11 |
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
@@ -48,7 +48,7 @@ if ( ! defined('ABSPATH') ) exit;
|
|
48 |
*/
|
49 |
if ( ! defined('SUPERPWA_PATH_ABS ') ) define('SUPERPWA_PATH_ABS', plugin_dir_path( __FILE__ )); // absolute path to the plugin directory. eg - /var/www/html/wp-content/plugins/superpwa/
|
50 |
if ( ! defined('SUPERPWA_PATH_SRC') ) define('SUPERPWA_PATH_SRC', plugin_dir_url( __FILE__ )); // link to the plugin folder. eg - http://example.com/wp/wp-content/plugins/superpwa/
|
51 |
-
if ( ! defined('SUPERPWA_VERSION') ) define('SUPERPWA_VERSION', '1.
|
52 |
if ( ! defined('SUPERPWA_MANIFEST_FILENAME') ) define('SUPERPWA_MANIFEST_FILENAME', 'superpwa-manifest.json'); // Name of Manifest file
|
53 |
if ( ! defined('SUPERPWA_MANIFEST_ABS') ) define('SUPERPWA_MANIFEST_ABS', trailingslashit( ABSPATH ) . SUPERPWA_MANIFEST_FILENAME); // Absolute path to manifest
|
54 |
if ( ! defined('SUPERPWA_MANIFEST_SRC') ) define('SUPERPWA_MANIFEST_SRC', trailingslashit( get_bloginfo('wpurl') ) . SUPERPWA_MANIFEST_FILENAME); // Link to manifest
|
5 |
* Description: Convert your WordPress website into a Progressive Web App
|
6 |
* Author: SuperPWA
|
7 |
* Contributors: Arun Basil Lal, Jose Varghese
|
8 |
+
* Version: 1.4
|
9 |
* Text Domain: super-progressive-web-apps
|
10 |
* Domain Path: /languages
|
11 |
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
48 |
*/
|
49 |
if ( ! defined('SUPERPWA_PATH_ABS ') ) define('SUPERPWA_PATH_ABS', plugin_dir_path( __FILE__ )); // absolute path to the plugin directory. eg - /var/www/html/wp-content/plugins/superpwa/
|
50 |
if ( ! defined('SUPERPWA_PATH_SRC') ) define('SUPERPWA_PATH_SRC', plugin_dir_url( __FILE__ )); // link to the plugin folder. eg - http://example.com/wp/wp-content/plugins/superpwa/
|
51 |
+
if ( ! defined('SUPERPWA_VERSION') ) define('SUPERPWA_VERSION', '1.4'); // Plugin version
|
52 |
if ( ! defined('SUPERPWA_MANIFEST_FILENAME') ) define('SUPERPWA_MANIFEST_FILENAME', 'superpwa-manifest.json'); // Name of Manifest file
|
53 |
if ( ! defined('SUPERPWA_MANIFEST_ABS') ) define('SUPERPWA_MANIFEST_ABS', trailingslashit( ABSPATH ) . SUPERPWA_MANIFEST_FILENAME); // Absolute path to manifest
|
54 |
if ( ! defined('SUPERPWA_MANIFEST_SRC') ) define('SUPERPWA_MANIFEST_SRC', trailingslashit( get_bloginfo('wpurl') ) . SUPERPWA_MANIFEST_FILENAME); // Link to manifest
|