Super Progressive Web Apps - Version 2.1.1

Version Description

  • Date: 4.July.2020
  • Tested with WordPress 5.4.2.
  • Enhancement: Added support for Maskable Icons #127
Download this release

Release Info

Developer arunbasillal
Plugin Icon 128x128 Super Progressive Web Apps
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1 to 2.1.1

.gitignore DELETED
@@ -1 +0,0 @@
1
- vendor
 
3rd-party/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
3rd-party/onesignal.php CHANGED
@@ -1,231 +1,231 @@
1
- <?php
2
- /**
3
- * OneSignal integration
4
- *
5
- * @link https://wordpress.org/plugins/onesignal-free-web-push-notifications/
6
- *
7
- * @since 1.6
8
- *
9
- * @function superpwa_onesignal_todo() Compatibility with OneSignal
10
- * @function superpwa_onesignal_add_gcm_sender_id() Add gcm_sender_id to SuperPWA manifest
11
- * @function superpwa_onesignal_sw_filename() Change Service Worker filename to OneSignalSDKWorker.js.php
12
- * @function superpwa_onesignal_sw() Import OneSignal service worker in SuperPWA
13
- * @function superpwa_onesignal_activation() OneSignal activation todo
14
- * @function superpwa_onesignal_deactivation() OneSignal deactivation todo
15
- * @function superpwa_onesignal_admin_notices() Admin notices for OneSignal compatibility
16
- */
17
-
18
- // Exit if accessed directly
19
- if ( ! defined('ABSPATH') ) exit;
20
-
21
- /**
22
- * Compatibility with OneSignal
23
- *
24
- * This was written without a function @since 1.6 but that caused issues in certain cases where
25
- * SuperPWA was loaded before OneSignal. Hooked everything to plugins_loaded @since 2.0.1
26
- *
27
- * @author Arun Basil Lal
28
- *
29
- * @since 2.0.1
30
- */
31
- function superpwa_onesignal_todo() {
32
-
33
- // If OneSignal is installed and active
34
- if ( class_exists( 'OneSignal' ) ) {
35
-
36
- // Filter manifest and service worker for singe websites and not for multisites.
37
- if ( ! is_multisite() ) {
38
-
39
- // Add gcm_sender_id to SuperPWA manifest
40
- add_filter( 'superpwa_manifest', 'superpwa_onesignal_add_gcm_sender_id' );
41
-
42
- // Change service worker filename to match OneSignal's service worker
43
- add_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
44
-
45
- // Import OneSignal service worker in SuperPWA
46
- add_filter( 'superpwa_sw_template', 'superpwa_onesignal_sw' );
47
- }
48
-
49
- // Show admin notice.
50
- add_action( 'admin_notices', 'superpwa_onesignal_admin_notices', 9 );
51
- add_action( 'network_admin_notices', 'superpwa_onesignal_admin_notices', 9 );
52
- }
53
- }
54
- add_action( 'plugins_loaded', 'superpwa_onesignal_todo' );
55
-
56
- /**
57
- * Add gcm_sender_id to SuperPWA manifest
58
- *
59
- * OneSignal's gcm_sender_id is 482941778795
60
- *
61
- * @param (array) $manifest Array with the manifest entries passed via the superpwa_manifest filter.
62
- *
63
- * @return (array) Array appended with the gcm_sender_id of OneSignal
64
- *
65
- * @since 1.8
66
- */
67
- function superpwa_onesignal_add_gcm_sender_id( $manifest ) {
68
-
69
- $manifest['gcm_sender_id'] = '482941778795';
70
-
71
- return $manifest;
72
- }
73
-
74
- /**
75
- * Change Service Worker filename to OneSignalSDKWorker.js.php
76
- *
77
- * OneSignalSDKWorker.js.php is the name of the service worker of OneSignal.
78
- * Since only one service worker is allowed in a given scope, OneSignal unregisters all other service workers and registers theirs.
79
- * Having the same name prevents OneSignal from unregistering our service worker.
80
- *
81
- * @link https://documentation.onesignal.com/docs/web-push-setup-faq
82
- *
83
- * @param (string) $sw_filename Filename of SuperPWA service worker passed via superpwa_sw_filename filter.
84
- *
85
- * @return (string) Service worker filename changed to OneSignalSDKWorker.js.php
86
- *
87
- * @since 1.8
88
- */
89
- function superpwa_onesignal_sw_filename( $sw_filename ) {
90
- return 'OneSignalSDKWorker.js.php';
91
- }
92
-
93
- /**
94
- * Import OneSignal service worker in SuperPWA
95
- *
96
- * @param (string) $sw Service worker template of SuperPWA passed via superpwa_sw_template filter
97
- *
98
- * @return (string) Import OneSignal's service worker into SuperPWA
99
- *
100
- * @author Arun Basil Lal
101
- *
102
- * @since 1.8
103
- * @since 2.0 Removed content-type header for compatibility with dynamic service workers.
104
- * @since 2.0.1 Added back compatibility with static service workers by sending content-type header.
105
- */
106
- function superpwa_onesignal_sw( $sw ) {
107
-
108
- /**
109
- * Checking to see if we are already sending the Content-Type header.
110
- *
111
- * @see superpwa_generate_sw_and_manifest_on_fly()
112
- */
113
- $match = preg_grep( '#Content-Type: text/javascript#i', headers_list() );
114
-
115
- if ( ! empty ( $match ) ) {
116
-
117
- $onesignal = 'importScripts( \'' . superpwa_httpsify( plugin_dir_url( 'onesignal-free-web-push-notifications/onesignal.php' ) ) . 'sdk_files/OneSignalSDKWorker.js.php\' );' . PHP_EOL;
118
-
119
- return $onesignal . $sw;
120
- }
121
-
122
- $onesignal = '<?php' . PHP_EOL;
123
- $onesignal .= 'header( "Content-Type: application/javascript" );' . PHP_EOL;
124
- $onesignal .= 'echo "importScripts( \'' . superpwa_httpsify( plugin_dir_url( 'onesignal-free-web-push-notifications/onesignal.php' ) ) . 'sdk_files/OneSignalSDKWorker.js.php\' );";' . PHP_EOL;
125
- $onesignal .= '?>' . PHP_EOL . PHP_EOL;
126
-
127
- return $onesignal . $sw;
128
- }
129
-
130
- /**
131
- * OneSignal activation todo
132
- *
133
- * Regenerates SuperPWA manifest with the gcm_sender_id added.
134
- * Delete current service worker.
135
- * Regenerate SuperPWA service worker with the new filename.
136
- *
137
- * @author Arun Basil Lal
138
- *
139
- * @since 1.8
140
- * @since 1.8.1 Excluded multisites. No OneSignal compatibility on multisites yet. In 1.8 onesignal.php was not loaded for multisites.
141
- */
142
- function superpwa_onesignal_activation() {
143
-
144
- // Do not do anything for multisites
145
- if ( is_multisite() ) {
146
- return;
147
- }
148
-
149
- // Filter in gcm_sender_id to SuperPWA manifest
150
- add_filter( 'superpwa_manifest', 'superpwa_onesignal_add_gcm_sender_id' );
151
-
152
- // Regenerate SuperPWA manifest
153
- superpwa_generate_manifest();
154
-
155
- // Delete service worker if it exists
156
- superpwa_delete_sw();
157
-
158
- // Change service worker filename to match OneSignal's service worker
159
- add_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
160
-
161
- // Import OneSignal service worker in SuperPWA
162
- add_filter( 'superpwa_sw_template', 'superpwa_onesignal_sw' );
163
-
164
- // Regenerate SuperPWA service worker
165
- superpwa_generate_sw();
166
- }
167
- add_action( 'activate_onesignal-free-web-push-notifications/onesignal.php', 'superpwa_onesignal_activation', 11 );
168
-
169
- /**
170
- * OneSignal deactivation todo
171
- *
172
- * Regenerates SuperPWA manifest.
173
- * Delete current service worker.
174
- * Regenerate SuperPWA service worker.
175
- *
176
- * @author Arun Basil Lal
177
- *
178
- * @since 1.8
179
- * @since 1.8.1 Excluded multisites. No OneSignal compatibility on multisites yet. In 1.8 onesignal.php was not loaded for multisites.
180
- */
181
- function superpwa_onesignal_deactivation() {
182
-
183
- // Do not do anything for multisites
184
- if ( is_multisite() ) {
185
- return;
186
- }
187
-
188
- // Remove gcm_sender_id from SuperPWA manifest
189
- remove_filter( 'superpwa_manifest', 'superpwa_onesignal_add_gcm_sender_id' );
190
-
191
- // Regenerate SuperPWA manifest
192
- superpwa_generate_manifest();
193
-
194
- // Delete service worker if it exists
195
- superpwa_delete_sw();
196
-
197
- // Restore the default service worker of SuperPWA
198
- remove_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
199
-
200
- // Remove OneSignal service worker in SuperPWA
201
- remove_filter( 'superpwa_sw_template', 'superpwa_onesignal_sw' );
202
-
203
- // Regenerate SuperPWA service worker
204
- superpwa_generate_sw();
205
- }
206
- add_action( 'deactivate_onesignal-free-web-push-notifications/onesignal.php', 'superpwa_onesignal_deactivation', 11 );
207
-
208
- /**
209
- * Admin notices for OneSignal compatibility
210
- *
211
- * One Single installs, warn users to add SuperPWA manifest as custom manifest in OneSignal settings.
212
- * One multisites, warn users that SuperPWA and OneSignal cannot work together.
213
- *
214
- * @since 1.8.1
215
- * @since 2.1 Removed the notice recommending customers to add manifest to OneSignal.
216
- */
217
- function superpwa_onesignal_admin_notices() {
218
-
219
- // Incompatibility notice for Multisites
220
- if ( is_multisite() && current_user_can( 'manage_options' ) ) {
221
-
222
- echo '<div class="notice notice-warning"><p>' .
223
- sprintf(
224
- __( '<strong>SuperPWA</strong> is not compatible with OneSignal on multisites yet. Disable one of these plugins until the compatibility is available.<br>Please refer to the <a href="%s" target="_blank">OneSignal integration documentation</a> for more info. ', 'super-progressive-web-apps' ),
225
- 'https://superpwa.com/doc/setup-onesignal-with-superpwa/?utm_source=superpwa-plugin&utm_medium=onesignal-multisite-admin-notice#multisites'
226
- ) . '</p></div>';
227
-
228
- // Filter PWA status since PWA is not ready yet.
229
- add_filter( 'superpwa_is_pwa_ready', '__return_false' );
230
- }
231
  }
1
+ <?php
2
+ /**
3
+ * OneSignal integration
4
+ *
5
+ * @link https://wordpress.org/plugins/onesignal-free-web-push-notifications/
6
+ *
7
+ * @since 1.6
8
+ *
9
+ * @function superpwa_onesignal_todo() Compatibility with OneSignal
10
+ * @function superpwa_onesignal_add_gcm_sender_id() Add gcm_sender_id to SuperPWA manifest
11
+ * @function superpwa_onesignal_sw_filename() Change Service Worker filename to OneSignalSDKWorker.js.php
12
+ * @function superpwa_onesignal_sw() Import OneSignal service worker in SuperPWA
13
+ * @function superpwa_onesignal_activation() OneSignal activation todo
14
+ * @function superpwa_onesignal_deactivation() OneSignal deactivation todo
15
+ * @function superpwa_onesignal_admin_notices() Admin notices for OneSignal compatibility
16
+ */
17
+
18
+ // Exit if accessed directly
19
+ if ( ! defined('ABSPATH') ) exit;
20
+
21
+ /**
22
+ * Compatibility with OneSignal
23
+ *
24
+ * This was written without a function @since 1.6 but that caused issues in certain cases where
25
+ * SuperPWA was loaded before OneSignal. Hooked everything to plugins_loaded @since 2.0.1
26
+ *
27
+ * @author Arun Basil Lal
28
+ *
29
+ * @since 2.0.1
30
+ */
31
+ function superpwa_onesignal_todo() {
32
+
33
+ // If OneSignal is installed and active
34
+ if ( class_exists( 'OneSignal' ) ) {
35
+
36
+ // Filter manifest and service worker for singe websites and not for multisites.
37
+ if ( ! is_multisite() ) {
38
+
39
+ // Add gcm_sender_id to SuperPWA manifest
40
+ add_filter( 'superpwa_manifest', 'superpwa_onesignal_add_gcm_sender_id' );
41
+
42
+ // Change service worker filename to match OneSignal's service worker
43
+ add_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
44
+
45
+ // Import OneSignal service worker in SuperPWA
46
+ add_filter( 'superpwa_sw_template', 'superpwa_onesignal_sw' );
47
+ }
48
+
49
+ // Show admin notice.
50
+ add_action( 'admin_notices', 'superpwa_onesignal_admin_notices', 9 );
51
+ add_action( 'network_admin_notices', 'superpwa_onesignal_admin_notices', 9 );
52
+ }
53
+ }
54
+ add_action( 'plugins_loaded', 'superpwa_onesignal_todo' );
55
+
56
+ /**
57
+ * Add gcm_sender_id to SuperPWA manifest
58
+ *
59
+ * OneSignal's gcm_sender_id is 482941778795
60
+ *
61
+ * @param (array) $manifest Array with the manifest entries passed via the superpwa_manifest filter.
62
+ *
63
+ * @return (array) Array appended with the gcm_sender_id of OneSignal
64
+ *
65
+ * @since 1.8
66
+ */
67
+ function superpwa_onesignal_add_gcm_sender_id( $manifest ) {
68
+
69
+ $manifest['gcm_sender_id'] = '482941778795';
70
+
71
+ return $manifest;
72
+ }
73
+
74
+ /**
75
+ * Change Service Worker filename to OneSignalSDKWorker.js.php
76
+ *
77
+ * OneSignalSDKWorker.js.php is the name of the service worker of OneSignal.
78
+ * Since only one service worker is allowed in a given scope, OneSignal unregisters all other service workers and registers theirs.
79
+ * Having the same name prevents OneSignal from unregistering our service worker.
80
+ *
81
+ * @link https://documentation.onesignal.com/docs/web-push-setup-faq
82
+ *
83
+ * @param (string) $sw_filename Filename of SuperPWA service worker passed via superpwa_sw_filename filter.
84
+ *
85
+ * @return (string) Service worker filename changed to OneSignalSDKWorker.js.php
86
+ *
87
+ * @since 1.8
88
+ */
89
+ function superpwa_onesignal_sw_filename( $sw_filename ) {
90
+ return 'OneSignalSDKWorker.js.php';
91
+ }
92
+
93
+ /**
94
+ * Import OneSignal service worker in SuperPWA
95
+ *
96
+ * @param (string) $sw Service worker template of SuperPWA passed via superpwa_sw_template filter
97
+ *
98
+ * @return (string) Import OneSignal's service worker into SuperPWA
99
+ *
100
+ * @author Arun Basil Lal
101
+ *
102
+ * @since 1.8
103
+ * @since 2.0 Removed content-type header for compatibility with dynamic service workers.
104
+ * @since 2.0.1 Added back compatibility with static service workers by sending content-type header.
105
+ */
106
+ function superpwa_onesignal_sw( $sw ) {
107
+
108
+ /**
109
+ * Checking to see if we are already sending the Content-Type header.
110
+ *
111
+ * @see superpwa_generate_sw_and_manifest_on_fly()
112
+ */
113
+ $match = preg_grep( '#Content-Type: text/javascript#i', headers_list() );
114
+
115
+ if ( ! empty ( $match ) ) {
116
+
117
+ $onesignal = 'importScripts( \'' . superpwa_httpsify( plugin_dir_url( 'onesignal-free-web-push-notifications/onesignal.php' ) ) . 'sdk_files/OneSignalSDKWorker.js.php\' );' . PHP_EOL;
118
+
119
+ return $onesignal . $sw;
120
+ }
121
+
122
+ $onesignal = '<?php' . PHP_EOL;
123
+ $onesignal .= 'header( "Content-Type: application/javascript" );' . PHP_EOL;
124
+ $onesignal .= 'echo "importScripts( \'' . superpwa_httpsify( plugin_dir_url( 'onesignal-free-web-push-notifications/onesignal.php' ) ) . 'sdk_files/OneSignalSDKWorker.js.php\' );";' . PHP_EOL;
125
+ $onesignal .= '?>' . PHP_EOL . PHP_EOL;
126
+
127
+ return $onesignal . $sw;
128
+ }
129
+
130
+ /**
131
+ * OneSignal activation todo
132
+ *
133
+ * Regenerates SuperPWA manifest with the gcm_sender_id added.
134
+ * Delete current service worker.
135
+ * Regenerate SuperPWA service worker with the new filename.
136
+ *
137
+ * @author Arun Basil Lal
138
+ *
139
+ * @since 1.8
140
+ * @since 1.8.1 Excluded multisites. No OneSignal compatibility on multisites yet. In 1.8 onesignal.php was not loaded for multisites.
141
+ */
142
+ function superpwa_onesignal_activation() {
143
+
144
+ // Do not do anything for multisites
145
+ if ( is_multisite() ) {
146
+ return;
147
+ }
148
+
149
+ // Filter in gcm_sender_id to SuperPWA manifest
150
+ add_filter( 'superpwa_manifest', 'superpwa_onesignal_add_gcm_sender_id' );
151
+
152
+ // Regenerate SuperPWA manifest
153
+ superpwa_generate_manifest();
154
+
155
+ // Delete service worker if it exists
156
+ superpwa_delete_sw();
157
+
158
+ // Change service worker filename to match OneSignal's service worker
159
+ add_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
160
+
161
+ // Import OneSignal service worker in SuperPWA
162
+ add_filter( 'superpwa_sw_template', 'superpwa_onesignal_sw' );
163
+
164
+ // Regenerate SuperPWA service worker
165
+ superpwa_generate_sw();
166
+ }
167
+ add_action( 'activate_onesignal-free-web-push-notifications/onesignal.php', 'superpwa_onesignal_activation', 11 );
168
+
169
+ /**
170
+ * OneSignal deactivation todo
171
+ *
172
+ * Regenerates SuperPWA manifest.
173
+ * Delete current service worker.
174
+ * Regenerate SuperPWA service worker.
175
+ *
176
+ * @author Arun Basil Lal
177
+ *
178
+ * @since 1.8
179
+ * @since 1.8.1 Excluded multisites. No OneSignal compatibility on multisites yet. In 1.8 onesignal.php was not loaded for multisites.
180
+ */
181
+ function superpwa_onesignal_deactivation() {
182
+
183
+ // Do not do anything for multisites
184
+ if ( is_multisite() ) {
185
+ return;
186
+ }
187
+
188
+ // Remove gcm_sender_id from SuperPWA manifest
189
+ remove_filter( 'superpwa_manifest', 'superpwa_onesignal_add_gcm_sender_id' );
190
+
191
+ // Regenerate SuperPWA manifest
192
+ superpwa_generate_manifest();
193
+
194
+ // Delete service worker if it exists
195
+ superpwa_delete_sw();
196
+
197
+ // Restore the default service worker of SuperPWA
198
+ remove_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
199
+
200
+ // Remove OneSignal service worker in SuperPWA
201
+ remove_filter( 'superpwa_sw_template', 'superpwa_onesignal_sw' );
202
+
203
+ // Regenerate SuperPWA service worker
204
+ superpwa_generate_sw();
205
+ }
206
+ add_action( 'deactivate_onesignal-free-web-push-notifications/onesignal.php', 'superpwa_onesignal_deactivation', 11 );
207
+
208
+ /**
209
+ * Admin notices for OneSignal compatibility
210
+ *
211
+ * One Single installs, warn users to add SuperPWA manifest as custom manifest in OneSignal settings.
212
+ * One multisites, warn users that SuperPWA and OneSignal cannot work together.
213
+ *
214
+ * @since 1.8.1
215
+ * @since 2.1 Removed the notice recommending customers to add manifest to OneSignal.
216
+ */
217
+ function superpwa_onesignal_admin_notices() {
218
+
219
+ // Incompatibility notice for Multisites
220
+ if ( is_multisite() && current_user_can( 'manage_options' ) ) {
221
+
222
+ echo '<div class="notice notice-warning"><p>' .
223
+ sprintf(
224
+ __( '<strong>SuperPWA</strong> is not compatible with OneSignal on multisites yet. Disable one of these plugins until the compatibility is available.<br>Please refer to the <a href="%s" target="_blank">OneSignal integration documentation</a> for more info. ', 'super-progressive-web-apps' ),
225
+ 'https://superpwa.com/doc/setup-onesignal-with-superpwa/?utm_source=superpwa-plugin&utm_medium=onesignal-multisite-admin-notice#multisites'
226
+ ) . '</p></div>';
227
+
228
+ // Filter PWA status since PWA is not ready yet.
229
+ add_filter( 'superpwa_is_pwa_ready', '__return_false' );
230
+ }
231
  }
README.MD CHANGED
@@ -1,235 +1,239 @@
1
- # Super Progressive Web Apps
2
- <p>
3
- <a href="https://twitter.com/intent/follow?screen_name=superpwa">
4
- <img src="https://img.shields.io/twitter/follow/superpwa.svg?style=social&logo=twitter" alt="follow SuperPWA on Twitter">
5
- </a>
6
- <a href="https://github.com/SuperPWA/Super-Progressive-Web-Apps">
7
- <img src="https://img.shields.io/github/stars/SuperPWA/Super-Progressive-Web-Apps.svg?style=social&logo=github&label=SuperPWA" alt="Star Super Progressive Web Apps">
8
- </a>
9
-
10
-
11
- </p>
12
-
13
- <p align="center">
14
- <a href="https://superpwa.com/?utm_source=GitHub&utm_medium=Readme-SuperPWALogo">
15
- <img src="https://pbs.twimg.com/profile_images/975224418543681536/X9-CESOD_400x400.jpg" alt="Super Progressive Web Apps" width=175 height=175>
16
- </a>
17
-
18
- <h3 align="center">Super Progressive Web Apps</h3>
19
-
20
- <p align="center">
21
- SuperPWA helps to convert your WordPress website into Progressive Web Apps easily.
22
- <br>
23
- <br>
24
- <a href="https://superpwa.com/?utm_source=GitHub&utm_medium=Readme-viewWeb"><strong>Visit Website »</strong></a>
25
- <br>
26
- <br>
27
- <a href="https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues/new?template=bug.md">Report bug</a>
28
- ·
29
- <a href="https://wordpress.org/plugins/super-progressive-web-apps/">WordPress Plugin</a>
30
- ·
31
- <a href="https://wordpress.org/support/plugin/super-progressive-web-apps/reviews/">Reviews</a>
32
- ·
33
- <a href="https://wordpress.org/plugins/super-progressive-web-apps/#faq">FAQ</a>
34
- ·
35
- <a href="#-contributions">Contributions</a>
36
- </p>
37
- </p>
38
-
39
-
40
- <p align="center">
41
- <a href="https://superpwa.com/?utm_source=GitHub&utm_medium=Readme-LighthouseScore">
42
- <img src="https://lighthouse-badge.appspot.com?score=100" alt="LightHouse Score">
43
- </a>
44
- <a href="https://wordpress.org/plugins/super-progressive-web-apps/">
45
- <img src="https://img.shields.io/wordpress/plugin/dt/super-progressive-web-apps.svg?style=plastic" alt="Super Progressive Web Apps Downloads">
46
- </a>
47
- <a href="https://wordpress.org/plugins/super-progressive-web-apps/">
48
- <img src="https://img.shields.io/wordpress/plugin/r/super-progressive-web-apps.svg?style=plastic" alt="Super Progressive Web Apps Rating">
49
- </a>
50
- <a href="https://wordpress.org/plugins/super-progressive-web-apps/">
51
- <img src="https://img.shields.io/wordpress/plugin/v/super-progressive-web-apps.svg?style=plastic" alt="Super Progressive Web Apps Version">
52
- </a>
53
- <a href="https://wordpress.org/plugins/super-progressive-web-apps/">
54
- <img src="https://img.shields.io/wordpress/v/super-progressive-web-apps.svg?style=plastic" alt="Super Progressive Web Apps Version">
55
- </a>
56
- </p>
57
-
58
- ## Welcome to the Super PWA GitHub repository
59
-
60
- ⚡️ Demo : <a href="https://superpwa.com/?utm_source=GitHub&utm_medium=Readme-WelcomeDemo">superpwa.com</a> [Check Video's to know how it works](#videos-on-how-add-to-home-screen--progressive-web-apps-works-on-different-browsers)
61
-
62
- ## What is Progressive Web Apps
63
- Progressive Web Apps (PWA) is a new technology that creates a middle ground between a website and a mobile app. They are installed on the phone like a normal app (web app) and can be accessed from the home screen.
64
-
65
- 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!
66
-
67
- <a href="https://superpwa.com?utm_source=github&utm_medium=Readme-what-is-pwa">Super Progressive Web Apps</a> makes it easy for you to convert your WordPress website into a Progressive Web App easily!
68
-
69
- ## ⭐ Support the project
70
- If you feel super excited and want to support us in a small way, please consider starring and/or sharing the repo! This helps us getting known and grow the community.
71
-
72
- <a href="#"><img src="https://raw.githubusercontent.com/josevarghese/Super-Progressive-Web-Apps/master/jose-github-star-gif.gif" alt="Star our repo" width="300px" height="76.95px" /></a>
73
-
74
- Also you can support us via [following on social media's and share about us](#share-via-social-medias-and-spread-superpwa).
75
-
76
- ## 🏗 Installation
77
- 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!
78
-
79
- 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.
80
-
81
- ### 💡 Progressive Web App Minimum Requirments
82
- - [x] Progressive Web Apps require that your WordPress website is served from a secure origin i.e. your website should be HTTPS and not HTTP. If your website isn’t HTTPS, please contact your host about it. You can also ask us [Support Forums](https://wordpress.org/support/plugin/super-progressive-web-apps) if you need help.
83
- </br>
84
-
85
- ##### Videos on How Add to Home Screen & Progressive Web Apps works on Different Browsers
86
-
87
- |<a href="https://www.youtube.com/watch?v=n3TjhNblvqs"><img src="http://i3.ytimg.com/vi/n3TjhNblvqs/maxresdefault.jpg" alt="Google Chrome for Android"/> </br>📽️ Google Chrome for Android| <a href="https://www.youtube.com/watch?v=9v4RwahRQFU"><img src="http://i3.ytimg.com/vi/9v4RwahRQFU/maxresdefault.jpg" alt="Mozilla Firefox for Android" /> </br>📽️ Mozilla Firefox for Android | <a href="https://www.youtube.com/watch?v=V8-AdKxm134"><img src="http://i3.ytimg.com/vi/V8-AdKxm134/maxresdefault.jpg" alt="Microsoft Edge for Android"/> </br>📽️ Microsoft Edge for Android | <a href="https://www.youtube.com/watch?v=Sbhgb6_QKfQ"><img src="http://i3.ytimg.com/vi/Sbhgb6_QKfQ/maxresdefault.jpg" alt="Samung Internet for Android "/> </br>📽️ Samung Internet for Android | <a href="https://www.youtube.com/watch?v=bV8xE6lOdoY"><img src="http://i3.ytimg.com/vi/bV8xE6lOdoY/maxresdefault.jpg" alt="PWA on iOS - Safari Browser"/> </br>📽️ PWA on iOS - Safari Browser |
88
- | :---------: | :---------: | :---------: | :---------: | :---------: |
89
- </br>
90
-
91
- ##### Detailed Documentations for testing PWA on Browsers
92
-
93
- * [PWA on Chrome for Android](https://superpwa.com/doc/test-pwa-google-chrome/)
94
- * [PWA on Desktop - Chrome](https://superpwa.com/doc/test-pwa-on-desktop/)
95
- * [PWA on iOS device - Safari Browser](https://superpwa.com/doc/test-pwa-ios-devices/)
96
- * [PWA on Microsoft Edge Browser for Android](https://superpwa.com/doc/test-pwa-microsoft-edge/)
97
- * [PWA on Samsung Internet Browser for Android](https://superpwa.com/doc/test-pwa-samsung-internet-browser/)
98
-
99
- #### 📦 What's in the box
100
-
101
- Here are the current features of Super Progressive Web Apps:
102
-
103
- * Generate a manifest for your website and add it to the head of your website.
104
- * Set the application icon for your Progressive Web App.
105
- * Set the background color for the splash screen of your Progressive Web App.
106
- * Your website will show the "Add to home screen" notice when accessed in a supported browser.
107
- * Aggressive caching of pages using CacheStorage API.
108
- * Pages once cached are served even if the user is offline.
109
- * Set custom offline page: Select the page you want the user to see when a page that isn't in the cache is accessed and the user is offline.
110
- * New in version 1.2: Support for theme-color.
111
- * New in version 1.2: Now you can edit the Application Name and Application Short name.
112
- * New in version 1.2: Set the start page of your PWA.
113
- * 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.
114
- * 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.
115
- * New in version 1.3: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
116
- * New in version 1.3: Improved in-browser service worker update handling.
117
- * New in version 1.4: You can now set the default orientation of your PWA. Choose from "any" (Follow Device Orientation), "Portrait" and "Landscape".
118
- * New in version 1.4: You can now set the theme_color property in the manifest.
119
- * New in version 1.5: OneSignal integration for Push notifications.
120
- * New in version 1.6: WordPress Multisite Network compatibility.
121
- * New in version 1.7: Add-Ons for SuperPWA is here! Ships with [UTM Tracking Add-On](https://superpwa.com/addons/utm-tracking/?utm_source=GitHub&utm_medium=Readme-version) to track visits coming from your PWA.
122
- * New in version 1.8: Compatibility issues with OneSignal are now resolved!
123
- * New in version 1.8: New Add-On: [Apple Touch Icons](https://superpwa.com/addons/apple-touch-icons/?utm_source=GitHub&utm_medium=Readme-version) that sets your app icons as Apple Touch Icons.
124
- * New in version 2.0: SuperPWA is now compatible with WordPress installed in a sub-folder.
125
- * New in version 2.0: You can now set [display property](https://superpwa.com/doc/web-app-manifest-display-modes/?utm_source=GitHub&utm_medium=Readme-version) from SuperPWA settings.
126
-
127
- #### 🔮 Upcoming features:
128
- * Offline Indicator Notice.
129
-
130
- ### Device and Browser Support For PWA
131
- | | <img src="https://image.flaticon.com/icons/svg/732/732205.svg" alt="Chrome" width="32px" height="32px" /> Chrome | <img src="https://image.flaticon.com/icons/svg/732/732198.svg" alt="Firefox" width="32px" height="32px" /> Firefox | <img src="https://image.flaticon.com/icons/svg/732/732219.svg" alt="Edge" width="32px" height="32px" /> Edge | <img src="https://camo.githubusercontent.com/3fb130c75d01178836d96dcf3baccbe7b95b3642/68747470733a2f2f696d6167652e666c617469636f6e2e636f6d2f69636f6e732f7376672f3733322f3733323233332e737667" alt="Opera" width="32px" height="32px" /> Opera | <img src="https://image.flaticon.com/icons/svg/732/732241.svg" alt="Safari" width="32px" height="32px" /> Safari |<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Samsung_Internet_Logo.png/800px-Samsung_Internet_Logo.png" alt="Samsung" width="32px" height="32px" /> Samsung | <img src="https://upload.wikimedia.org/wikipedia/en/d/d0/UC_Browser_Logo.png" alt="UC Browser" width="32px" height="32px" /> UC Browser | <img src="https://upload.wikimedia.org/wikipedia/en/a/a5/Brave_Software_Logo.png" alt="Brave" width="32px" height="32px" /> Brave |
132
- | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: |
133
- | Add to Home Screen | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/123/123381.svg" alt="Beta or Partial Support" width="20px" height="20px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/123/123381.svg" alt="Beta or Partial Support" width="20px" height="20px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> |
134
- | Service Workers | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> |
135
- | Web Push & Notifications| <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/123/123381.svg" alt="Beta or Partial Support" width="20px" height="20px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> |
136
- | Payment Request API | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/876/876101.svg" alt="In Development" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/876/876101.svg" alt="In Development" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | - | - |
137
- | Meta Theme Color | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | - | - | - | - | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | - | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> |
138
-
139
- </br>
140
-
141
- <p align="center">
142
- <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> Supported
143
- &nbsp;
144
- &nbsp;
145
- &nbsp;
146
- &nbsp;
147
- <img src="https://image.flaticon.com/icons/svg/123/123381.svg" alt="Beta or Partial Support" width="32px" height="32px" /> Beta or Partial Support
148
- &nbsp;
149
- &nbsp;
150
- &nbsp;
151
- &nbsp;
152
- <img src="https://image.flaticon.com/icons/svg/876/876101.svg" alt="In Development" width="32px" height="32px" /> In Development
153
- </p>
154
-
155
-
156
- Progressive web apps need browsers that support manifests and service workers. Currently Google Chrome (version 57+), Chrome for Android (62), Mozilla Firefox (57), Firefox for Android (58) are the major browsers that support PWA.
157
-
158
- The list is fast growing and is likely to be supported in most major browsers by the end of this year.
159
-
160
- ### Why Build Progressive Web Apps?
161
- [![Why Build Progressive Web Apps](http://i3.ytimg.com/vi/1QILz1lAzWY/maxresdefault.jpg)](https://www.youtube.com/embed/1QILz1lAzWY)
162
-
163
- ### How To Convert Your WordPress Website Into A Progressive Web App
164
-
165
- #### ⚙️ WordPress Installation
166
-
167
- * Visit WordPress Admin > **Plugins** > **Add New**
168
- * Search for **Super Progressive Web Apps**
169
- * Click "**Install Now**" and then "**Activate**" Super Progressive Web Apps
170
-
171
- #### ⚙️ To install manually:
172
-
173
- * Upload super-progressive-web-apps folder to the /wp-content/plugins/ directory on your server
174
- * Go to WordPress Admin > **Plugins**
175
- * Activate **Super Progressive Web Apps** plugin from the list.
176
-
177
- #### Customizing Your Progressive Web App
178
-
179
- Your Progressive Web App should be ready to test with the default settings upon activation. You can customize it further and make it truly your own.
180
-
181
- * Go to WordPress Admin > "**SuperPWA**" > **Settings**
182
- * Set a Background Color for the splash screen to be shown when your PWA is opened on a mobile device.
183
- * Set the Application Icon. This will be the icon of your PWA when it is added to the homescreen in a mobile device. The icon must be a PNG image and exactly 192 x 192 pixels in size.
184
- * Set the Offline Page. This page will be displayed if the user is offline and the page he requested is not cached already. Ideally you should create a dedicated WordPress page and set it here. Within the page you create, you could add a note that reads, "It looks like you are offline and the page you requested is not available right now. Please check back again once you are online.".
185
- * Click "Save Settings".
186
-
187
- #### Testing Your Progressive Web App
188
-
189
- * Open a supported browser in a supported device (for eg: Chrome for Android (62 or higher) in an Android device)
190
- * Enter your website and wait till it fully loads
191
- * You should see a pop-up that has your Application Icon and a button that reads "ADD TO HOME SCREEN".
192
- * Click on it and your PWA will be added to your home screen. Wait for the install to complete.
193
- * Go to your home screen and open your PWA. Browse into a few pages if you like. Close the App.
194
- * Disconnect from the internet and now open your PWA again. You should be able to see all the pages that you previously browsed.
195
- * Try visiting a page that you did not visit before. You should see the page you set as your "Offline Page" in the settings of SuperPWA.
196
-
197
-
198
- ### 🤝 About us
199
- > We are a duo who got excited about the idea. Our mission is simple: Help you build an awesome PWA that your users would want to have on their home screen. When we first heard about PWA we wanted to learn everything about it. We have spent countless hours learning and wants to share it with the world. Please give us your constructive feedback and support.
200
-
201
- ## ⛷️ Support
202
- This is a developer's portal for Super Progressive Web Apps and should not be used for support. Please visit the
203
- [Support Forums](https://wordpress.org/support/plugin/super-progressive-web-apps).
204
-
205
- ## 🐛 Reporting bugs
206
- If you ever get stuck, we are here to watch your back! [Open a New Support Topic](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!
207
-
208
- ## 🎍 Contributions
209
- Anyone is welcome to contribute to Super PWA to make it SUPER.
210
-
211
- There are various ways you can contribute:
212
-
213
- * [Raise an issue](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues) on GitHub.
214
- * Follow and Engage with us on Social Media
215
-
216
- &nbsp;&nbsp;&nbsp; <a href="https://twitter.com/intent/follow?screen_name=superpwa" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174876.svg" title="Follow SuperPWA on Twitter" width=35 height=35></a>&nbsp;&nbsp;&nbsp;&nbsp;
217
- <a href="https://www.youtube.com/channel/UCMFlNeutNCwTNls186moUUA" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174883.svg" title="Follow SuperPWA on YouTube" width=35 height=35></a>&nbsp;&nbsp;&nbsp;&nbsp;
218
- <a href="https://www.facebook.com/SuperPWA/" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174848.svg" title="Follow SuperPWA on Facebook" width=35 height=35></a>&nbsp;&nbsp;&nbsp;&nbsp;
219
- <a href="https://www.instagram.com/superpwa/" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174855.svg" title="Follow SuperPWA on Instagram" width=35 height=35></a>&nbsp;&nbsp;&nbsp;&nbsp;
220
-
221
- * Send us a Pull Request with your bug fixes and/or new features.
222
- * Provide feedback and [suggestions on enhancements](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues?direction=desc&labels=Enhancement&page=1&sort=created&state=open).
223
- * ##### Share via Social Media's and spread SuperPWA
224
-
225
- &nbsp;&nbsp;&nbsp; <a href="https://twitter.com/home?status=Super%20Progressive%20Web%20Apps%20helps%20to%20convert%20your%20WordPress%20website%20into%20PWA%20%23SuperPWA%20https%3A//github.com/SuperPWA/Super-Progressive-Web-Apps/%20%40SuperPWA" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174876.svg" title="Share SuperPWA on Twitter" width=20 height=20> Share on Twitter </a>&nbsp;&nbsp;&nbsp;&nbsp;
226
- <p> &nbsp;&nbsp;&nbsp; <a href="https://www.facebook.com/sharer/sharer.php?u=https%3A//github.com/SuperPWA/Super-Progressive-Web-Apps/" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174848.svg" title="Follow SuperPWA on Facebook" width=20 height=20> Share on Facebook </a>&nbsp;&nbsp;&nbsp;&nbsp;</p>
227
- <p> &nbsp;&nbsp;&nbsp; <a href="https://www.linkedin.com/shareArticle?mini=true&url=https%3A//github.com/SuperPWA/Super-Progressive-Web-Apps/&title=Super%20Progressive%20Web%20Apps&summary=Super%20Progressive%20Web%20Apps%20helps%20to%20convert%20your%20WordPress%20website%20into%20PWA%20%23SuperPWA&source=GitHub" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174857.svg" title="Share SuperPWA on LinkedIn" width=20 height=20> Share on LinkedIn</a>&nbsp;&nbsp;&nbsp;&nbsp;</p>
228
-
229
- ## 📇 Changelog
230
- [superpwa.com/changelog/](https://superpwa.com/changelog/?utm_source=GitHub&utm_medium=Readme-Changelog).
231
-
232
- Emoji Credits : [Emojipedia](emojipedia.org)
233
- Social Media Icon Credits : [Flaticon](flaticon.com)
234
-
235
- **[⬆ back to top](#super-progressive-web-apps)**
 
 
 
 
1
+ **Help decide on the future of SuperPWA**
2
+ We are looking for your input to decide on the future of SuperPWA. If you wish to acquire SuperPWA as a whole and continue it's development or if you are interested in a premium version of the plugin with extended features, [please fill in the form and let us know](https://superpwa.com/superpwa-2-1/?utm_source=github&utm_medium=description-future).
3
+
4
+ # Super Progressive Web Apps
5
+ <p>
6
+ <a href="https://twitter.com/intent/follow?screen_name=superpwa">
7
+ <img src="https://img.shields.io/twitter/follow/superpwa.svg?style=social&logo=twitter" alt="follow SuperPWA on Twitter">
8
+ </a>
9
+ <a href="https://github.com/SuperPWA/Super-Progressive-Web-Apps">
10
+ <img src="https://img.shields.io/github/stars/SuperPWA/Super-Progressive-Web-Apps.svg?style=social&logo=github&label=SuperPWA" alt="Star Super Progressive Web Apps">
11
+ </a>
12
+
13
+
14
+ </p>
15
+
16
+ <p align="center">
17
+ <a href="https://superpwa.com/?utm_source=GitHub&utm_medium=Readme-SuperPWALogo">
18
+ <img src="https://pbs.twimg.com/profile_images/975224418543681536/X9-CESOD_400x400.jpg" alt="Super Progressive Web Apps" width=175 height=175>
19
+ </a>
20
+
21
+ <h3 align="center">Super Progressive Web Apps</h3>
22
+
23
+ <p align="center">
24
+ SuperPWA helps to convert your WordPress website into Progressive Web Apps easily.
25
+ <br>
26
+ <br>
27
+ <a href="https://superpwa.com/?utm_source=GitHub&utm_medium=Readme-viewWeb"><strong>Visit Website »</strong></a>
28
+ <br>
29
+ <br>
30
+ <a href="https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues/new?template=bug.md">Report bug</a>
31
+ ·
32
+ <a href="https://wordpress.org/plugins/super-progressive-web-apps/">WordPress Plugin</a>
33
+ ·
34
+ <a href="https://wordpress.org/support/plugin/super-progressive-web-apps/reviews/">Reviews</a>
35
+ ·
36
+ <a href="https://wordpress.org/plugins/super-progressive-web-apps/#faq">FAQ</a>
37
+ ·
38
+ <a href="#-contributions">Contributions</a>
39
+ </p>
40
+ </p>
41
+
42
+
43
+ <p align="center">
44
+ <a href="https://superpwa.com/?utm_source=GitHub&utm_medium=Readme-LighthouseScore">
45
+ <img src="https://lighthouse-badge.appspot.com?score=100" alt="LightHouse Score">
46
+ </a>
47
+ <a href="https://wordpress.org/plugins/super-progressive-web-apps/">
48
+ <img src="https://img.shields.io/wordpress/plugin/dt/super-progressive-web-apps.svg?style=plastic" alt="Super Progressive Web Apps Downloads">
49
+ </a>
50
+ <a href="https://wordpress.org/plugins/super-progressive-web-apps/">
51
+ <img src="https://img.shields.io/wordpress/plugin/r/super-progressive-web-apps.svg?style=plastic" alt="Super Progressive Web Apps Rating">
52
+ </a>
53
+ <a href="https://wordpress.org/plugins/super-progressive-web-apps/">
54
+ <img src="https://img.shields.io/wordpress/plugin/v/super-progressive-web-apps.svg?style=plastic" alt="Super Progressive Web Apps Version">
55
+ </a>
56
+ <a href="https://wordpress.org/plugins/super-progressive-web-apps/">
57
+ <img src="https://img.shields.io/wordpress/v/super-progressive-web-apps.svg?style=plastic" alt="Super Progressive Web Apps Version">
58
+ </a>
59
+ </p>
60
+
61
+ ## Welcome to the Super PWA GitHub repository
62
+
63
+ ⚡️ Demo : <a href="https://superpwa.com/?utm_source=GitHub&utm_medium=Readme-WelcomeDemo">superpwa.com</a> [Check Video's to know how it works](#videos-on-how-add-to-home-screen--progressive-web-apps-works-on-different-browsers)
64
+
65
+ ## What is Progressive Web Apps
66
+ Progressive Web Apps (PWA) is a new technology that creates a middle ground between a website and a mobile app. They are installed on the phone like a normal app (web app) and can be accessed from the home screen.
67
+
68
+ 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!
69
+
70
+ <a href="https://superpwa.com?utm_source=github&utm_medium=Readme-what-is-pwa">Super Progressive Web Apps</a> makes it easy for you to convert your WordPress website into a Progressive Web App easily!
71
+
72
+ ## Support the project
73
+ If you feel super excited and want to support us in a small way, please consider starring and/or sharing the repo! This helps us getting known and grow the community.
74
+
75
+ <a href="#"><img src="https://raw.githubusercontent.com/josevarghese/Super-Progressive-Web-Apps/master/jose-github-star-gif.gif" alt="Star our repo" width="300px" height="76.95px" /></a>
76
+
77
+ Also you can support us via [following on social media's and share about us](#share-via-social-medias-and-spread-superpwa).
78
+
79
+ ## 🏗 Installation
80
+ 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!
81
+
82
+ 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.
83
+
84
+ ### 💡 Progressive Web App Minimum Requirments
85
+ - [x] Progressive Web Apps require that your WordPress website is served from a secure origin i.e. your website should be HTTPS and not HTTP. If your website isn’t HTTPS, please contact your host about it. You can also ask us [Support Forums](https://wordpress.org/support/plugin/super-progressive-web-apps) if you need help.
86
+ </br>
87
+
88
+ ##### Videos on How Add to Home Screen & Progressive Web Apps works on Different Browsers
89
+
90
+ |<a href="https://www.youtube.com/watch?v=n3TjhNblvqs"><img src="http://i3.ytimg.com/vi/n3TjhNblvqs/maxresdefault.jpg" alt="Google Chrome for Android"/> </br>📽️ Google Chrome for Android| <a href="https://www.youtube.com/watch?v=9v4RwahRQFU"><img src="http://i3.ytimg.com/vi/9v4RwahRQFU/maxresdefault.jpg" alt="Mozilla Firefox for Android" /> </br>📽️ Mozilla Firefox for Android | <a href="https://www.youtube.com/watch?v=V8-AdKxm134"><img src="http://i3.ytimg.com/vi/V8-AdKxm134/maxresdefault.jpg" alt="Microsoft Edge for Android"/> </br>📽️ Microsoft Edge for Android | <a href="https://www.youtube.com/watch?v=Sbhgb6_QKfQ"><img src="http://i3.ytimg.com/vi/Sbhgb6_QKfQ/maxresdefault.jpg" alt="Samung Internet for Android "/> </br>📽️ Samung Internet for Android | <a href="https://www.youtube.com/watch?v=bV8xE6lOdoY"><img src="http://i3.ytimg.com/vi/bV8xE6lOdoY/maxresdefault.jpg" alt="PWA on iOS - Safari Browser"/> </br>📽️ PWA on iOS - Safari Browser |
91
+ | :---------: | :---------: | :---------: | :---------: | :---------: |
92
+ </br>
93
+
94
+ ##### Detailed Documentations for testing PWA on Browsers
95
+
96
+ * [PWA on Chrome for Android](https://superpwa.com/doc/test-pwa-google-chrome/)
97
+ * [PWA on Desktop - Chrome](https://superpwa.com/doc/test-pwa-on-desktop/)
98
+ * [PWA on iOS device - Safari Browser](https://superpwa.com/doc/test-pwa-ios-devices/)
99
+ * [PWA on Microsoft Edge Browser for Android](https://superpwa.com/doc/test-pwa-microsoft-edge/)
100
+ * [PWA on Samsung Internet Browser for Android](https://superpwa.com/doc/test-pwa-samsung-internet-browser/)
101
+
102
+ #### 📦 What's in the box
103
+
104
+ Here are the current features of Super Progressive Web Apps:
105
+
106
+ * Generate a manifest for your website and add it to the head of your website.
107
+ * Set the application icon for your Progressive Web App.
108
+ * Set the background color for the splash screen of your Progressive Web App.
109
+ * Your website will show the "Add to home screen" notice when accessed in a supported browser.
110
+ * Aggressive caching of pages using CacheStorage API.
111
+ * Pages once cached are served even if the user is offline.
112
+ * Set custom offline page: Select the page you want the user to see when a page that isn't in the cache is accessed and the user is offline.
113
+ * New in version 1.2: Support for theme-color.
114
+ * New in version 1.2: Now you can edit the Application Name and Application Short name.
115
+ * New in version 1.2: Set the start page of your PWA.
116
+ * 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.
117
+ * 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.
118
+ * New in version 1.3: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
119
+ * New in version 1.3: Improved in-browser service worker update handling.
120
+ * New in version 1.4: You can now set the default orientation of your PWA. Choose from "any" (Follow Device Orientation), "Portrait" and "Landscape".
121
+ * New in version 1.4: You can now set the theme_color property in the manifest.
122
+ * New in version 1.5: OneSignal integration for Push notifications.
123
+ * New in version 1.6: WordPress Multisite Network compatibility.
124
+ * New in version 1.7: Add-Ons for SuperPWA is here! Ships with [UTM Tracking Add-On](https://superpwa.com/addons/utm-tracking/?utm_source=GitHub&utm_medium=Readme-version) to track visits coming from your PWA.
125
+ * New in version 1.8: Compatibility issues with OneSignal are now resolved!
126
+ * New in version 1.8: New Add-On: [Apple Touch Icons](https://superpwa.com/addons/apple-touch-icons/?utm_source=GitHub&utm_medium=Readme-version) that sets your app icons as Apple Touch Icons.
127
+ * New in version 2.0: SuperPWA is now compatible with WordPress installed in a sub-folder.
128
+ * New in version 2.0: You can now set [display property](https://superpwa.com/doc/web-app-manifest-display-modes/?utm_source=GitHub&utm_medium=Readme-version) from SuperPWA settings.
129
+ * New in version 2.1.1: Support for maskabale icons.
130
+
131
+ #### 🔮 Upcoming features:
132
+ * Offline Indicator Notice.
133
+
134
+ ### Device and Browser Support For PWA
135
+ | | <img src="https://image.flaticon.com/icons/svg/732/732205.svg" alt="Chrome" width="32px" height="32px" /> Chrome | <img src="https://image.flaticon.com/icons/svg/732/732198.svg" alt="Firefox" width="32px" height="32px" /> Firefox | <img src="https://image.flaticon.com/icons/svg/732/732219.svg" alt="Edge" width="32px" height="32px" /> Edge | <img src="https://camo.githubusercontent.com/3fb130c75d01178836d96dcf3baccbe7b95b3642/68747470733a2f2f696d6167652e666c617469636f6e2e636f6d2f69636f6e732f7376672f3733322f3733323233332e737667" alt="Opera" width="32px" height="32px" /> Opera | <img src="https://image.flaticon.com/icons/svg/732/732241.svg" alt="Safari" width="32px" height="32px" /> Safari |<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Samsung_Internet_Logo.png/800px-Samsung_Internet_Logo.png" alt="Samsung" width="32px" height="32px" /> Samsung | <img src="https://upload.wikimedia.org/wikipedia/en/d/d0/UC_Browser_Logo.png" alt="UC Browser" width="32px" height="32px" /> UC Browser | <img src="https://upload.wikimedia.org/wikipedia/en/a/a5/Brave_Software_Logo.png" alt="Brave" width="32px" height="32px" /> Brave |
136
+ | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: |
137
+ | Add to Home Screen | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/123/123381.svg" alt="Beta or Partial Support" width="20px" height="20px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/123/123381.svg" alt="Beta or Partial Support" width="20px" height="20px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> |
138
+ | Service Workers | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> |
139
+ | Web Push & Notifications| <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/123/123381.svg" alt="Beta or Partial Support" width="20px" height="20px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> |
140
+ | Payment Request API | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/876/876101.svg" alt="In Development" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/876/876101.svg" alt="In Development" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> | - | - |
141
+ | Meta Theme Color | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | - | - | - | - | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> | - | <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Yes" width="32px" height="32px" /> |
142
+
143
+ </br>
144
+
145
+ <p align="center">
146
+ <img src="https://image.flaticon.com/icons/svg/144/144008.svg" alt="Supported" width="32px" height="32px" /> Supported
147
+ &nbsp;
148
+ &nbsp;
149
+ &nbsp;
150
+ &nbsp;
151
+ <img src="https://image.flaticon.com/icons/svg/123/123381.svg" alt="Beta or Partial Support" width="32px" height="32px" /> Beta or Partial Support
152
+ &nbsp;
153
+ &nbsp;
154
+ &nbsp;
155
+ &nbsp;
156
+ <img src="https://image.flaticon.com/icons/svg/876/876101.svg" alt="In Development" width="32px" height="32px" /> In Development
157
+ </p>
158
+
159
+
160
+ Progressive web apps need browsers that support manifests and service workers. Currently Google Chrome (version 57+), Chrome for Android (62), Mozilla Firefox (57), Firefox for Android (58) are the major browsers that support PWA.
161
+
162
+ The list is fast growing and is likely to be supported in most major browsers by the end of this year.
163
+
164
+ ### Why Build Progressive Web Apps?
165
+ [![Why Build Progressive Web Apps](http://i3.ytimg.com/vi/1QILz1lAzWY/maxresdefault.jpg)](https://www.youtube.com/embed/1QILz1lAzWY)
166
+
167
+ ### How To Convert Your WordPress Website Into A Progressive Web App
168
+
169
+ #### ⚙️ WordPress Installation
170
+
171
+ * Visit WordPress Admin > **Plugins** > **Add New**
172
+ * Search for **Super Progressive Web Apps**
173
+ * Click "**Install Now**" and then "**Activate**" Super Progressive Web Apps
174
+
175
+ #### ⚙️ To install manually:
176
+
177
+ * Upload super-progressive-web-apps folder to the /wp-content/plugins/ directory on your server
178
+ * Go to WordPress Admin > **Plugins**
179
+ * Activate **Super Progressive Web Apps** plugin from the list.
180
+
181
+ #### Customizing Your Progressive Web App
182
+
183
+ Your Progressive Web App should be ready to test with the default settings upon activation. You can customize it further and make it truly your own.
184
+
185
+ * Go to WordPress Admin > "**SuperPWA**" > **Settings**
186
+ * Set a Background Color for the splash screen to be shown when your PWA is opened on a mobile device.
187
+ * Set the Application Icon. This will be the icon of your PWA when it is added to the homescreen in a mobile device. The icon must be a PNG image and exactly 192 x 192 pixels in size.
188
+ * Set the Offline Page. This page will be displayed if the user is offline and the page he requested is not cached already. Ideally you should create a dedicated WordPress page and set it here. Within the page you create, you could add a note that reads, "It looks like you are offline and the page you requested is not available right now. Please check back again once you are online.".
189
+ * Click "Save Settings".
190
+
191
+ #### Testing Your Progressive Web App
192
+
193
+ * Open a supported browser in a supported device (for eg: Chrome for Android (62 or higher) in an Android device)
194
+ * Enter your website and wait till it fully loads
195
+ * You should see a pop-up that has your Application Icon and a button that reads "ADD TO HOME SCREEN".
196
+ * Click on it and your PWA will be added to your home screen. Wait for the install to complete.
197
+ * Go to your home screen and open your PWA. Browse into a few pages if you like. Close the App.
198
+ * Disconnect from the internet and now open your PWA again. You should be able to see all the pages that you previously browsed.
199
+ * Try visiting a page that you did not visit before. You should see the page you set as your "Offline Page" in the settings of SuperPWA.
200
+
201
+
202
+ ### 🤝 About us
203
+ > We are a duo who got excited about the idea. Our mission is simple: Help you build an awesome PWA that your users would want to have on their home screen. When we first heard about PWA we wanted to learn everything about it. We have spent countless hours learning and wants to share it with the world. Please give us your constructive feedback and support.
204
+
205
+ ## ⛷️ Support
206
+ This is a developer's portal for Super Progressive Web Apps and should not be used for support. Please visit the
207
+ [Support Forums](https://wordpress.org/support/plugin/super-progressive-web-apps).
208
+
209
+ ## 🐛 Reporting bugs
210
+ If you ever get stuck, we are here to watch your back! [Open a New Support Topic](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!
211
+
212
+ ## 🎍 Contributions
213
+ Anyone is welcome to contribute to Super PWA to make it SUPER.
214
+
215
+ There are various ways you can contribute:
216
+
217
+ * [Raise an issue](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues) on GitHub.
218
+ * Follow and Engage with us on Social Media
219
+
220
+ &nbsp;&nbsp;&nbsp; <a href="https://twitter.com/intent/follow?screen_name=superpwa" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174876.svg" title="Follow SuperPWA on Twitter" width=35 height=35></a>&nbsp;&nbsp;&nbsp;&nbsp;
221
+ <a href="https://www.youtube.com/channel/UCMFlNeutNCwTNls186moUUA" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174883.svg" title="Follow SuperPWA on YouTube" width=35 height=35></a>&nbsp;&nbsp;&nbsp;&nbsp;
222
+ <a href="https://www.facebook.com/SuperPWA/" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174848.svg" title="Follow SuperPWA on Facebook" width=35 height=35></a>&nbsp;&nbsp;&nbsp;&nbsp;
223
+ <a href="https://www.instagram.com/superpwa/" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174855.svg" title="Follow SuperPWA on Instagram" width=35 height=35></a>&nbsp;&nbsp;&nbsp;&nbsp;
224
+
225
+ * Send us a Pull Request with your bug fixes and/or new features.
226
+ * Provide feedback and [suggestions on enhancements](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues?direction=desc&labels=Enhancement&page=1&sort=created&state=open).
227
+ * ##### Share via Social Media's and spread SuperPWA
228
+
229
+ &nbsp;&nbsp;&nbsp; <a href="https://twitter.com/home?status=Super%20Progressive%20Web%20Apps%20helps%20to%20convert%20your%20WordPress%20website%20into%20PWA%20%23SuperPWA%20https%3A//github.com/SuperPWA/Super-Progressive-Web-Apps/%20%40SuperPWA" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174876.svg" title="Share SuperPWA on Twitter" width=20 height=20> Share on Twitter </a>&nbsp;&nbsp;&nbsp;&nbsp;
230
+ <p> &nbsp;&nbsp;&nbsp; <a href="https://www.facebook.com/sharer/sharer.php?u=https%3A//github.com/SuperPWA/Super-Progressive-Web-Apps/" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174848.svg" title="Follow SuperPWA on Facebook" width=20 height=20> Share on Facebook </a>&nbsp;&nbsp;&nbsp;&nbsp;</p>
231
+ <p> &nbsp;&nbsp;&nbsp; <a href="https://www.linkedin.com/shareArticle?mini=true&url=https%3A//github.com/SuperPWA/Super-Progressive-Web-Apps/&title=Super%20Progressive%20Web%20Apps&summary=Super%20Progressive%20Web%20Apps%20helps%20to%20convert%20your%20WordPress%20website%20into%20PWA%20%23SuperPWA&source=GitHub" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174857.svg" title="Share SuperPWA on LinkedIn" width=20 height=20> Share on LinkedIn</a>&nbsp;&nbsp;&nbsp;&nbsp;</p>
232
+
233
+ ## 📇 Changelog
234
+ [superpwa.com/changelog/](https://superpwa.com/changelog/?utm_source=GitHub&utm_medium=Readme-Changelog).
235
+
236
+ Emoji Credits : [Emojipedia](emojipedia.org)
237
+ Social Media Icon Credits : [Flaticon](flaticon.com)
238
+
239
+ **[⬆ back to top](#super-progressive-web-apps)**
addons/apple-touch-icons.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php
2
- /**
3
- * Apple Touch Icons
4
- *
5
- * @since 1.8
6
- *
7
- * @function superpwa_ati_add_apple_touch_icons() Add Apple Touch Icons to the wp_head
8
- */
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) ) exit;
12
-
13
- /**
14
- * Add Apple Touch Icons to the wp_head
15
- *
16
- * Uses the Application Icon and Splash Screen Icon for SuperPWA > Settings
17
- * and adds them to wp_head using the superpwa_wp_head_tags filter.
18
- *
19
- * @param (string) $tags HTML element tags passed on by superpwa_wp_head_tags
20
- *
21
- * @return (string) Appends the Apple Touch Icons to the existing tag string
22
- *
23
- * @since 1.8
24
- */
25
- function superpwa_ati_add_apple_touch_icons( $tags ) {
26
-
27
- // Get the icons added via SuperPWA > Settings
28
- $icons = superpwa_get_pwa_icons();
29
-
30
- foreach( $icons as $icon ) {
31
- $tags .= '<link rel="apple-touch-icon" sizes="' . $icon['sizes'] . '" href="' . $icon['src'] . '">' . PHP_EOL;
32
- }
33
-
34
- return $tags;
35
- }
36
  add_filter( 'superpwa_wp_head_tags', 'superpwa_ati_add_apple_touch_icons' );
1
+ <?php
2
+ /**
3
+ * Apple Touch Icons
4
+ *
5
+ * @since 1.8
6
+ *
7
+ * @function superpwa_ati_add_apple_touch_icons() Add Apple Touch Icons to the wp_head
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ /**
14
+ * Add Apple Touch Icons to the wp_head
15
+ *
16
+ * Uses the Application Icon and Splash Screen Icon for SuperPWA > Settings
17
+ * and adds them to wp_head using the superpwa_wp_head_tags filter.
18
+ *
19
+ * @param (string) $tags HTML element tags passed on by superpwa_wp_head_tags
20
+ *
21
+ * @return (string) Appends the Apple Touch Icons to the existing tag string
22
+ *
23
+ * @since 1.8
24
+ */
25
+ function superpwa_ati_add_apple_touch_icons( $tags ) {
26
+
27
+ // Get the icons added via SuperPWA > Settings
28
+ $icons = superpwa_get_pwa_icons();
29
+
30
+ foreach( $icons as $icon ) {
31
+ $tags .= '<link rel="apple-touch-icon" sizes="' . $icon['sizes'] . '" href="' . $icon['src'] . '">' . PHP_EOL;
32
+ }
33
+
34
+ return $tags;
35
+ }
36
  add_filter( 'superpwa_wp_head_tags', 'superpwa_ati_add_apple_touch_icons' );
addons/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
addons/utm-tracking.php CHANGED
@@ -1,397 +1,397 @@
1
- <?php
2
- /**
3
- * UTM Tracking
4
- *
5
- * @since 1.7
6
- *
7
- * @function superpwa_utm_tracking_sub_menu() Add sub-menu page for UTM Tracking
8
- * @function superpwa_utm_tracking_get_settings() Get UTM Tracking settings
9
- * @function superpwa_utm_tracking_for_start_url() Add UTM Tracking to the start_url
10
- * @function superpwa_utm_tracking_save_settings_todo() Todo list after saving UTM Tracking settings
11
- * @function superpwa_utm_tracking_deactivate_todo() Deactivation Todo
12
- * @function superpwa_utm_tracking_register_settings() Register UTM Tracking settings
13
- * @function superpwa_utm_tracking_validater_sanitizer() Validate and sanitize user input
14
- * @function superpwa_utm_tracking_section_cb() Callback function for UTM Tracking section
15
- * @function superpwa_utm_tracking_start_url_cb() Current Start URL
16
- * @function superpwa_utm_tracking_source_cb() Campaign Source
17
- * @function superpwa_utm_tracking_medium_cb() Campaign Medium
18
- * @function superpwa_utm_tracking_name_cb() Campaign Name
19
- * @function superpwa_utm_tracking_term_cb() Campaign Term
20
- * @function superpwa_utm_tracking_content_cb() Campaign Content
21
- * @function superpwa_utm_tracking_interface_render() UTM Tracking UI renderer
22
- */
23
-
24
- // Exit if accessed directly
25
- if ( ! defined( 'ABSPATH' ) ) exit;
26
-
27
- /**
28
- * Add sub-menu page for UTM Tracking
29
- *
30
- * @since 1.7
31
- */
32
- function superpwa_utm_tracking_sub_menu() {
33
-
34
- // UTM Tracking sub-menu
35
- add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), __( 'UTM Tracking', 'super-progressive-web-apps' ), 'manage_options', 'superpwa-utm-tracking', 'superpwa_utm_tracking_interface_render' );
36
- }
37
- add_action( 'admin_menu', 'superpwa_utm_tracking_sub_menu' );
38
-
39
- /**
40
- * Get UTM Tracking settings
41
- *
42
- * @since 1.7
43
- */
44
- function superpwa_utm_tracking_get_settings() {
45
-
46
- $defaults = array(
47
- 'utm_source' => 'superpwa',
48
- 'utm_medium' => 'superpwa',
49
- 'utm_campaign' => 'superpwa',
50
- );
51
-
52
- return get_option( 'superpwa_utm_tracking_settings', $defaults );
53
- }
54
-
55
- /**
56
- * Add UTM Tracking to the start_url
57
- *
58
- * Hooks onto the superpwa_manifest_start_url filter to add the
59
- * UTM tracking parameters to the start_url
60
- *
61
- * Example: https://superpwa.com/?utm_source=superpwa&utm_medium=medium&utm_campaign=name&utm_term=terms&utm_content=content
62
- *
63
- * @param $start_url (string) the start_url for manifest from superpwa_get_start_url()
64
- * @return (string) Filtered start_url with UTM tracking added
65
- *
66
- * @since 1.7
67
- */
68
- function superpwa_utm_tracking_for_start_url( $start_url ) {
69
-
70
- // Get UTM Tracking settings
71
- $utm_params = superpwa_utm_tracking_get_settings();
72
-
73
- // Add the initial '/?'
74
- $start_url = trailingslashit( $start_url ) . '?';
75
-
76
- // Build the URL
77
- foreach ( $utm_params as $param => $value ) {
78
-
79
- if ( ! empty( $value ) ) {
80
- $start_url = $start_url . $param . '=' . rawurlencode( $value ) . '&';
81
- }
82
- }
83
-
84
- // Remove trailing '&'
85
- return rtrim( $start_url, '&' );
86
- }
87
- add_filter( 'superpwa_manifest_start_url', 'superpwa_utm_tracking_for_start_url' );
88
-
89
- /**
90
- * Todo list after saving UTM Tracking settings
91
- *
92
- * Regenerate manifest when settings are saved.
93
- * Also used when add-on is activated and deactivated.
94
- *
95
- * @since 1.7
96
- */
97
- function superpwa_utm_tracking_save_settings_todo() {
98
-
99
- // Regenerate manifest
100
- superpwa_generate_manifest();
101
- }
102
- add_action( 'add_option_superpwa_utm_tracking_settings', 'superpwa_utm_tracking_save_settings_todo' );
103
- add_action( 'update_option_superpwa_utm_tracking_settings', 'superpwa_utm_tracking_save_settings_todo' );
104
- add_action( 'superpwa_addon_activated_utm_tracking', 'superpwa_utm_tracking_save_settings_todo' );
105
-
106
- /**
107
- * Deactivation Todo
108
- *
109
- * Unhook the filter and regenerate manifest
110
- *
111
- * @since 1.7
112
- */
113
- function superpwa_utm_tracking_deactivate_todo() {
114
-
115
- // Unhook the UTM tracking params filter
116
- remove_filter( 'superpwa_manifest_start_url', 'superpwa_utm_tracking_for_start_url' );
117
-
118
- // Regenerate manifest
119
- superpwa_generate_manifest();
120
- }
121
- add_action( 'superpwa_addon_deactivated_utm_tracking', 'superpwa_utm_tracking_deactivate_todo' );
122
-
123
- /**
124
- * Register UTM Tracking settings
125
- *
126
- * @since 1.7
127
- */
128
- function superpwa_utm_tracking_register_settings() {
129
-
130
- // Register Setting
131
- register_setting(
132
- 'superpwa_utm_tracking_settings_group', // Group name
133
- 'superpwa_utm_tracking_settings', // Setting name = html form <input> name on settings form
134
- 'superpwa_utm_tracking_validater_sanitizer' // Input validator and sanitizer
135
- );
136
-
137
- // UTM Tracking
138
- add_settings_section(
139
- 'superpwa_utm_tracking_section', // ID
140
- __return_false(), // Title
141
- 'superpwa_utm_tracking_section_cb', // Callback Function
142
- 'superpwa_utm_tracking_section' // Page slug
143
- );
144
-
145
- // Current Start URL
146
- add_settings_field(
147
- 'superpwa_utm_tracking_start_url', // ID
148
- __('Current Start URL', 'super-progressive-web-apps'), // Title
149
- 'superpwa_utm_tracking_start_url_cb', // CB
150
- 'superpwa_utm_tracking_section', // Page slug
151
- 'superpwa_utm_tracking_section' // Settings Section ID
152
- );
153
-
154
- // Campaign Source
155
- add_settings_field(
156
- 'superpwa_utm_tracking_source', // ID
157
- __('Campaign Source', 'super-progressive-web-apps'), // Title
158
- 'superpwa_utm_tracking_source_cb', // CB
159
- 'superpwa_utm_tracking_section', // Page slug
160
- 'superpwa_utm_tracking_section' // Settings Section ID
161
- );
162
-
163
- // Campaign Medium
164
- add_settings_field(
165
- 'superpwa_utm_tracking_medium', // ID
166
- __('Campaign Medium', 'super-progressive-web-apps'), // Title
167
- 'superpwa_utm_tracking_medium_cb', // CB
168
- 'superpwa_utm_tracking_section', // Page slug
169
- 'superpwa_utm_tracking_section' // Settings Section ID
170
- );
171
-
172
- // Campaign Name
173
- add_settings_field(
174
- 'superpwa_utm_tracking_name', // ID
175
- __('Campaign Name', 'super-progressive-web-apps'), // Title
176
- 'superpwa_utm_tracking_name_cb', // CB
177
- 'superpwa_utm_tracking_section', // Page slug
178
- 'superpwa_utm_tracking_section' // Settings Section ID
179
- );
180
-
181
- // Campaign Term
182
- add_settings_field(
183
- 'superpwa_utm_tracking_term', // ID
184
- __('Campaign Term', 'super-progressive-web-apps'), // Title
185
- 'superpwa_utm_tracking_term_cb', // CB
186
- 'superpwa_utm_tracking_section', // Page slug
187
- 'superpwa_utm_tracking_section' // Settings Section ID
188
- );
189
-
190
- // Campaign Content
191
- add_settings_field(
192
- 'superpwa_utm_tracking_content', // ID
193
- __('Campaign Content', 'super-progressive-web-apps'), // Title
194
- 'superpwa_utm_tracking_content_cb', // CB
195
- 'superpwa_utm_tracking_section', // Page slug
196
- 'superpwa_utm_tracking_section' // Settings Section ID
197
- );
198
- }
199
- add_action( 'admin_init', 'superpwa_utm_tracking_register_settings' );
200
-
201
- /**
202
- * Validate and sanitize user input
203
- *
204
- * @since 1.7
205
- */
206
- function superpwa_utm_tracking_validater_sanitizer( $settings ) {
207
-
208
- // Sanitize and validate campaign source. Campaign source cannot be empty.
209
- $settings['utm_source'] = sanitize_text_field( $settings['utm_source'] ) == '' ? 'superpwa' : sanitize_text_field( $settings['utm_source'] );
210
-
211
- // Sanitize campaign medium
212
- $settings['utm_medium'] = sanitize_text_field( $settings['utm_medium'] ) == '' ? 'superpwa' : sanitize_text_field( $settings['utm_medium'] );
213
-
214
- // Sanitize campaign name
215
- $settings['utm_campaign'] = sanitize_text_field( $settings['utm_campaign'] ) == '' ? 'superpwa' : sanitize_text_field( $settings['utm_campaign'] );
216
-
217
- // Sanitize campaign term
218
- $settings['utm_term'] = sanitize_text_field( $settings['utm_term'] );
219
-
220
- // Sanitize campaign medium
221
- $settings['utm_content'] = sanitize_text_field( $settings['utm_content'] );
222
-
223
- return $settings;
224
- }
225
-
226
- /**
227
- * Callback function for UTM Tracking section
228
- *
229
- * @since 1.7
230
- */
231
- function superpwa_utm_tracking_section_cb() {
232
-
233
- // Get add-on info
234
- $addon_utm_tracking = superpwa_get_addons( 'utm_tracking' );
235
-
236
- printf( '<p>' . __( 'This add-on automatically adds UTM campaign parameters to the <code>Start Page</code> URL in your <a href="%s" target="_blank">manifest</a>. This will help you identify visitors coming specifically from your app. <a href="%s" target="_blank">Read more</a> about UTM Tracking.', 'super-progressive-web-apps' ) . '</p>', superpwa_manifest( 'src' ), $addon_utm_tracking['link'] . '?utm_source=superpwa-plugin&utm_medium=utm-tracking-settings' );
237
- }
238
-
239
- /**
240
- * Current Start URL
241
- *
242
- * @since 1.7
243
- */
244
- function superpwa_utm_tracking_start_url_cb() {
245
-
246
- echo '<code style="word-break: break-all;">' . superpwa_get_start_url( true ) . '</code>';
247
- }
248
-
249
- /**
250
- * Campaign Source
251
- *
252
- * @since 1.7
253
- */
254
- function superpwa_utm_tracking_source_cb() {
255
-
256
- // Get Settings
257
- $settings = superpwa_utm_tracking_get_settings(); ?>
258
-
259
- <fieldset>
260
-
261
- <input type="text" name="superpwa_utm_tracking_settings[utm_source]" class="regular-text" value="<?php if ( isset( $settings['utm_source'] ) && ( ! empty($settings['utm_source']) ) ) echo esc_attr( $settings['utm_source'] ); ?>"/>
262
-
263
- </fieldset>
264
-
265
- <p class="description">
266
- <?php _e( 'Campaign Source is mandatory and defaults to <code>superpwa</code>.', 'super-progressive-web-apps' ); ?>
267
- </p>
268
-
269
- <?php
270
- }
271
-
272
- /**
273
- * Campaign Medium
274
- *
275
- * @since 1.7
276
- */
277
- function superpwa_utm_tracking_medium_cb() {
278
-
279
- // Get Settings
280
- $settings = superpwa_utm_tracking_get_settings(); ?>
281
-
282
- <fieldset>
283
-
284
- <input type="text" name="superpwa_utm_tracking_settings[utm_medium]" class="regular-text" value="<?php if ( isset( $settings['utm_medium'] ) && ( ! empty($settings['utm_medium']) ) ) echo esc_attr( $settings['utm_medium'] ); ?>"/>
285
-
286
- </fieldset>
287
-
288
- <p class="description">
289
- <?php _e( 'Campaign Source is mandatory and defaults to <code>superpwa</code>.', 'super-progressive-web-apps' ); ?>
290
- </p>
291
-
292
- <?php
293
- }
294
-
295
- /**
296
- * Campaign Name
297
- *
298
- * @since 1.7
299
- */
300
- function superpwa_utm_tracking_name_cb() {
301
-
302
- // Get Settings
303
- $settings = superpwa_utm_tracking_get_settings(); ?>
304
-
305
- <fieldset>
306
-
307
- <input type="text" name="superpwa_utm_tracking_settings[utm_campaign]" class="regular-text" value="<?php if ( isset( $settings['utm_campaign'] ) && ( ! empty($settings['utm_campaign']) ) ) echo esc_attr( $settings['utm_campaign'] ); ?>"/>
308
-
309
- </fieldset>
310
-
311
- <p class="description">
312
- <?php _e( 'Campaign Source is mandatory and defaults to <code>superpwa</code>.', 'super-progressive-web-apps' ); ?>
313
- </p>
314
-
315
- <?php
316
- }
317
-
318
- /**
319
- * Campaign Term
320
- *
321
- * @since 1.7
322
- */
323
- function superpwa_utm_tracking_term_cb() {
324
-
325
- // Get Settings
326
- $settings = superpwa_utm_tracking_get_settings(); ?>
327
-
328
- <fieldset>
329
-
330
- <input type="text" name="superpwa_utm_tracking_settings[utm_term]" placeholder="Optional" class="regular-text" value="<?php if ( isset( $settings['utm_term'] ) && ( ! empty($settings['utm_term']) ) ) echo esc_attr( $settings['utm_term'] ); ?>"/>
331
-
332
- </fieldset>
333
-
334
- <?php
335
- }
336
-
337
- /**
338
- * Campaign Content
339
- *
340
- * @since 1.7
341
- */
342
- function superpwa_utm_tracking_content_cb() {
343
-
344
- // Get Settings
345
- $settings = superpwa_utm_tracking_get_settings(); ?>
346
-
347
- <fieldset>
348
-
349
- <input type="text" name="superpwa_utm_tracking_settings[utm_content]" placeholder="Optional" class="regular-text" value="<?php if ( isset( $settings['utm_content'] ) && ( ! empty($settings['utm_content']) ) ) echo esc_attr( $settings['utm_content'] ); ?>"/>
350
-
351
- </fieldset>
352
-
353
- <?php
354
- }
355
-
356
- /**
357
- * UTM Tracking UI renderer
358
- *
359
- * @since 1.7
360
- */
361
- function superpwa_utm_tracking_interface_render() {
362
-
363
- // Authentication
364
- if ( ! current_user_can( 'manage_options' ) ) {
365
- return;
366
- }
367
-
368
- // Handing save settings
369
- if ( isset( $_GET['settings-updated'] ) ) {
370
-
371
- // Add settings saved message with the class of "updated"
372
- add_settings_error( 'superpwa_settings_group', 'superpwa_utm_tracking_settings_saved_message', __( 'Settings saved.', 'super-progressive-web-apps' ), 'updated' );
373
-
374
- // Show Settings Saved Message
375
- settings_errors( 'superpwa_settings_group' );
376
- }
377
-
378
- ?>
379
-
380
- <div class="wrap">
381
- <h1><?php _e( 'UTM Tracking for', 'super-progressive-web-apps' ); ?> SuperPWA <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
382
-
383
- <form action="options.php" method="post" enctype="multipart/form-data">
384
- <?php
385
- // Output nonce, action, and option_page fields for a settings page.
386
- settings_fields( 'superpwa_utm_tracking_settings_group' );
387
-
388
- // Status
389
- do_settings_sections( 'superpwa_utm_tracking_section' ); // Page slug
390
-
391
- // Output save settings button
392
- submit_button( __('Save Settings', 'super-progressive-web-apps') );
393
- ?>
394
- </form>
395
- </div>
396
- <?php
397
  }
1
+ <?php
2
+ /**
3
+ * UTM Tracking
4
+ *
5
+ * @since 1.7
6
+ *
7
+ * @function superpwa_utm_tracking_sub_menu() Add sub-menu page for UTM Tracking
8
+ * @function superpwa_utm_tracking_get_settings() Get UTM Tracking settings
9
+ * @function superpwa_utm_tracking_for_start_url() Add UTM Tracking to the start_url
10
+ * @function superpwa_utm_tracking_save_settings_todo() Todo list after saving UTM Tracking settings
11
+ * @function superpwa_utm_tracking_deactivate_todo() Deactivation Todo
12
+ * @function superpwa_utm_tracking_register_settings() Register UTM Tracking settings
13
+ * @function superpwa_utm_tracking_validater_sanitizer() Validate and sanitize user input
14
+ * @function superpwa_utm_tracking_section_cb() Callback function for UTM Tracking section
15
+ * @function superpwa_utm_tracking_start_url_cb() Current Start URL
16
+ * @function superpwa_utm_tracking_source_cb() Campaign Source
17
+ * @function superpwa_utm_tracking_medium_cb() Campaign Medium
18
+ * @function superpwa_utm_tracking_name_cb() Campaign Name
19
+ * @function superpwa_utm_tracking_term_cb() Campaign Term
20
+ * @function superpwa_utm_tracking_content_cb() Campaign Content
21
+ * @function superpwa_utm_tracking_interface_render() UTM Tracking UI renderer
22
+ */
23
+
24
+ // Exit if accessed directly
25
+ if ( ! defined( 'ABSPATH' ) ) exit;
26
+
27
+ /**
28
+ * Add sub-menu page for UTM Tracking
29
+ *
30
+ * @since 1.7
31
+ */
32
+ function superpwa_utm_tracking_sub_menu() {
33
+
34
+ // UTM Tracking sub-menu
35
+ add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), __( 'UTM Tracking', 'super-progressive-web-apps' ), 'manage_options', 'superpwa-utm-tracking', 'superpwa_utm_tracking_interface_render' );
36
+ }
37
+ add_action( 'admin_menu', 'superpwa_utm_tracking_sub_menu' );
38
+
39
+ /**
40
+ * Get UTM Tracking settings
41
+ *
42
+ * @since 1.7
43
+ */
44
+ function superpwa_utm_tracking_get_settings() {
45
+
46
+ $defaults = array(
47
+ 'utm_source' => 'superpwa',
48
+ 'utm_medium' => 'superpwa',
49
+ 'utm_campaign' => 'superpwa',
50
+ );
51
+
52
+ return get_option( 'superpwa_utm_tracking_settings', $defaults );
53
+ }
54
+
55
+ /**
56
+ * Add UTM Tracking to the start_url
57
+ *
58
+ * Hooks onto the superpwa_manifest_start_url filter to add the
59
+ * UTM tracking parameters to the start_url
60
+ *
61
+ * Example: https://superpwa.com/?utm_source=superpwa&utm_medium=medium&utm_campaign=name&utm_term=terms&utm_content=content
62
+ *
63
+ * @param $start_url (string) the start_url for manifest from superpwa_get_start_url()
64
+ * @return (string) Filtered start_url with UTM tracking added
65
+ *
66
+ * @since 1.7
67
+ */
68
+ function superpwa_utm_tracking_for_start_url( $start_url ) {
69
+
70
+ // Get UTM Tracking settings
71
+ $utm_params = superpwa_utm_tracking_get_settings();
72
+
73
+ // Add the initial '/?'
74
+ $start_url = trailingslashit( $start_url ) . '?';
75
+
76
+ // Build the URL
77
+ foreach ( $utm_params as $param => $value ) {
78
+
79
+ if ( ! empty( $value ) ) {
80
+ $start_url = $start_url . $param . '=' . rawurlencode( $value ) . '&';
81
+ }
82
+ }
83
+
84
+ // Remove trailing '&'
85
+ return rtrim( $start_url, '&' );
86
+ }
87
+ add_filter( 'superpwa_manifest_start_url', 'superpwa_utm_tracking_for_start_url' );
88
+
89
+ /**
90
+ * Todo list after saving UTM Tracking settings
91
+ *
92
+ * Regenerate manifest when settings are saved.
93
+ * Also used when add-on is activated and deactivated.
94
+ *
95
+ * @since 1.7
96
+ */
97
+ function superpwa_utm_tracking_save_settings_todo() {
98
+
99
+ // Regenerate manifest
100
+ superpwa_generate_manifest();
101
+ }
102
+ add_action( 'add_option_superpwa_utm_tracking_settings', 'superpwa_utm_tracking_save_settings_todo' );
103
+ add_action( 'update_option_superpwa_utm_tracking_settings', 'superpwa_utm_tracking_save_settings_todo' );
104
+ add_action( 'superpwa_addon_activated_utm_tracking', 'superpwa_utm_tracking_save_settings_todo' );
105
+
106
+ /**
107
+ * Deactivation Todo
108
+ *
109
+ * Unhook the filter and regenerate manifest
110
+ *
111
+ * @since 1.7
112
+ */
113
+ function superpwa_utm_tracking_deactivate_todo() {
114
+
115
+ // Unhook the UTM tracking params filter
116
+ remove_filter( 'superpwa_manifest_start_url', 'superpwa_utm_tracking_for_start_url' );
117
+
118
+ // Regenerate manifest
119
+ superpwa_generate_manifest();
120
+ }
121
+ add_action( 'superpwa_addon_deactivated_utm_tracking', 'superpwa_utm_tracking_deactivate_todo' );
122
+
123
+ /**
124
+ * Register UTM Tracking settings
125
+ *
126
+ * @since 1.7
127
+ */
128
+ function superpwa_utm_tracking_register_settings() {
129
+
130
+ // Register Setting
131
+ register_setting(
132
+ 'superpwa_utm_tracking_settings_group', // Group name
133
+ 'superpwa_utm_tracking_settings', // Setting name = html form <input> name on settings form
134
+ 'superpwa_utm_tracking_validater_sanitizer' // Input validator and sanitizer
135
+ );
136
+
137
+ // UTM Tracking
138
+ add_settings_section(
139
+ 'superpwa_utm_tracking_section', // ID
140
+ __return_false(), // Title
141
+ 'superpwa_utm_tracking_section_cb', // Callback Function
142
+ 'superpwa_utm_tracking_section' // Page slug
143
+ );
144
+
145
+ // Current Start URL
146
+ add_settings_field(
147
+ 'superpwa_utm_tracking_start_url', // ID
148
+ __('Current Start URL', 'super-progressive-web-apps'), // Title
149
+ 'superpwa_utm_tracking_start_url_cb', // CB
150
+ 'superpwa_utm_tracking_section', // Page slug
151
+ 'superpwa_utm_tracking_section' // Settings Section ID
152
+ );
153
+
154
+ // Campaign Source
155
+ add_settings_field(
156
+ 'superpwa_utm_tracking_source', // ID
157
+ __('Campaign Source', 'super-progressive-web-apps'), // Title
158
+ 'superpwa_utm_tracking_source_cb', // CB
159
+ 'superpwa_utm_tracking_section', // Page slug
160
+ 'superpwa_utm_tracking_section' // Settings Section ID
161
+ );
162
+
163
+ // Campaign Medium
164
+ add_settings_field(
165
+ 'superpwa_utm_tracking_medium', // ID
166
+ __('Campaign Medium', 'super-progressive-web-apps'), // Title
167
+ 'superpwa_utm_tracking_medium_cb', // CB
168
+ 'superpwa_utm_tracking_section', // Page slug
169
+ 'superpwa_utm_tracking_section' // Settings Section ID
170
+ );
171
+
172
+ // Campaign Name
173
+ add_settings_field(
174
+ 'superpwa_utm_tracking_name', // ID
175
+ __('Campaign Name', 'super-progressive-web-apps'), // Title
176
+ 'superpwa_utm_tracking_name_cb', // CB
177
+ 'superpwa_utm_tracking_section', // Page slug
178
+ 'superpwa_utm_tracking_section' // Settings Section ID
179
+ );
180
+
181
+ // Campaign Term
182
+ add_settings_field(
183
+ 'superpwa_utm_tracking_term', // ID
184
+ __('Campaign Term', 'super-progressive-web-apps'), // Title
185
+ 'superpwa_utm_tracking_term_cb', // CB
186
+ 'superpwa_utm_tracking_section', // Page slug
187
+ 'superpwa_utm_tracking_section' // Settings Section ID
188
+ );
189
+
190
+ // Campaign Content
191
+ add_settings_field(
192
+ 'superpwa_utm_tracking_content', // ID
193
+ __('Campaign Content', 'super-progressive-web-apps'), // Title
194
+ 'superpwa_utm_tracking_content_cb', // CB
195
+ 'superpwa_utm_tracking_section', // Page slug
196
+ 'superpwa_utm_tracking_section' // Settings Section ID
197
+ );
198
+ }
199
+ add_action( 'admin_init', 'superpwa_utm_tracking_register_settings' );
200
+
201
+ /**
202
+ * Validate and sanitize user input
203
+ *
204
+ * @since 1.7
205
+ */
206
+ function superpwa_utm_tracking_validater_sanitizer( $settings ) {
207
+
208
+ // Sanitize and validate campaign source. Campaign source cannot be empty.
209
+ $settings['utm_source'] = sanitize_text_field( $settings['utm_source'] ) == '' ? 'superpwa' : sanitize_text_field( $settings['utm_source'] );
210
+
211
+ // Sanitize campaign medium
212
+ $settings['utm_medium'] = sanitize_text_field( $settings['utm_medium'] ) == '' ? 'superpwa' : sanitize_text_field( $settings['utm_medium'] );
213
+
214
+ // Sanitize campaign name
215
+ $settings['utm_campaign'] = sanitize_text_field( $settings['utm_campaign'] ) == '' ? 'superpwa' : sanitize_text_field( $settings['utm_campaign'] );
216
+
217
+ // Sanitize campaign term
218
+ $settings['utm_term'] = sanitize_text_field( $settings['utm_term'] );
219
+
220
+ // Sanitize campaign medium
221
+ $settings['utm_content'] = sanitize_text_field( $settings['utm_content'] );
222
+
223
+ return $settings;
224
+ }
225
+
226
+ /**
227
+ * Callback function for UTM Tracking section
228
+ *
229
+ * @since 1.7
230
+ */
231
+ function superpwa_utm_tracking_section_cb() {
232
+
233
+ // Get add-on info
234
+ $addon_utm_tracking = superpwa_get_addons( 'utm_tracking' );
235
+
236
+ printf( '<p>' . __( 'This add-on automatically adds UTM campaign parameters to the <code>Start Page</code> URL in your <a href="%s" target="_blank">manifest</a>. This will help you identify visitors coming specifically from your app. <a href="%s" target="_blank">Read more</a> about UTM Tracking.', 'super-progressive-web-apps' ) . '</p>', superpwa_manifest( 'src' ), $addon_utm_tracking['link'] . '?utm_source=superpwa-plugin&utm_medium=utm-tracking-settings' );
237
+ }
238
+
239
+ /**
240
+ * Current Start URL
241
+ *
242
+ * @since 1.7
243
+ */
244
+ function superpwa_utm_tracking_start_url_cb() {
245
+
246
+ echo '<code style="word-break: break-all;">' . superpwa_get_start_url( true ) . '</code>';
247
+ }
248
+
249
+ /**
250
+ * Campaign Source
251
+ *
252
+ * @since 1.7
253
+ */
254
+ function superpwa_utm_tracking_source_cb() {
255
+
256
+ // Get Settings
257
+ $settings = superpwa_utm_tracking_get_settings(); ?>
258
+
259
+ <fieldset>
260
+
261
+ <input type="text" name="superpwa_utm_tracking_settings[utm_source]" class="regular-text" value="<?php if ( isset( $settings['utm_source'] ) && ( ! empty($settings['utm_source']) ) ) echo esc_attr( $settings['utm_source'] ); ?>"/>
262
+
263
+ </fieldset>
264
+
265
+ <p class="description">
266
+ <?php _e( 'Campaign Source is mandatory and defaults to <code>superpwa</code>.', 'super-progressive-web-apps' ); ?>
267
+ </p>
268
+
269
+ <?php
270
+ }
271
+
272
+ /**
273
+ * Campaign Medium
274
+ *
275
+ * @since 1.7
276
+ */
277
+ function superpwa_utm_tracking_medium_cb() {
278
+
279
+ // Get Settings
280
+ $settings = superpwa_utm_tracking_get_settings(); ?>
281
+
282
+ <fieldset>
283
+
284
+ <input type="text" name="superpwa_utm_tracking_settings[utm_medium]" class="regular-text" value="<?php if ( isset( $settings['utm_medium'] ) && ( ! empty($settings['utm_medium']) ) ) echo esc_attr( $settings['utm_medium'] ); ?>"/>
285
+
286
+ </fieldset>
287
+
288
+ <p class="description">
289
+ <?php _e( 'Campaign Source is mandatory and defaults to <code>superpwa</code>.', 'super-progressive-web-apps' ); ?>
290
+ </p>
291
+
292
+ <?php
293
+ }
294
+
295
+ /**
296
+ * Campaign Name
297
+ *
298
+ * @since 1.7
299
+ */
300
+ function superpwa_utm_tracking_name_cb() {
301
+
302
+ // Get Settings
303
+ $settings = superpwa_utm_tracking_get_settings(); ?>
304
+
305
+ <fieldset>
306
+
307
+ <input type="text" name="superpwa_utm_tracking_settings[utm_campaign]" class="regular-text" value="<?php if ( isset( $settings['utm_campaign'] ) && ( ! empty($settings['utm_campaign']) ) ) echo esc_attr( $settings['utm_campaign'] ); ?>"/>
308
+
309
+ </fieldset>
310
+
311
+ <p class="description">
312
+ <?php _e( 'Campaign Source is mandatory and defaults to <code>superpwa</code>.', 'super-progressive-web-apps' ); ?>
313
+ </p>
314
+
315
+ <?php
316
+ }
317
+
318
+ /**
319
+ * Campaign Term
320
+ *
321
+ * @since 1.7
322
+ */
323
+ function superpwa_utm_tracking_term_cb() {
324
+
325
+ // Get Settings
326
+ $settings = superpwa_utm_tracking_get_settings(); ?>
327
+
328
+ <fieldset>
329
+
330
+ <input type="text" name="superpwa_utm_tracking_settings[utm_term]" placeholder="Optional" class="regular-text" value="<?php if ( isset( $settings['utm_term'] ) && ( ! empty($settings['utm_term']) ) ) echo esc_attr( $settings['utm_term'] ); ?>"/>
331
+
332
+ </fieldset>
333
+
334
+ <?php
335
+ }
336
+
337
+ /**
338
+ * Campaign Content
339
+ *
340
+ * @since 1.7
341
+ */
342
+ function superpwa_utm_tracking_content_cb() {
343
+
344
+ // Get Settings
345
+ $settings = superpwa_utm_tracking_get_settings(); ?>
346
+
347
+ <fieldset>
348
+
349
+ <input type="text" name="superpwa_utm_tracking_settings[utm_content]" placeholder="Optional" class="regular-text" value="<?php if ( isset( $settings['utm_content'] ) && ( ! empty($settings['utm_content']) ) ) echo esc_attr( $settings['utm_content'] ); ?>"/>
350
+
351
+ </fieldset>
352
+
353
+ <?php
354
+ }
355
+
356
+ /**
357
+ * UTM Tracking UI renderer
358
+ *
359
+ * @since 1.7
360
+ */
361
+ function superpwa_utm_tracking_interface_render() {
362
+
363
+ // Authentication
364
+ if ( ! current_user_can( 'manage_options' ) ) {
365
+ return;
366
+ }
367
+
368
+ // Handing save settings
369
+ if ( isset( $_GET['settings-updated'] ) ) {
370
+
371
+ // Add settings saved message with the class of "updated"
372
+ add_settings_error( 'superpwa_settings_group', 'superpwa_utm_tracking_settings_saved_message', __( 'Settings saved.', 'super-progressive-web-apps' ), 'updated' );
373
+
374
+ // Show Settings Saved Message
375
+ settings_errors( 'superpwa_settings_group' );
376
+ }
377
+
378
+ ?>
379
+
380
+ <div class="wrap">
381
+ <h1><?php _e( 'UTM Tracking for', 'super-progressive-web-apps' ); ?> SuperPWA <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
382
+
383
+ <form action="options.php" method="post" enctype="multipart/form-data">
384
+ <?php
385
+ // Output nonce, action, and option_page fields for a settings page.
386
+ settings_fields( 'superpwa_utm_tracking_settings_group' );
387
+
388
+ // Status
389
+ do_settings_sections( 'superpwa_utm_tracking_section' ); // Page slug
390
+
391
+ // Output save settings button
392
+ submit_button( __('Save Settings', 'super-progressive-web-apps') );
393
+ ?>
394
+ </form>
395
+ </div>
396
+ <?php
397
  }
admin/admin-ui-render-addons.php CHANGED
@@ -1,500 +1,500 @@
1
- <?php
2
- /**
3
- * Add-Ons Settings UI
4
- *
5
- * @since 1.7
6
- *
7
- * @function superpwa_get_addons() Add-ons of SuperPWA
8
- * @function superpwa_addons_interface_render() Add-Ons UI renderer
9
- * @function superpwa_addons_status() Find add-on status
10
- * @function superpwa_addons_button_text() Button text based on add-on status
11
- * @function superpwa_addons_button_link() Action URL based on add-on status
12
- * @function superpwa_addons_handle_activation() Handle add-on activation
13
- * @function superpwa_addons_handle_deactivation() Handle add-on deactivation
14
- */
15
-
16
- // Exit if accessed directly
17
- if ( ! defined( 'ABSPATH' ) ) exit;
18
-
19
- /**
20
- * Add-ons of SuperPWA
21
- *
22
- * An associative array containing all the add-ons of SuperPWA.
23
- * array(
24
- * 'addon-slug' => array(
25
- * 'name' => 'Add-On Name',
26
- * 'description' => 'Add-On description',
27
- * 'type' => 'bundled | addon',
28
- * 'icon' => 'icon-for-addon-128x128.png',
29
- * 'link' => 'https://superpwa.com/addons/details-page-of-addon',
30
- * 'admin_link' => admin_url( 'admin.php?page=superpwa-addon-admin-page' ),
31
- * 'admin_link_text' => __( 'Customize settings | More Details &rarr;', 'super-progressive-web-apps' ),
32
- * 'admin_link_target' => 'admin | external',
33
- * 'superpwa_min_version' => '1.7' // min version of SuperPWA required to use the add-on.
34
- * )
35
- * );
36
- *
37
- * @param (string) addon-slug to retrieve the details about a specific add-on. False by default and then returns all add-ons.
38
- *
39
- * @return (array|boolean) an associative array containing all the info about the requested add-on. False if add-on not found.
40
- *
41
- * @since 1.7
42
- * @since 1.8 Returns false of $slug isn't found.
43
- */
44
- function superpwa_get_addons( $slug = false ) {
45
-
46
- // Add-Ons array
47
- $addons = array(
48
- 'utm_tracking' => array(
49
- 'name' => __( 'UTM Tracking', 'super-progressive-web-apps' ),
50
- 'description' => __( 'Track visits from your app by adding UTM tracking parameters to the Start Page URL.', 'super-progressive-web-apps' ),
51
- 'type' => 'bundled',
52
- 'icon' => 'superpwa-128x128.png',
53
- 'link' => 'https://superpwa.com/addons/utm-tracking/',
54
- 'admin_link' => admin_url( 'admin.php?page=superpwa-utm-tracking' ),
55
- 'admin_link_text' => __( 'Customize Settings &rarr;', 'super-progressive-web-apps' ),
56
- 'admin_link_target' => 'admin',
57
- 'superpwa_min_version' => '1.7',
58
- ),
59
- 'apple_touch_icons' => array(
60
- 'name' => __( 'Apple Touch Icons', 'super-progressive-web-apps' ),
61
- 'description' => __( 'Set the Application Icon and Splash Screen Icon as Apple Touch Icons for compatibility with iOS devices.', 'super-progressive-web-apps' ),
62
- 'type' => 'bundled',
63
- 'icon' => 'superpwa-128x128.png',
64
- 'link' => 'https://superpwa.com/addons/apple-touch-icons/',
65
- 'admin_link' => 'https://superpwa.com/addons/apple-touch-icons/',
66
- 'admin_link_text' => __( 'More Details &rarr;', 'super-progressive-web-apps' ),
67
- 'admin_link_target' => 'external',
68
- 'superpwa_min_version' => '1.8',
69
- ),
70
- );
71
-
72
- if ( $slug === false ) {
73
- return $addons;
74
- }
75
-
76
- if ( ! isset( $addons[$slug] ) ) {
77
- return false;
78
- }
79
-
80
- return $addons[$slug];
81
- }
82
-
83
- /**
84
- * Add-Ons UI renderer
85
- *
86
- * @since 1.7
87
- */
88
- function superpwa_addons_interface_render() {
89
-
90
- // Authentication
91
- if ( ! current_user_can( 'manage_options' ) ) {
92
- return;
93
- }
94
-
95
- // Add-on activation todo
96
- if ( isset( $_GET['activated'] ) && isset( $_GET['addon'] ) ) {
97
-
98
- // Add-on activation action. Functions defined in the add-on file are loaded by now.
99
- do_action( 'superpwa_addon_activated_' . $_GET['addon'] );
100
-
101
- // Get add-on info
102
- $addon = superpwa_get_addons( $_GET['addon'] );
103
-
104
- // Add UTM Tracking to admin_link_text if its not an admin page.
105
- if ( $addon['admin_link_target'] === 'external' ) {
106
- $addon['admin_link'] .= '?utm_source=superpwa-plugin&utm_medium=addon-activation-notice';
107
- }
108
-
109
- // Set link target attribute so that external links open in a new tab.
110
- $link_target = ( $addon['admin_link_target'] === 'external' ) ? 'target="_blank"' : '';
111
-
112
- if ( $addon !== false ) {
113
-
114
- // Add-on activation notice
115
- echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>Add-On activated: %s.</strong> <a href="%s"%s>%s</a>', 'super-progressive-web-apps' ), $addon['name'], $addon['admin_link'], $link_target, $addon['admin_link_text'] ) . '</p></div>';
116
- }
117
- }
118
-
119
- // Add-on de-activation notice
120
- if ( isset( $_GET['deactivated'] ) ) {
121
-
122
- // Add settings saved message with the class of "updated"
123
- add_settings_error( 'superpwa_settings_group', 'superpwa_addon_deactivated_message', __( 'Add-On deactivated', 'super-progressive-web-apps' ), 'updated' );
124
-
125
- // Show Settings Saved Message
126
- settings_errors( 'superpwa_settings_group' );
127
- }
128
-
129
- // Get add-ons array
130
- $addons = superpwa_get_addons();
131
-
132
- ?>
133
-
134
- <div class="wrap">
135
- <h1><?php _e( 'Add-Ons for', 'super-progressive-web-apps' ); ?> SuperPWA <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
136
-
137
- <p><?php _e( 'Add-Ons extend the functionality of SuperPWA.', 'super-progressive-web-apps' ); ?></p>
138
-
139
- <!-- Add-Ons UI -->
140
- <div class="wp-list-table widefat addon-install">
141
-
142
- <div id="the-list">
143
-
144
- <?php
145
- // Newsletter marker. Set this to false once newsletter subscription is displayed.
146
- $superpwa_newsletter = true;
147
-
148
- // Looping over each add-on
149
- foreach( $addons as $slug => $addon ) {
150
-
151
- // Add UTM Tracking to admin_link_text if its not an admin page.
152
- if ( $addon['admin_link_target'] === 'external' ) {
153
- $addon['admin_link'] .= '?utm_source=superpwa-plugin&utm_medium=addon-card';
154
- }
155
-
156
- // Set link target attribute so that external links open in a new tab.
157
- $link_target = ( $addon['admin_link_target'] === 'external' ) ? 'target="_blank"' : '';
158
-
159
- ?>
160
-
161
- <div class="plugin-card plugin-card-<?php echo $slug; ?>">
162
-
163
- <div class="plugin-card-top">
164
-
165
- <div class="name column-name">
166
- <h3>
167
- <a href="<?php echo $addon['link'] . '?utm_source=superpwa-plugin&utm_medium=addon-card'; ?>" target="_blank">
168
- <?php echo $addon['name']; ?>
169
- <img src="<?php echo SUPERPWA_PATH_SRC . 'admin/img/' . $addon['icon']; ?>" class="plugin-icon" alt="">
170
- </a>
171
- </h3>
172
- </div>
173
-
174
- <div class="action-links">
175
- <ul class="plugin-action-buttons">
176
- <li>
177
- <a class="button activate-now button-<?php echo superpwa_addons_button_text( $slug ) == __( 'Deactivate', 'super-progressive-web-apps' ) ? 'secondary' : 'primary'; ?>" data-slug="<?php echo $slug; ?>" href="<?php echo superpwa_addons_button_link( $slug ); ?>" aria-label<?php echo superpwa_addons_button_text( $slug ) . ' ' . $addon['name'] . ' now'; ?>" data-name="<?php echo $addon['name']; ?>">
178
- <?php echo superpwa_addons_button_text( $slug ); ?>
179
- </a>
180
- </li>
181
- <li>
182
- <a href="<?php echo $addon['link'] . '?utm_source=superpwa-plugin&utm_medium=addon-card'; ?>" target="_blank" aria-label="<?php printf( __( 'More information about %s', 'super-progressive-web-apps' ), $addon['name'] ); ?>" data-title="<?php echo $addon['name']; ?>"><?php _e( 'More Details', 'super-progressive-web-apps' ); ?></a>
183
- </li>
184
- </ul>
185
- </div>
186
-
187
- <div class="desc column-description">
188
- <p><?php echo $addon['description']; ?></p>
189
- </div>
190
-
191
- </div>
192
-
193
- <div class="plugin-card-bottom">
194
- <div class="column-compatibility">
195
- <?php
196
- if ( superpwa_addons_status( $slug ) == 'active' ) {
197
- printf( __( '<span class="compatibility-compatible"><strong>Add-On active.</strong> <a href="%s"%s>%s</a></span>', 'super-progressive-web-apps' ), $addon['admin_link'], $link_target, $addon['admin_link_text'] );
198
- }
199
- else if ( version_compare( SUPERPWA_VERSION, $addon['superpwa_min_version'], '>=' ) ) {
200
- _e( '<span class="compatibility-compatible"><strong>Compatible</strong> with your version of SuperPWA</span>', 'super-progressive-web-apps' );
201
- }
202
- else {
203
- _e( '<span class="compatibility-incompatible"><strong>Please upgrade</strong> to the latest version of SuperPWA</span>', 'super-progressive-web-apps' );
204
- } ?>
205
- </div>
206
- </div>
207
-
208
- </div>
209
-
210
- <?php if ( $superpwa_newsletter === true ) { ?>
211
-
212
- <div class="plugin-card plugin-card-superpwa-newsletter" style="background: #fdfc35 url('<?php echo SUPERPWA_PATH_SRC . 'admin/img/email.png'; ?>') no-repeat right top;">
213
-
214
- <div class="plugin-card-top" style="min-height: 178px;">
215
-
216
- <div class="name column-name" style="margin: 0px 10px;">
217
- <h3><?php _e( 'SuperPWA Newsletter', 'super-progressive-web-apps' ); ?></h3>
218
- </div>
219
-
220
- <div class="desc column-description" style="margin: 0px 10px;">
221
- <p><?php _e( 'Learn more about Progressive Web Apps<br>and get latest updates about SuperPWA', 'super-progressive-web-apps' ); ?></p>
222
- </div>
223
-
224
- <div class="superpwa-newsletter-form" style="margin: 18px 10px 0px;">
225
-
226
- <form method="post" action="https://superpwa.com/newsletter/" target="_blank">
227
- <fieldset>
228
-
229
- <input name="newsletter-email" value="<?php $user = wp_get_current_user(); echo esc_attr( $user->user_email ); ?>" placeholder="<?php _e( 'Enter your email', 'super-progressive-web-apps' ); ?>" style="width: 60%; margin-left: 0px;" type="email">
230
- <input name="source" value="superpwa-plugin" type="hidden">
231
- <input type="submit" class="button" value="<?php _e( 'Subscribe', 'super-progressive-web-apps' ); ?>" style="background: linear-gradient(to right, #fdfc35, #ffe258) !important; box-shadow: unset;">
232
-
233
- <small style="display:block; margin-top:8px;"><?php _e( 'we\'ll share our <code>root</code> password before we share your email with anyone else.', 'super-progressive-web-apps' ); ?></small>
234
-
235
- </fieldset>
236
- </form>
237
-
238
- </div>
239
-
240
- </div>
241
-
242
- </div>
243
-
244
- <?php
245
-
246
- // Set newsletter marker to false
247
- $superpwa_newsletter = false;
248
- }
249
- } ?>
250
-
251
- </div>
252
- </div>
253
-
254
- </div>
255
- <?php
256
- }
257
-
258
- /**
259
- * Find add-on status
260
- *
261
- * Returns one of these statuses:
262
- * active when the add-on is installed and active.
263
- * inactive when the add-on is installed but not activated.
264
- * uninstalled when the add-on is not installed and not available.
265
- *
266
- * @param $slug this is the $key used in the $addons array in superpwa_get_addons().
267
- * For add-ons installed as a separate plugin, this will be plugin-directory/main-plugin-file.php
268
- *
269
- * @return (string) one of the statuses as described above. False if $slug is not a valid add-on.
270
- *
271
- * @since 1.7
272
- */
273
- function superpwa_addons_status( $slug ) {
274
-
275
- // Get add-on details
276
- $addon = superpwa_get_addons( $slug );
277
-
278
- // A security check to make sure that the add-on under consideration exist.
279
- if ( $addon === false ) {
280
- return false;
281
- }
282
-
283
- // Get active add-ons
284
- $active_addons = get_option( 'superpwa_active_addons', array() );
285
-
286
- switch( $addon['type'] ) {
287
-
288
- // Bundled add-ons ships with SuperPWA and need not be installed separately.
289
- case 'bundled':
290
-
291
- // True means, add-on is installed and active
292
- if ( in_array( $slug, $active_addons ) ) {
293
- return 'active';
294
- }
295
-
296
- // add-on is installed, but inactive
297
- return 'inactive';
298
-
299
- break;
300
-
301
- // Add-ons installed as a separate plugin
302
- case 'addon':
303
-
304
- // True means, add-on is installed and active
305
- if ( is_plugin_active( $slug ) ) {
306
- return 'active';
307
- }
308
-
309
- // Add-on is inactive, check if add-on is installed
310
- if ( file_exists( WP_PLUGIN_DIR . '/' . $slug ) ) {
311
- return 'inactive';
312
- }
313
-
314
- // If we are here, add-on is not installed and not active
315
- return 'uninstalled';
316
-
317
- break;
318
-
319
- default:
320
- return false;
321
- break;
322
- }
323
- }
324
-
325
- /**
326
- * Button text based on add-on status
327
- *
328
- * @param $slug this is the $key used in the $addons array in superpwa_get_addons().
329
- * For add-ons installed as a separate plugin, this will be plugin-directory/main-plugin-file.php
330
- *
331
- * @return (string) 'Activate', if plugin status is 'inactive'
332
- * 'Deactivate', if plugin status is 'active'
333
- * 'Install', if plugin status is 'uninstalled'
334
- *
335
- * @since 1.7
336
- */
337
- function superpwa_addons_button_text( $slug ) {
338
-
339
- // Get the add-on status
340
- $addon_status = superpwa_addons_status( $slug );
341
-
342
- switch( $addon_status ) {
343
-
344
- case 'inactive':
345
- return __( 'Activate', 'super-progressive-web-apps' );
346
- break;
347
-
348
- case 'active':
349
- return __( 'Deactivate', 'super-progressive-web-apps' );
350
- break;
351
-
352
- case 'uninstalled':
353
- default: // Safety net for edge cases if any.
354
- return __( 'Install', 'super-progressive-web-apps' );
355
- break;
356
- }
357
- }
358
-
359
- /**
360
- * Action URL based on add-on status
361
- *
362
- * @param $slug this is the $key used in the $addons array in superpwa_get_addons().
363
- * For add-ons installed as a separate plugin, this will be plugin-directory/main-plugin-file.php
364
- *
365
- * @return (string) activation / deactivation / install url with nonce as necessary
366
- *
367
- * @since 1.7
368
- */
369
- function superpwa_addons_button_link( $slug ) {
370
-
371
- // Get the add-on status
372
- $addon_status = superpwa_addons_status( $slug );
373
-
374
- // Get add-on details
375
- $addon = superpwa_get_addons( $slug );
376
-
377
- switch( $addon_status ) {
378
-
379
- // Add-on inactive, send activation link.
380
- case 'inactive':
381
-
382
- // Plugin activation link for add-on plugins that are installed separately.
383
- if ( $addon['type'] == 'addon' ) {
384
- wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $slug ), 'activate-plugin_' . $slug );
385
- }
386
-
387
- // Activation link for bundled add-ons.
388
- return wp_nonce_url( admin_url( 'admin-post.php?action=superpwa_activate_addon&addon=' . $slug ), 'activate', 'superpwa_addon_activate_nonce' );
389
-
390
- break;
391
-
392
- // Add-on active, send deactivation link.
393
- case 'active':
394
-
395
- // Plugin deactivation link for add-on plugins that are installed separately.
396
- if ( $addon['type'] == 'addon' ) {
397
- wp_nonce_url( admin_url( 'plugins.php?action=deactivate&plugin=' . $slug ), 'deactivate-plugin_' . $slug );
398
- }
399
-
400
- // Deactivation link for bundled add-ons.
401
- return wp_nonce_url( admin_url( 'admin-post.php?action=superpwa_deactivate_addon&addon=' . $slug ), 'deactivate', 'superpwa_addon_deactivate_nonce' );
402
-
403
- break;
404
-
405
- // If add-on is not installed and for edge cases where $addon_status is false, we use the add-on link.
406
- case 'uninstalled':
407
- default:
408
- return $addon['link'];
409
- break;
410
- }
411
- }
412
-
413
- /**
414
- * Handle add-on activation
415
- *
416
- * Verifies that the activation request is valid and then redirects the page back to the add-ons page.
417
- * Hooked onto admin_post_superpwa_activate_addon action hook
418
- *
419
- * @since 1.7
420
- * @since 1.8 Handles only activation. Used to handle both activation and deactivation.
421
- * @since 1.8 Hooked onto admin_post_superpwa_activate_addon. Was hooked to load-superpwa_page_superpwa-addons before.
422
- */
423
- function superpwa_addons_handle_activation() {
424
-
425
- // Get the add-on status
426
- $addon_status = superpwa_addons_status( $_GET['addon'] );
427
-
428
- // Authentication
429
- if (
430
- ! current_user_can( 'manage_options' ) ||
431
- ! isset( $_GET['addon'] ) ||
432
- ! ( isset( $_GET['superpwa_addon_activate_nonce'] ) && wp_verify_nonce( $_GET['superpwa_addon_activate_nonce'], 'activate' ) ) ||
433
- ! ( $addon_status == 'inactive' )
434
- ) {
435
-
436
- // Return to referer if authentication fails.
437
- wp_redirect( admin_url( 'admin.php?page=superpwa-addons' ) );
438
- exit;
439
- }
440
-
441
- // Get active add-ons
442
- $active_addons = get_option( 'superpwa_active_addons', array() );
443
-
444
- // Add the add-on to the list of active add-ons
445
- $active_addons[] = $_GET['addon'];
446
-
447
- // Write settings back to database
448
- update_option( 'superpwa_active_addons', $active_addons );
449
-
450
- // Redirect back to add-ons sub-menu
451
- wp_redirect( admin_url( 'admin.php?page=superpwa-addons&activated=1&addon=' . $_GET['addon'] ) );
452
- exit;
453
- }
454
- add_action( 'admin_post_superpwa_activate_addon', 'superpwa_addons_handle_activation' );
455
-
456
- /**
457
- * Handle add-on deactivation
458
- *
459
- * Verifies that the deactivation request is valid and then redirects the page back to the add-ons page.
460
- * Hooked onto admin_post_superpwa_deactivate_addon action hook.
461
- *
462
- * @since 1.8
463
- */
464
- function superpwa_addons_handle_deactivation() {
465
-
466
- // Get the add-on status
467
- $addon_status = superpwa_addons_status( $_GET['addon'] );
468
-
469
- // Authentication
470
- if (
471
- ! current_user_can( 'manage_options' ) ||
472
- ! isset( $_GET['addon'] ) ||
473
- ! ( isset( $_GET['superpwa_addon_deactivate_nonce'] ) && wp_verify_nonce( $_GET['superpwa_addon_deactivate_nonce'], 'deactivate' ) ) ||
474
- ! ( $addon_status == 'active' )
475
- ) {
476
-
477
- // Return to referer if authentication fails.
478
- wp_redirect( admin_url( 'admin.php?page=superpwa-addons' ) );
479
- exit;
480
- }
481
-
482
- // Get active add-ons
483
- $active_addons = get_option( 'superpwa_active_addons', array() );
484
-
485
- // Delete the add-on from the active_addons array in SuperPWA settings.
486
- $active_addons = array_flip( $active_addons );
487
- unset( $active_addons[ $_GET['addon'] ] );
488
- $active_addons = array_flip( $active_addons );
489
-
490
- // Write settings back to database
491
- update_option( 'superpwa_active_addons', $active_addons );
492
-
493
- // Add-on deactivation action. Functions defined in the add-on file are still availalbe at this point.
494
- do_action( 'superpwa_addon_deactivated_' . $_GET['addon'] );
495
-
496
- // Redirect back to add-ons sub-menu
497
- wp_redirect( admin_url( 'admin.php?page=superpwa-addons&deactivated=1&addon=' . $_GET['addon'] ) );
498
- exit;
499
- }
500
  add_action( 'admin_post_superpwa_deactivate_addon', 'superpwa_addons_handle_deactivation' );
1
+ <?php
2
+ /**
3
+ * Add-Ons Settings UI
4
+ *
5
+ * @since 1.7
6
+ *
7
+ * @function superpwa_get_addons() Add-ons of SuperPWA
8
+ * @function superpwa_addons_interface_render() Add-Ons UI renderer
9
+ * @function superpwa_addons_status() Find add-on status
10
+ * @function superpwa_addons_button_text() Button text based on add-on status
11
+ * @function superpwa_addons_button_link() Action URL based on add-on status
12
+ * @function superpwa_addons_handle_activation() Handle add-on activation
13
+ * @function superpwa_addons_handle_deactivation() Handle add-on deactivation
14
+ */
15
+
16
+ // Exit if accessed directly
17
+ if ( ! defined( 'ABSPATH' ) ) exit;
18
+
19
+ /**
20
+ * Add-ons of SuperPWA
21
+ *
22
+ * An associative array containing all the add-ons of SuperPWA.
23
+ * array(
24
+ * 'addon-slug' => array(
25
+ * 'name' => 'Add-On Name',
26
+ * 'description' => 'Add-On description',
27
+ * 'type' => 'bundled | addon',
28
+ * 'icon' => 'icon-for-addon-128x128.png',
29
+ * 'link' => 'https://superpwa.com/addons/details-page-of-addon',
30
+ * 'admin_link' => admin_url( 'admin.php?page=superpwa-addon-admin-page' ),
31
+ * 'admin_link_text' => __( 'Customize settings | More Details &rarr;', 'super-progressive-web-apps' ),
32
+ * 'admin_link_target' => 'admin | external',
33
+ * 'superpwa_min_version' => '1.7' // min version of SuperPWA required to use the add-on.
34
+ * )
35
+ * );
36
+ *
37
+ * @param (string) addon-slug to retrieve the details about a specific add-on. False by default and then returns all add-ons.
38
+ *
39
+ * @return (array|boolean) an associative array containing all the info about the requested add-on. False if add-on not found.
40
+ *
41
+ * @since 1.7
42
+ * @since 1.8 Returns false of $slug isn't found.
43
+ */
44
+ function superpwa_get_addons( $slug = false ) {
45
+
46
+ // Add-Ons array
47
+ $addons = array(
48
+ 'utm_tracking' => array(
49
+ 'name' => __( 'UTM Tracking', 'super-progressive-web-apps' ),
50
+ 'description' => __( 'Track visits from your app by adding UTM tracking parameters to the Start Page URL.', 'super-progressive-web-apps' ),
51
+ 'type' => 'bundled',
52
+ 'icon' => 'superpwa-128x128.png',
53
+ 'link' => 'https://superpwa.com/addons/utm-tracking/',
54
+ 'admin_link' => admin_url( 'admin.php?page=superpwa-utm-tracking' ),
55
+ 'admin_link_text' => __( 'Customize Settings &rarr;', 'super-progressive-web-apps' ),
56
+ 'admin_link_target' => 'admin',
57
+ 'superpwa_min_version' => '1.7',
58
+ ),
59
+ 'apple_touch_icons' => array(
60
+ 'name' => __( 'Apple Touch Icons', 'super-progressive-web-apps' ),
61
+ 'description' => __( 'Set the Application Icon and Splash Screen Icon as Apple Touch Icons for compatibility with iOS devices.', 'super-progressive-web-apps' ),
62
+ 'type' => 'bundled',
63
+ 'icon' => 'superpwa-128x128.png',
64
+ 'link' => 'https://superpwa.com/addons/apple-touch-icons/',
65
+ 'admin_link' => 'https://superpwa.com/addons/apple-touch-icons/',
66
+ 'admin_link_text' => __( 'More Details &rarr;', 'super-progressive-web-apps' ),
67
+ 'admin_link_target' => 'external',
68
+ 'superpwa_min_version' => '1.8',
69
+ ),
70
+ );
71
+
72
+ if ( $slug === false ) {
73
+ return $addons;
74
+ }
75
+
76
+ if ( ! isset( $addons[$slug] ) ) {
77
+ return false;
78
+ }
79
+
80
+ return $addons[$slug];
81
+ }
82
+
83
+ /**
84
+ * Add-Ons UI renderer
85
+ *
86
+ * @since 1.7
87
+ */
88
+ function superpwa_addons_interface_render() {
89
+
90
+ // Authentication
91
+ if ( ! current_user_can( 'manage_options' ) ) {
92
+ return;
93
+ }
94
+
95
+ // Add-on activation todo
96
+ if ( isset( $_GET['activated'] ) && isset( $_GET['addon'] ) ) {
97
+
98
+ // Add-on activation action. Functions defined in the add-on file are loaded by now.
99
+ do_action( 'superpwa_addon_activated_' . $_GET['addon'] );
100
+
101
+ // Get add-on info
102
+ $addon = superpwa_get_addons( $_GET['addon'] );
103
+
104
+ // Add UTM Tracking to admin_link_text if its not an admin page.
105
+ if ( $addon['admin_link_target'] === 'external' ) {
106
+ $addon['admin_link'] .= '?utm_source=superpwa-plugin&utm_medium=addon-activation-notice';
107
+ }
108
+
109
+ // Set link target attribute so that external links open in a new tab.
110
+ $link_target = ( $addon['admin_link_target'] === 'external' ) ? 'target="_blank"' : '';
111
+
112
+ if ( $addon !== false ) {
113
+
114
+ // Add-on activation notice
115
+ echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>Add-On activated: %s.</strong> <a href="%s"%s>%s</a>', 'super-progressive-web-apps' ), $addon['name'], $addon['admin_link'], $link_target, $addon['admin_link_text'] ) . '</p></div>';
116
+ }
117
+ }
118
+
119
+ // Add-on de-activation notice
120
+ if ( isset( $_GET['deactivated'] ) ) {
121
+
122
+ // Add settings saved message with the class of "updated"
123
+ add_settings_error( 'superpwa_settings_group', 'superpwa_addon_deactivated_message', __( 'Add-On deactivated', 'super-progressive-web-apps' ), 'updated' );
124
+
125
+ // Show Settings Saved Message
126
+ settings_errors( 'superpwa_settings_group' );
127
+ }
128
+
129
+ // Get add-ons array
130
+ $addons = superpwa_get_addons();
131
+
132
+ ?>
133
+
134
+ <div class="wrap">
135
+ <h1><?php _e( 'Add-Ons for', 'super-progressive-web-apps' ); ?> SuperPWA <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
136
+
137
+ <p><?php _e( 'Add-Ons extend the functionality of SuperPWA.', 'super-progressive-web-apps' ); ?></p>
138
+
139
+ <!-- Add-Ons UI -->
140
+ <div class="wp-list-table widefat addon-install">
141
+
142
+ <div id="the-list">
143
+
144
+ <?php
145
+ // Newsletter marker. Set this to false once newsletter subscription is displayed.
146
+ $superpwa_newsletter = true;
147
+
148
+ // Looping over each add-on
149
+ foreach( $addons as $slug => $addon ) {
150
+
151
+ // Add UTM Tracking to admin_link_text if its not an admin page.
152
+ if ( $addon['admin_link_target'] === 'external' ) {
153
+ $addon['admin_link'] .= '?utm_source=superpwa-plugin&utm_medium=addon-card';
154
+ }
155
+
156
+ // Set link target attribute so that external links open in a new tab.
157
+ $link_target = ( $addon['admin_link_target'] === 'external' ) ? 'target="_blank"' : '';
158
+
159
+ ?>
160
+
161
+ <div class="plugin-card plugin-card-<?php echo $slug; ?>">
162
+
163
+ <div class="plugin-card-top">
164
+
165
+ <div class="name column-name">
166
+ <h3>
167
+ <a href="<?php echo $addon['link'] . '?utm_source=superpwa-plugin&utm_medium=addon-card'; ?>" target="_blank">
168
+ <?php echo $addon['name']; ?>
169
+ <img src="<?php echo SUPERPWA_PATH_SRC . 'admin/img/' . $addon['icon']; ?>" class="plugin-icon" alt="">
170
+ </a>
171
+ </h3>
172
+ </div>
173
+
174
+ <div class="action-links">
175
+ <ul class="plugin-action-buttons">
176
+ <li>
177
+ <a class="button activate-now button-<?php echo superpwa_addons_button_text( $slug ) == __( 'Deactivate', 'super-progressive-web-apps' ) ? 'secondary' : 'primary'; ?>" data-slug="<?php echo $slug; ?>" href="<?php echo superpwa_addons_button_link( $slug ); ?>" aria-label<?php echo superpwa_addons_button_text( $slug ) . ' ' . $addon['name'] . ' now'; ?>" data-name="<?php echo $addon['name']; ?>">
178
+ <?php echo superpwa_addons_button_text( $slug ); ?>
179
+ </a>
180
+ </li>
181
+ <li>
182
+ <a href="<?php echo $addon['link'] . '?utm_source=superpwa-plugin&utm_medium=addon-card'; ?>" target="_blank" aria-label="<?php printf( __( 'More information about %s', 'super-progressive-web-apps' ), $addon['name'] ); ?>" data-title="<?php echo $addon['name']; ?>"><?php _e( 'More Details', 'super-progressive-web-apps' ); ?></a>
183
+ </li>
184
+ </ul>
185
+ </div>
186
+
187
+ <div class="desc column-description">
188
+ <p><?php echo $addon['description']; ?></p>
189
+ </div>
190
+
191
+ </div>
192
+
193
+ <div class="plugin-card-bottom">
194
+ <div class="column-compatibility">
195
+ <?php
196
+ if ( superpwa_addons_status( $slug ) == 'active' ) {
197
+ printf( __( '<span class="compatibility-compatible"><strong>Add-On active.</strong> <a href="%s"%s>%s</a></span>', 'super-progressive-web-apps' ), $addon['admin_link'], $link_target, $addon['admin_link_text'] );
198
+ }
199
+ else if ( version_compare( SUPERPWA_VERSION, $addon['superpwa_min_version'], '>=' ) ) {
200
+ _e( '<span class="compatibility-compatible"><strong>Compatible</strong> with your version of SuperPWA</span>', 'super-progressive-web-apps' );
201
+ }
202
+ else {
203
+ _e( '<span class="compatibility-incompatible"><strong>Please upgrade</strong> to the latest version of SuperPWA</span>', 'super-progressive-web-apps' );
204
+ } ?>
205
+ </div>
206
+ </div>
207
+
208
+ </div>
209
+
210
+ <?php if ( $superpwa_newsletter === true ) { ?>
211
+
212
+ <div class="plugin-card plugin-card-superpwa-newsletter" style="background: #fdfc35 url('<?php echo SUPERPWA_PATH_SRC . 'admin/img/email.png'; ?>') no-repeat right top;">
213
+
214
+ <div class="plugin-card-top" style="min-height: 178px;">
215
+
216
+ <div class="name column-name" style="margin: 0px 10px;">
217
+ <h3><?php _e( 'SuperPWA Newsletter', 'super-progressive-web-apps' ); ?></h3>
218
+ </div>
219
+
220
+ <div class="desc column-description" style="margin: 0px 10px;">
221
+ <p><?php _e( 'Learn more about Progressive Web Apps<br>and get latest updates about SuperPWA', 'super-progressive-web-apps' ); ?></p>
222
+ </div>
223
+
224
+ <div class="superpwa-newsletter-form" style="margin: 18px 10px 0px;">
225
+
226
+ <form method="post" action="https://superpwa.com/newsletter/" target="_blank">
227
+ <fieldset>
228
+
229
+ <input name="newsletter-email" value="<?php $user = wp_get_current_user(); echo esc_attr( $user->user_email ); ?>" placeholder="<?php _e( 'Enter your email', 'super-progressive-web-apps' ); ?>" style="width: 60%; margin-left: 0px;" type="email">
230
+ <input name="source" value="superpwa-plugin" type="hidden">
231
+ <input type="submit" class="button" value="<?php _e( 'Subscribe', 'super-progressive-web-apps' ); ?>" style="background: linear-gradient(to right, #fdfc35, #ffe258) !important; box-shadow: unset;">
232
+
233
+ <small style="display:block; margin-top:8px;"><?php _e( 'we\'ll share our <code>root</code> password before we share your email with anyone else.', 'super-progressive-web-apps' ); ?></small>
234
+
235
+ </fieldset>
236
+ </form>
237
+
238
+ </div>
239
+
240
+ </div>
241
+
242
+ </div>
243
+
244
+ <?php
245
+
246
+ // Set newsletter marker to false
247
+ $superpwa_newsletter = false;
248
+ }
249
+ } ?>
250
+
251
+ </div>
252
+ </div>
253
+
254
+ </div>
255
+ <?php
256
+ }
257
+
258
+ /**
259
+ * Find add-on status
260
+ *
261
+ * Returns one of these statuses:
262
+ * active when the add-on is installed and active.
263
+ * inactive when the add-on is installed but not activated.
264
+ * uninstalled when the add-on is not installed and not available.
265
+ *
266
+ * @param $slug this is the $key used in the $addons array in superpwa_get_addons().
267
+ * For add-ons installed as a separate plugin, this will be plugin-directory/main-plugin-file.php
268
+ *
269
+ * @return (string) one of the statuses as described above. False if $slug is not a valid add-on.
270
+ *
271
+ * @since 1.7
272
+ */
273
+ function superpwa_addons_status( $slug ) {
274
+
275
+ // Get add-on details
276
+ $addon = superpwa_get_addons( $slug );
277
+
278
+ // A security check to make sure that the add-on under consideration exist.
279
+ if ( $addon === false ) {
280
+ return false;
281
+ }
282
+
283
+ // Get active add-ons
284
+ $active_addons = get_option( 'superpwa_active_addons', array() );
285
+
286
+ switch( $addon['type'] ) {
287
+
288
+ // Bundled add-ons ships with SuperPWA and need not be installed separately.
289
+ case 'bundled':
290
+
291
+ // True means, add-on is installed and active
292
+ if ( in_array( $slug, $active_addons ) ) {
293
+ return 'active';
294
+ }
295
+
296
+ // add-on is installed, but inactive
297
+ return 'inactive';
298
+
299
+ break;
300
+
301
+ // Add-ons installed as a separate plugin
302
+ case 'addon':
303
+
304
+ // True means, add-on is installed and active
305
+ if ( is_plugin_active( $slug ) ) {
306
+ return 'active';
307
+ }
308
+
309
+ // Add-on is inactive, check if add-on is installed
310
+ if ( file_exists( WP_PLUGIN_DIR . '/' . $slug ) ) {
311
+ return 'inactive';
312
+ }
313
+
314
+ // If we are here, add-on is not installed and not active
315
+ return 'uninstalled';
316
+
317
+ break;
318
+
319
+ default:
320
+ return false;
321
+ break;
322
+ }
323
+ }
324
+
325
+ /**
326
+ * Button text based on add-on status
327
+ *
328
+ * @param $slug this is the $key used in the $addons array in superpwa_get_addons().
329
+ * For add-ons installed as a separate plugin, this will be plugin-directory/main-plugin-file.php
330
+ *
331
+ * @return (string) 'Activate', if plugin status is 'inactive'
332
+ * 'Deactivate', if plugin status is 'active'
333
+ * 'Install', if plugin status is 'uninstalled'
334
+ *
335
+ * @since 1.7
336
+ */
337
+ function superpwa_addons_button_text( $slug ) {
338
+
339
+ // Get the add-on status
340
+ $addon_status = superpwa_addons_status( $slug );
341
+
342
+ switch( $addon_status ) {
343
+
344
+ case 'inactive':
345
+ return __( 'Activate', 'super-progressive-web-apps' );
346
+ break;
347
+
348
+ case 'active':
349
+ return __( 'Deactivate', 'super-progressive-web-apps' );
350
+ break;
351
+
352
+ case 'uninstalled':
353
+ default: // Safety net for edge cases if any.
354
+ return __( 'Install', 'super-progressive-web-apps' );
355
+ break;
356
+ }
357
+ }
358
+
359
+ /**
360
+ * Action URL based on add-on status
361
+ *
362
+ * @param $slug this is the $key used in the $addons array in superpwa_get_addons().
363
+ * For add-ons installed as a separate plugin, this will be plugin-directory/main-plugin-file.php
364
+ *
365
+ * @return (string) activation / deactivation / install url with nonce as necessary
366
+ *
367
+ * @since 1.7
368
+ */
369
+ function superpwa_addons_button_link( $slug ) {
370
+
371
+ // Get the add-on status
372
+ $addon_status = superpwa_addons_status( $slug );
373
+
374
+ // Get add-on details
375
+ $addon = superpwa_get_addons( $slug );
376
+
377
+ switch( $addon_status ) {
378
+
379
+ // Add-on inactive, send activation link.
380
+ case 'inactive':
381
+
382
+ // Plugin activation link for add-on plugins that are installed separately.
383
+ if ( $addon['type'] == 'addon' ) {
384
+ wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $slug ), 'activate-plugin_' . $slug );
385
+ }
386
+
387
+ // Activation link for bundled add-ons.
388
+ return wp_nonce_url( admin_url( 'admin-post.php?action=superpwa_activate_addon&addon=' . $slug ), 'activate', 'superpwa_addon_activate_nonce' );
389
+
390
+ break;
391
+
392
+ // Add-on active, send deactivation link.
393
+ case 'active':
394
+
395
+ // Plugin deactivation link for add-on plugins that are installed separately.
396
+ if ( $addon['type'] == 'addon' ) {
397
+ wp_nonce_url( admin_url( 'plugins.php?action=deactivate&plugin=' . $slug ), 'deactivate-plugin_' . $slug );
398
+ }
399
+
400
+ // Deactivation link for bundled add-ons.
401
+ return wp_nonce_url( admin_url( 'admin-post.php?action=superpwa_deactivate_addon&addon=' . $slug ), 'deactivate', 'superpwa_addon_deactivate_nonce' );
402
+
403
+ break;
404
+
405
+ // If add-on is not installed and for edge cases where $addon_status is false, we use the add-on link.
406
+ case 'uninstalled':
407
+ default:
408
+ return $addon['link'];
409
+ break;
410
+ }
411
+ }
412
+
413
+ /**
414
+ * Handle add-on activation
415
+ *
416
+ * Verifies that the activation request is valid and then redirects the page back to the add-ons page.
417
+ * Hooked onto admin_post_superpwa_activate_addon action hook
418
+ *
419
+ * @since 1.7
420
+ * @since 1.8 Handles only activation. Used to handle both activation and deactivation.
421
+ * @since 1.8 Hooked onto admin_post_superpwa_activate_addon. Was hooked to load-superpwa_page_superpwa-addons before.
422
+ */
423
+ function superpwa_addons_handle_activation() {
424
+
425
+ // Get the add-on status
426
+ $addon_status = superpwa_addons_status( $_GET['addon'] );
427
+
428
+ // Authentication
429
+ if (
430
+ ! current_user_can( 'manage_options' ) ||
431
+ ! isset( $_GET['addon'] ) ||
432
+ ! ( isset( $_GET['superpwa_addon_activate_nonce'] ) && wp_verify_nonce( $_GET['superpwa_addon_activate_nonce'], 'activate' ) ) ||
433
+ ! ( $addon_status == 'inactive' )
434
+ ) {
435
+
436
+ // Return to referer if authentication fails.
437
+ wp_redirect( admin_url( 'admin.php?page=superpwa-addons' ) );
438
+ exit;
439
+ }
440
+
441
+ // Get active add-ons
442
+ $active_addons = get_option( 'superpwa_active_addons', array() );
443
+
444
+ // Add the add-on to the list of active add-ons
445
+ $active_addons[] = $_GET['addon'];
446
+
447
+ // Write settings back to database
448
+ update_option( 'superpwa_active_addons', $active_addons );
449
+
450
+ // Redirect back to add-ons sub-menu
451
+ wp_redirect( admin_url( 'admin.php?page=superpwa-addons&activated=1&addon=' . $_GET['addon'] ) );
452
+ exit;
453
+ }
454
+ add_action( 'admin_post_superpwa_activate_addon', 'superpwa_addons_handle_activation' );
455
+
456
+ /**
457
+ * Handle add-on deactivation
458
+ *
459
+ * Verifies that the deactivation request is valid and then redirects the page back to the add-ons page.
460
+ * Hooked onto admin_post_superpwa_deactivate_addon action hook.
461
+ *
462
+ * @since 1.8
463
+ */
464
+ function superpwa_addons_handle_deactivation() {
465
+
466
+ // Get the add-on status
467
+ $addon_status = superpwa_addons_status( $_GET['addon'] );
468
+
469
+ // Authentication
470
+ if (
471
+ ! current_user_can( 'manage_options' ) ||
472
+ ! isset( $_GET['addon'] ) ||
473
+ ! ( isset( $_GET['superpwa_addon_deactivate_nonce'] ) && wp_verify_nonce( $_GET['superpwa_addon_deactivate_nonce'], 'deactivate' ) ) ||
474
+ ! ( $addon_status == 'active' )
475
+ ) {
476
+
477
+ // Return to referer if authentication fails.
478
+ wp_redirect( admin_url( 'admin.php?page=superpwa-addons' ) );
479
+ exit;
480
+ }
481
+
482
+ // Get active add-ons
483
+ $active_addons = get_option( 'superpwa_active_addons', array() );
484
+
485
+ // Delete the add-on from the active_addons array in SuperPWA settings.
486
+ $active_addons = array_flip( $active_addons );
487
+ unset( $active_addons[ $_GET['addon'] ] );
488
+ $active_addons = array_flip( $active_addons );
489
+
490
+ // Write settings back to database
491
+ update_option( 'superpwa_active_addons', $active_addons );
492
+
493
+ // Add-on deactivation action. Functions defined in the add-on file are still availalbe at this point.
494
+ do_action( 'superpwa_addon_deactivated_' . $_GET['addon'] );
495
+
496
+ // Redirect back to add-ons sub-menu
497
+ wp_redirect( admin_url( 'admin.php?page=superpwa-addons&deactivated=1&addon=' . $_GET['addon'] ) );
498
+ exit;
499
+ }
500
  add_action( 'admin_post_superpwa_deactivate_addon', 'superpwa_addons_handle_deactivation' );
admin/admin-ui-render-settings.php CHANGED
@@ -1,447 +1,447 @@
1
- <?php
2
- /**
3
- * Admin UI setup and render
4
- *
5
- * @since 1.0
6
- *
7
- * @function superpwa_app_name_cb() Application Name
8
- * @function superpwa_app_short_name_cb() Application Short Name
9
- * @function superpwa_description_cb() Description
10
- * @function superpwa_background_color_cb() Splash Screen Background Color
11
- * @function superpwa_theme_color_cb() Theme Color
12
- * @function superpwa_app_icon_cb() Application Icon
13
- * @function superpwa_app_icon_cb() Splash Screen Icon
14
- * @function superpwa_start_url_cb() Start URL Dropdown
15
- * @function superpwa_offline_page_cb() Offline Page Dropdown
16
- * @function superpwa_orientation_cb() Default Orientation Dropdown
17
- * @function superpwa_display_cb() Default Display Dropdown
18
- * @function superpwa_manifest_status_cb() Manifest Status
19
- * @function superpwa_sw_status_cb() Service Worker Status
20
- * @function superpwa_https_status_cb() HTTPS Status
21
- * @function superpwa_admin_interface_render() Admin interface renderer
22
- */
23
-
24
- // Exit if accessed directly
25
- if ( ! defined( 'ABSPATH' ) ) exit;
26
-
27
- /**
28
- * Application Name
29
- *
30
- * @since 1.2
31
- */
32
- function superpwa_app_name_cb() {
33
-
34
- // Get Settings
35
- $settings = superpwa_get_settings(); ?>
36
-
37
- <fieldset>
38
-
39
- <input type="text" name="superpwa_settings[app_name]" class="regular-text" value="<?php if ( isset( $settings['app_name'] ) && ( ! empty($settings['app_name']) ) ) echo esc_attr($settings['app_name']); ?>"/>
40
-
41
- </fieldset>
42
-
43
- <?php
44
- }
45
-
46
- /**
47
- * Application Short Name
48
- *
49
- * @since 1.2
50
- */
51
- function superpwa_app_short_name_cb() {
52
-
53
- // Get Settings
54
- $settings = superpwa_get_settings(); ?>
55
-
56
- <fieldset>
57
-
58
- <input type="text" name="superpwa_settings[app_short_name]" class="regular-text superpwa-app-short-name" value="<?php if ( isset( $settings['app_short_name'] ) && ( ! empty($settings['app_short_name']) ) ) echo esc_attr($settings['app_short_name']); ?>"/>
59
-
60
- <p class="description">
61
- <?php _e('Used when there is insufficient space to display the full name of the application. <span id="superpwa-app-short-name-limit"><code>12</code> characters or less.</span>', 'super-progressive-web-apps'); ?>
62
- </p>
63
-
64
- </fieldset>
65
-
66
- <?php
67
- }
68
-
69
- /**
70
- * Description
71
- *
72
- * @since 1.6
73
- */
74
- function superpwa_description_cb() {
75
-
76
- // Get Settings
77
- $settings = superpwa_get_settings(); ?>
78
-
79
- <fieldset>
80
-
81
- <input type="text" name="superpwa_settings[description]" class="regular-text" value="<?php if ( isset( $settings['description'] ) && ( ! empty( $settings['description'] ) ) ) echo esc_attr( $settings['description'] ); ?>"/>
82
-
83
- <p class="description">
84
- <?php _e( 'A brief description of what your app is about.', 'super-progressive-web-apps' ); ?>
85
- </p>
86
-
87
- </fieldset>
88
-
89
- <?php
90
- }
91
-
92
- /**
93
- * Application Icon
94
- *
95
- * @since 1.0
96
- */
97
- function superpwa_app_icon_cb() {
98
-
99
- // Get Settings
100
- $settings = superpwa_get_settings(); ?>
101
-
102
- <!-- Application Icon -->
103
- <input type="text" name="superpwa_settings[icon]" id="superpwa_settings[icon]" class="superpwa-icon regular-text" size="50" value="<?php echo isset( $settings['icon'] ) ? esc_attr( $settings['icon']) : ''; ?>">
104
- <button type="button" class="button superpwa-icon-upload" data-editor="content">
105
- <span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> <?php _e( 'Choose Icon', 'super-progressive-web-apps' ); ?>
106
- </button>
107
-
108
- <p class="description">
109
- <?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'); ?>
110
- </p>
111
-
112
- <?php
113
- }
114
-
115
- /**
116
- * Splash Screen Icon
117
- *
118
- * @since 1.3
119
- */
120
- function superpwa_splash_icon_cb() {
121
-
122
- // Get Settings
123
- $settings = superpwa_get_settings(); ?>
124
-
125
- <!-- Splash Screen Icon -->
126
- <input type="text" name="superpwa_settings[splash_icon]" id="superpwa_settings[splash_icon]" class="superpwa-splash-icon regular-text" size="50" value="<?php echo isset( $settings['splash_icon'] ) ? esc_attr( $settings['splash_icon']) : ''; ?>">
127
- <button type="button" class="button superpwa-splash-icon-upload" data-editor="content">
128
- <span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> <?php _e( 'Choose Icon', 'super-progressive-web-apps' ); ?>
129
- </button>
130
-
131
- <p class="description">
132
- <?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'); ?>
133
- </p>
134
-
135
- <?php
136
- }
137
-
138
- /**
139
- * Splash Screen Background Color
140
- *
141
- * @since 1.0
142
- */
143
- function superpwa_background_color_cb() {
144
-
145
- // Get Settings
146
- $settings = superpwa_get_settings(); ?>
147
-
148
- <!-- Background Color -->
149
- <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">
150
-
151
- <p class="description">
152
- <?php _e('Background color of the splash screen.', 'super-progressive-web-apps'); ?>
153
- </p>
154
-
155
- <?php
156
- }
157
-
158
- /**
159
- * Theme Color
160
- *
161
- * @since 1.4
162
- */
163
- function superpwa_theme_color_cb() {
164
-
165
- // Get Settings
166
- $settings = superpwa_get_settings(); ?>
167
-
168
- <!-- Theme Color -->
169
- <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">
170
-
171
- <p class="description">
172
- <?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'); ?>
173
- </p>
174
-
175
- <?php
176
- }
177
-
178
- /**
179
- * Start URL Dropdown
180
- *
181
- * @since 1.2
182
- */
183
- function superpwa_start_url_cb() {
184
-
185
- // Get Settings
186
- $settings = superpwa_get_settings(); ?>
187
-
188
- <fieldset>
189
-
190
- <!-- WordPress Pages Dropdown -->
191
- <label for="superpwa_settings[start_url]">
192
- <?php echo wp_dropdown_pages( array(
193
- 'name' => 'superpwa_settings[start_url]',
194
- 'echo' => 0,
195
- 'show_option_none' => __( '&mdash; Homepage &mdash;' ),
196
- 'option_none_value' => '0',
197
- 'selected' => isset($settings['start_url']) ? $settings['start_url'] : '',
198
- )); ?>
199
- </label>
200
-
201
- <p class="description">
202
- <?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() ); ?>
203
- </p>
204
-
205
- <?php if ( superpwa_is_amp() ) { ?>
206
-
207
- <!-- AMP Page As Start Page -->
208
- <br><input type="checkbox" name="superpwa_settings[start_url_amp]" id="superpwa_settings[start_url_amp]" value="1"
209
- <?php if ( isset( $settings['start_url_amp'] ) ) { checked( '1', $settings['start_url_amp'] ); } ?>>
210
- <label for="superpwa_settings[start_url_amp]"><?php _e('Use AMP version of the start page.', 'super-progressive-web-apps') ?></label>
211
- <br>
212
-
213
- <!-- AMP for WordPress 0.6.2 doesn't support homepage, the blog index, and archive pages. -->
214
- <?php if ( is_plugin_active( 'amp/amp.php' ) ) { ?>
215
- <p class="description">
216
- <?php _e( 'Do not check this if your start page is the homepage, the blog index, or the archives page. AMP for WordPress does not create AMP versions for these pages.', 'super-progressive-web-apps' ); ?>
217
- </p>
218
- <?php } ?>
219
-
220
- <!-- tagDiv AMP 1.2 doesn't enable AMP for pages by default and needs to be enabled manually in settings -->
221
- <?php if ( is_plugin_active( 'td-amp/td-amp.php' ) && method_exists( 'td_util', 'get_option' ) ) {
222
-
223
- // Read option value from db
224
- $td_amp_page_post_type = td_util::get_option( 'tds_amp_post_type_page' );
225
-
226
- // Show notice if option to enable AMP for pages is disabled.
227
- if ( empty( $td_amp_page_post_type ) ) { ?>
228
- <p class="description">
229
- <?php printf( __( 'Please enable AMP support for Page in <a href="%s">Theme Settings > Theme Panel</a> > AMP > Post Type Support.', 'super-progressive-web-apps' ), admin_url( 'admin.php?page=td_theme_panel' ) ); ?>
230
- </p>
231
- <?php }
232
- } ?>
233
-
234
- <?php } ?>
235
-
236
- </fieldset>
237
-
238
- <?php
239
- }
240
-
241
- /**
242
- * Offline Page Dropdown
243
- *
244
- * @since 1.1
245
- */
246
- function superpwa_offline_page_cb() {
247
-
248
- // Get Settings
249
- $settings = superpwa_get_settings(); ?>
250
-
251
- <!-- WordPress Pages Dropdown -->
252
- <label for="superpwa_settings[offline_page]">
253
- <?php echo wp_dropdown_pages( array(
254
- 'name' => 'superpwa_settings[offline_page]',
255
- 'echo' => 0,
256
- 'show_option_none' => __( '&mdash; Default &mdash;' ),
257
- 'option_none_value' => '0',
258
- 'selected' => isset($settings['offline_page']) ? $settings['offline_page'] : '',
259
- )); ?>
260
- </label>
261
-
262
- <p class="description">
263
- <?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' ), superpwa_get_offline_page() ); ?>
264
- </p>
265
-
266
- <?php
267
- }
268
-
269
- /**
270
- * Default Orientation Dropdown
271
- *
272
- * @since 1.4
273
- */
274
- function superpwa_orientation_cb() {
275
-
276
- // Get Settings
277
- $settings = superpwa_get_settings(); ?>
278
-
279
- <!-- Orientation Dropdown -->
280
- <label for="superpwa_settings[orientation]">
281
- <select name="superpwa_settings[orientation]" id="superpwa_settings[orientation]">
282
- <option value="0" <?php if ( isset( $settings['orientation'] ) ) { selected( $settings['orientation'], 0 ); } ?>>
283
- <?php _e( 'Follow Device Orientation', 'super-progressive-web-apps' ); ?>
284
- </option>
285
- <option value="1" <?php if ( isset( $settings['orientation'] ) ) { selected( $settings['orientation'], 1 ); } ?>>
286
- <?php _e( 'Portrait', 'super-progressive-web-apps' ); ?>
287
- </option>
288
- <option value="2" <?php if ( isset( $settings['orientation'] ) ) { selected( $settings['orientation'], 2 ); } ?>>
289
- <?php _e( 'Landscape', 'super-progressive-web-apps' ); ?>
290
- </option>
291
- </select>
292
- </label>
293
-
294
- <p class="description">
295
- <?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' ); ?>
296
- </p>
297
-
298
- <?php
299
- }
300
-
301
- /**
302
- * Default Display Dropdown
303
- *
304
- * @author Jose Varghese
305
- *
306
- * @since 2.0
307
- */
308
- function superpwa_display_cb() {
309
-
310
- // Get Settings
311
- $settings = superpwa_get_settings(); ?>
312
-
313
- <!-- Display Dropdown -->
314
- <label for="superpwa_settings[display]">
315
- <select name="superpwa_settings[display]" id="superpwa_settings[display]">
316
- <option value="0" <?php if ( isset( $settings['display'] ) ) { selected( $settings['display'], 0 ); } ?>>
317
- <?php _e( 'Full Screen', 'super-progressive-web-apps' ); ?>
318
- </option>
319
- <option value="1" <?php if ( isset( $settings['display'] ) ) { selected( $settings['display'], 1 ); } ?>>
320
- <?php _e( 'Standalone', 'super-progressive-web-apps' ); ?>
321
- </option>
322
- <option value="2" <?php if ( isset( $settings['display'] ) ) { selected( $settings['display'], 2 ); } ?>>
323
- <?php _e( 'Minimal UI', 'super-progressive-web-apps' ); ?>
324
- </option>
325
- <option value="3" <?php if ( isset( $settings['display'] ) ) { selected( $settings['display'], 3 ); } ?>>
326
- <?php _e( 'Browser', 'super-progressive-web-apps' ); ?>
327
- </option>
328
- </select>
329
- </label>
330
-
331
- <p class="description">
332
- <?php printf( __( 'Display mode decides what browser UI is shown when your app is launched. <code>Standalone</code> is default. <a href="%s" target="_blank">What\'s the difference? &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', 'https://superpwa.com/doc/web-app-manifest-display-modes/?utm_source=superpwa-plugin&utm_medium=settings-display' ); ?>
333
- </p>
334
-
335
- <?php
336
- }
337
-
338
- /**
339
- * Manifest Status
340
- *
341
- * @author Arun Basil Lal
342
- *
343
- * @since 1.2
344
- * @since 1.8 Attempt to generate manifest again if the manifest doesn't exist.
345
- * @since 2.0 Remove logic to check if manifest exists in favour of dynamic manifest.
346
- * @since 2.0.1 Added checks to see if dynamic file is valid. If not, generates a physical file.
347
- */
348
- function superpwa_manifest_status_cb() {
349
-
350
- /**
351
- * Check to see if the file exists, If not attempts to generate a new one.
352
- */
353
- if ( superpwa_file_exists( superpwa_manifest( 'src' ) ) || superpwa_generate_manifest() ) {
354
-
355
- printf( '<p><span class="dashicons dashicons-yes" style="color: #46b450;"></span> ' . __( 'Manifest generated successfully. You can <a href="%s" target="_blank">See it here &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', superpwa_manifest( 'src' ) );
356
- } else {
357
-
358
- printf( '<p><span class="dashicons dashicons-no-alt" style="color: #dc3232;"></span> ' . __( 'Manifest generation failed. <a href="%s" target="_blank">Fix it &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', 'https://superpwa.com/doc/fixing-manifest-service-worker-generation-failed-error/?utm_source=superpwa-plugin&utm_medium=settings-status-no-manifest' );
359
- }
360
- }
361
-
362
- /**
363
- * Service Worker Status
364
- *
365
- * @author Arun Basil Lal
366
- *
367
- * @since 1.2
368
- * @since 1.8 Attempt to generate service worker again if it doesn't exist.
369
- * @since 2.0 Modify logic to check if Service worker exists.
370
- * @since 2.0.1 Added checks to see if dynamic file is valid. If not, generates a physical file.
371
- */
372
- function superpwa_sw_status_cb() {
373
-
374
- /**
375
- * Check to see if the file exists, If not attempts to generate a new one.
376
- */
377
- if ( superpwa_file_exists( superpwa_sw( 'src' ) ) || superpwa_generate_sw() ) {
378
-
379
- printf( '<p><span class="dashicons dashicons-yes" style="color: #46b450;"></span> ' . __( 'Service worker generated successfully. <a href="%s" target="_blank">See it here &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', superpwa_sw( 'src' ) );
380
- } else {
381
-
382
- printf( '<p><span class="dashicons dashicons-no-alt" style="color: #dc3232;"></span> ' . __( 'Service worker generation failed. <a href="%s" target="_blank">Fix it &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', 'https://superpwa.com/doc/fixing-manifest-service-worker-generation-failed-error/?utm_source=superpwa-plugin&utm_medium=settings-status-no-sw' );
383
- }
384
- }
385
-
386
- /**
387
- * HTTPS Status
388
- *
389
- * @since 1.2
390
- */
391
- function superpwa_https_status_cb() {
392
-
393
- if ( is_ssl() ) {
394
-
395
- printf( '<p><span class="dashicons dashicons-yes" style="color: #46b450;"></span> ' . __( 'Your website is served over HTTPS.', 'super-progressive-web-apps' ) . '</p>' );
396
- } else {
397
-
398
- printf( '<p><span class="dashicons dashicons-no-alt" style="color: #dc3232;"></span> ' . __( 'Progressive Web Apps require that your website is served over HTTPS. Please contact your host to add a SSL certificate to your domain.', 'super-progressive-web-apps' ) . '</p>' );
399
- }
400
- }
401
-
402
- /**
403
- * Admin interface renderer
404
- *
405
- * @since 1.0
406
- * @since 1.7 Handling of settings saved messages since UI is its own menu item in the admin menu.
407
- */
408
- function superpwa_admin_interface_render() {
409
-
410
- // Authentication
411
- if ( ! current_user_can( 'manage_options' ) ) {
412
- return;
413
- }
414
-
415
- // Handing save settings
416
- if ( isset( $_GET['settings-updated'] ) ) {
417
-
418
- // Add settings saved message with the class of "updated"
419
- add_settings_error( 'superpwa_settings_group', 'superpwa_settings_saved_message', __( 'Settings saved.', 'super-progressive-web-apps' ), 'updated' );
420
-
421
- // Show Settings Saved Message
422
- settings_errors( 'superpwa_settings_group' );
423
- }
424
-
425
- ?>
426
-
427
- <div class="wrap">
428
- <h1>Super Progressive Web Apps <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
429
-
430
- <form action="options.php" method="post" enctype="multipart/form-data">
431
- <?php
432
- // Output nonce, action, and option_page fields for a settings page.
433
- settings_fields( 'superpwa_settings_group' );
434
-
435
- // Basic Application Settings
436
- do_settings_sections( 'superpwa_basic_settings_section' ); // Page slug
437
-
438
- // Status
439
- do_settings_sections( 'superpwa_pwa_status_section' ); // Page slug
440
-
441
- // Output save settings button
442
- submit_button( __('Save Settings', 'super-progressive-web-apps') );
443
- ?>
444
- </form>
445
- </div>
446
- <?php
447
- }
1
+ <?php
2
+ /**
3
+ * Admin UI setup and render
4
+ *
5
+ * @since 1.0
6
+ *
7
+ * @function superpwa_app_name_cb() Application Name
8
+ * @function superpwa_app_short_name_cb() Application Short Name
9
+ * @function superpwa_description_cb() Description
10
+ * @function superpwa_background_color_cb() Splash Screen Background Color
11
+ * @function superpwa_theme_color_cb() Theme Color
12
+ * @function superpwa_app_icon_cb() Application Icon
13
+ * @function superpwa_app_icon_cb() Splash Screen Icon
14
+ * @function superpwa_start_url_cb() Start URL Dropdown
15
+ * @function superpwa_offline_page_cb() Offline Page Dropdown
16
+ * @function superpwa_orientation_cb() Default Orientation Dropdown
17
+ * @function superpwa_display_cb() Default Display Dropdown
18
+ * @function superpwa_manifest_status_cb() Manifest Status
19
+ * @function superpwa_sw_status_cb() Service Worker Status
20
+ * @function superpwa_https_status_cb() HTTPS Status
21
+ * @function superpwa_admin_interface_render() Admin interface renderer
22
+ */
23
+
24
+ // Exit if accessed directly
25
+ if ( ! defined( 'ABSPATH' ) ) exit;
26
+
27
+ /**
28
+ * Application Name
29
+ *
30
+ * @since 1.2
31
+ */
32
+ function superpwa_app_name_cb() {
33
+
34
+ // Get Settings
35
+ $settings = superpwa_get_settings(); ?>
36
+
37
+ <fieldset>
38
+
39
+ <input type="text" name="superpwa_settings[app_name]" class="regular-text" value="<?php if ( isset( $settings['app_name'] ) && ( ! empty($settings['app_name']) ) ) echo esc_attr($settings['app_name']); ?>"/>
40
+
41
+ </fieldset>
42
+
43
+ <?php
44
+ }
45
+
46
+ /**
47
+ * Application Short Name
48
+ *
49
+ * @since 1.2
50
+ */
51
+ function superpwa_app_short_name_cb() {
52
+
53
+ // Get Settings
54
+ $settings = superpwa_get_settings(); ?>
55
+
56
+ <fieldset>
57
+
58
+ <input type="text" name="superpwa_settings[app_short_name]" class="regular-text superpwa-app-short-name" value="<?php if ( isset( $settings['app_short_name'] ) && ( ! empty($settings['app_short_name']) ) ) echo esc_attr($settings['app_short_name']); ?>"/>
59
+
60
+ <p class="description">
61
+ <?php _e('Used when there is insufficient space to display the full name of the application. <span id="superpwa-app-short-name-limit"><code>12</code> characters or less.</span>', 'super-progressive-web-apps'); ?>
62
+ </p>
63
+
64
+ </fieldset>
65
+
66
+ <?php
67
+ }
68
+
69
+ /**
70
+ * Description
71
+ *
72
+ * @since 1.6
73
+ */
74
+ function superpwa_description_cb() {
75
+
76
+ // Get Settings
77
+ $settings = superpwa_get_settings(); ?>
78
+
79
+ <fieldset>
80
+
81
+ <input type="text" name="superpwa_settings[description]" class="regular-text" value="<?php if ( isset( $settings['description'] ) && ( ! empty( $settings['description'] ) ) ) echo esc_attr( $settings['description'] ); ?>"/>
82
+
83
+ <p class="description">
84
+ <?php _e( 'A brief description of what your app is about.', 'super-progressive-web-apps' ); ?>
85
+ </p>
86
+
87
+ </fieldset>
88
+
89
+ <?php
90
+ }
91
+
92
+ /**
93
+ * Application Icon
94
+ *
95
+ * @since 1.0
96
+ */
97
+ function superpwa_app_icon_cb() {
98
+
99
+ // Get Settings
100
+ $settings = superpwa_get_settings(); ?>
101
+
102
+ <!-- Application Icon -->
103
+ <input type="text" name="superpwa_settings[icon]" id="superpwa_settings[icon]" class="superpwa-icon regular-text" size="50" value="<?php echo isset( $settings['icon'] ) ? esc_attr( $settings['icon']) : ''; ?>">
104
+ <button type="button" class="button superpwa-icon-upload" data-editor="content">
105
+ <span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> <?php _e( 'Choose Icon', 'super-progressive-web-apps' ); ?>
106
+ </button>
107
+
108
+ <p class="description">
109
+ <?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'); ?>
110
+ </p>
111
+
112
+ <?php
113
+ }
114
+
115
+ /**
116
+ * Splash Screen Icon
117
+ *
118
+ * @since 1.3
119
+ */
120
+ function superpwa_splash_icon_cb() {
121
+
122
+ // Get Settings
123
+ $settings = superpwa_get_settings(); ?>
124
+
125
+ <!-- Splash Screen Icon -->
126
+ <input type="text" name="superpwa_settings[splash_icon]" id="superpwa_settings[splash_icon]" class="superpwa-splash-icon regular-text" size="50" value="<?php echo isset( $settings['splash_icon'] ) ? esc_attr( $settings['splash_icon']) : ''; ?>">
127
+ <button type="button" class="button superpwa-splash-icon-upload" data-editor="content">
128
+ <span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> <?php _e( 'Choose Icon', 'super-progressive-web-apps' ); ?>
129
+ </button>
130
+
131
+ <p class="description">
132
+ <?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'); ?>
133
+ </p>
134
+
135
+ <?php
136
+ }
137
+
138
+ /**
139
+ * Splash Screen Background Color
140
+ *
141
+ * @since 1.0
142
+ */
143
+ function superpwa_background_color_cb() {
144
+
145
+ // Get Settings
146
+ $settings = superpwa_get_settings(); ?>
147
+
148
+ <!-- Background Color -->
149
+ <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">
150
+
151
+ <p class="description">
152
+ <?php _e('Background color of the splash screen.', 'super-progressive-web-apps'); ?>
153
+ </p>
154
+
155
+ <?php
156
+ }
157
+
158
+ /**
159
+ * Theme Color
160
+ *
161
+ * @since 1.4
162
+ */
163
+ function superpwa_theme_color_cb() {
164
+
165
+ // Get Settings
166
+ $settings = superpwa_get_settings(); ?>
167
+
168
+ <!-- Theme Color -->
169
+ <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">
170
+
171
+ <p class="description">
172
+ <?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'); ?>
173
+ </p>
174
+
175
+ <?php
176
+ }
177
+
178
+ /**
179
+ * Start URL Dropdown
180
+ *
181
+ * @since 1.2
182
+ */
183
+ function superpwa_start_url_cb() {
184
+
185
+ // Get Settings
186
+ $settings = superpwa_get_settings(); ?>
187
+
188
+ <fieldset>
189
+
190
+ <!-- WordPress Pages Dropdown -->
191
+ <label for="superpwa_settings[start_url]">
192
+ <?php echo wp_dropdown_pages( array(
193
+ 'name' => 'superpwa_settings[start_url]',
194
+ 'echo' => 0,
195
+ 'show_option_none' => __( '&mdash; Homepage &mdash;' ),
196
+ 'option_none_value' => '0',
197
+ 'selected' => isset($settings['start_url']) ? $settings['start_url'] : '',
198
+ )); ?>
199
+ </label>
200
+
201
+ <p class="description">
202
+ <?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() ); ?>
203
+ </p>
204
+
205
+ <?php if ( superpwa_is_amp() ) { ?>
206
+
207
+ <!-- AMP Page As Start Page -->
208
+ <br><input type="checkbox" name="superpwa_settings[start_url_amp]" id="superpwa_settings[start_url_amp]" value="1"
209
+ <?php if ( isset( $settings['start_url_amp'] ) ) { checked( '1', $settings['start_url_amp'] ); } ?>>
210
+ <label for="superpwa_settings[start_url_amp]"><?php _e('Use AMP version of the start page.', 'super-progressive-web-apps') ?></label>
211
+ <br>
212
+
213
+ <!-- AMP for WordPress 0.6.2 doesn't support homepage, the blog index, and archive pages. -->
214
+ <?php if ( is_plugin_active( 'amp/amp.php' ) ) { ?>
215
+ <p class="description">
216
+ <?php _e( 'Do not check this if your start page is the homepage, the blog index, or the archives page. AMP for WordPress does not create AMP versions for these pages.', 'super-progressive-web-apps' ); ?>
217
+ </p>
218
+ <?php } ?>
219
+
220
+ <!-- tagDiv AMP 1.2 doesn't enable AMP for pages by default and needs to be enabled manually in settings -->
221
+ <?php if ( is_plugin_active( 'td-amp/td-amp.php' ) && method_exists( 'td_util', 'get_option' ) ) {
222
+
223
+ // Read option value from db
224
+ $td_amp_page_post_type = td_util::get_option( 'tds_amp_post_type_page' );
225
+
226
+ // Show notice if option to enable AMP for pages is disabled.
227
+ if ( empty( $td_amp_page_post_type ) ) { ?>
228
+ <p class="description">
229
+ <?php printf( __( 'Please enable AMP support for Page in <a href="%s">Theme Settings > Theme Panel</a> > AMP > Post Type Support.', 'super-progressive-web-apps' ), admin_url( 'admin.php?page=td_theme_panel' ) ); ?>
230
+ </p>
231
+ <?php }
232
+ } ?>
233
+
234
+ <?php } ?>
235
+
236
+ </fieldset>
237
+
238
+ <?php
239
+ }
240
+
241
+ /**
242
+ * Offline Page Dropdown
243
+ *
244
+ * @since 1.1
245
+ */
246
+ function superpwa_offline_page_cb() {
247
+
248
+ // Get Settings
249
+ $settings = superpwa_get_settings(); ?>
250
+
251
+ <!-- WordPress Pages Dropdown -->
252
+ <label for="superpwa_settings[offline_page]">
253
+ <?php echo wp_dropdown_pages( array(
254
+ 'name' => 'superpwa_settings[offline_page]',
255
+ 'echo' => 0,
256
+ 'show_option_none' => __( '&mdash; Default &mdash;' ),
257
+ 'option_none_value' => '0',
258
+ 'selected' => isset($settings['offline_page']) ? $settings['offline_page'] : '',
259
+ )); ?>
260
+ </label>
261
+
262
+ <p class="description">
263
+ <?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' ), superpwa_get_offline_page() ); ?>
264
+ </p>
265
+
266
+ <?php
267
+ }
268
+
269
+ /**
270
+ * Default Orientation Dropdown
271
+ *
272
+ * @since 1.4
273
+ */
274
+ function superpwa_orientation_cb() {
275
+
276
+ // Get Settings
277
+ $settings = superpwa_get_settings(); ?>
278
+
279
+ <!-- Orientation Dropdown -->
280
+ <label for="superpwa_settings[orientation]">
281
+ <select name="superpwa_settings[orientation]" id="superpwa_settings[orientation]">
282
+ <option value="0" <?php if ( isset( $settings['orientation'] ) ) { selected( $settings['orientation'], 0 ); } ?>>
283
+ <?php _e( 'Follow Device Orientation', 'super-progressive-web-apps' ); ?>
284
+ </option>
285
+ <option value="1" <?php if ( isset( $settings['orientation'] ) ) { selected( $settings['orientation'], 1 ); } ?>>
286
+ <?php _e( 'Portrait', 'super-progressive-web-apps' ); ?>
287
+ </option>
288
+ <option value="2" <?php if ( isset( $settings['orientation'] ) ) { selected( $settings['orientation'], 2 ); } ?>>
289
+ <?php _e( 'Landscape', 'super-progressive-web-apps' ); ?>
290
+ </option>
291
+ </select>
292
+ </label>
293
+
294
+ <p class="description">
295
+ <?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' ); ?>
296
+ </p>
297
+
298
+ <?php
299
+ }
300
+
301
+ /**
302
+ * Default Display Dropdown
303
+ *
304
+ * @author Jose Varghese
305
+ *
306
+ * @since 2.0
307
+ */
308
+ function superpwa_display_cb() {
309
+
310
+ // Get Settings
311
+ $settings = superpwa_get_settings(); ?>
312
+
313
+ <!-- Display Dropdown -->
314
+ <label for="superpwa_settings[display]">
315
+ <select name="superpwa_settings[display]" id="superpwa_settings[display]">
316
+ <option value="0" <?php if ( isset( $settings['display'] ) ) { selected( $settings['display'], 0 ); } ?>>
317
+ <?php _e( 'Full Screen', 'super-progressive-web-apps' ); ?>
318
+ </option>
319
+ <option value="1" <?php if ( isset( $settings['display'] ) ) { selected( $settings['display'], 1 ); } ?>>
320
+ <?php _e( 'Standalone', 'super-progressive-web-apps' ); ?>
321
+ </option>
322
+ <option value="2" <?php if ( isset( $settings['display'] ) ) { selected( $settings['display'], 2 ); } ?>>
323
+ <?php _e( 'Minimal UI', 'super-progressive-web-apps' ); ?>
324
+ </option>
325
+ <option value="3" <?php if ( isset( $settings['display'] ) ) { selected( $settings['display'], 3 ); } ?>>
326
+ <?php _e( 'Browser', 'super-progressive-web-apps' ); ?>
327
+ </option>
328
+ </select>
329
+ </label>
330
+
331
+ <p class="description">
332
+ <?php printf( __( 'Display mode decides what browser UI is shown when your app is launched. <code>Standalone</code> is default. <a href="%s" target="_blank">What\'s the difference? &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', 'https://superpwa.com/doc/web-app-manifest-display-modes/?utm_source=superpwa-plugin&utm_medium=settings-display' ); ?>
333
+ </p>
334
+
335
+ <?php
336
+ }
337
+
338
+ /**
339
+ * Manifest Status
340
+ *
341
+ * @author Arun Basil Lal
342
+ *
343
+ * @since 1.2
344
+ * @since 1.8 Attempt to generate manifest again if the manifest doesn't exist.
345
+ * @since 2.0 Remove logic to check if manifest exists in favour of dynamic manifest.
346
+ * @since 2.0.1 Added checks to see if dynamic file is valid. If not, generates a physical file.
347
+ */
348
+ function superpwa_manifest_status_cb() {
349
+
350
+ /**
351
+ * Check to see if the file exists, If not attempts to generate a new one.
352
+ */
353
+ if ( superpwa_file_exists( superpwa_manifest( 'src' ) ) || superpwa_generate_manifest() ) {
354
+
355
+ printf( '<p><span class="dashicons dashicons-yes" style="color: #46b450;"></span> ' . __( 'Manifest generated successfully. You can <a href="%s" target="_blank">See it here &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', superpwa_manifest( 'src' ) );
356
+ } else {
357
+
358
+ printf( '<p><span class="dashicons dashicons-no-alt" style="color: #dc3232;"></span> ' . __( 'Manifest generation failed. <a href="%s" target="_blank">Fix it &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', 'https://superpwa.com/doc/fixing-manifest-service-worker-generation-failed-error/?utm_source=superpwa-plugin&utm_medium=settings-status-no-manifest' );
359
+ }
360
+ }
361
+
362
+ /**
363
+ * Service Worker Status
364
+ *
365
+ * @author Arun Basil Lal
366
+ *
367
+ * @since 1.2
368
+ * @since 1.8 Attempt to generate service worker again if it doesn't exist.
369
+ * @since 2.0 Modify logic to check if Service worker exists.
370
+ * @since 2.0.1 Added checks to see if dynamic file is valid. If not, generates a physical file.
371
+ */
372
+ function superpwa_sw_status_cb() {
373
+
374
+ /**
375
+ * Check to see if the file exists, If not attempts to generate a new one.
376
+ */
377
+ if ( superpwa_file_exists( superpwa_sw( 'src' ) ) || superpwa_generate_sw() ) {
378
+
379
+ printf( '<p><span class="dashicons dashicons-yes" style="color: #46b450;"></span> ' . __( 'Service worker generated successfully. <a href="%s" target="_blank">See it here &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', superpwa_sw( 'src' ) );
380
+ } else {
381
+
382
+ printf( '<p><span class="dashicons dashicons-no-alt" style="color: #dc3232;"></span> ' . __( 'Service worker generation failed. <a href="%s" target="_blank">Fix it &rarr;</a>', 'super-progressive-web-apps' ) . '</p>', 'https://superpwa.com/doc/fixing-manifest-service-worker-generation-failed-error/?utm_source=superpwa-plugin&utm_medium=settings-status-no-sw' );
383
+ }
384
+ }
385
+
386
+ /**
387
+ * HTTPS Status
388
+ *
389
+ * @since 1.2
390
+ */
391
+ function superpwa_https_status_cb() {
392
+
393
+ if ( is_ssl() ) {
394
+
395
+ printf( '<p><span class="dashicons dashicons-yes" style="color: #46b450;"></span> ' . __( 'Your website is served over HTTPS.', 'super-progressive-web-apps' ) . '</p>' );
396
+ } else {
397
+
398
+ printf( '<p><span class="dashicons dashicons-no-alt" style="color: #dc3232;"></span> ' . __( 'Progressive Web Apps require that your website is served over HTTPS. Please contact your host to add a SSL certificate to your domain.', 'super-progressive-web-apps' ) . '</p>' );
399
+ }
400
+ }
401
+
402
+ /**
403
+ * Admin interface renderer
404
+ *
405
+ * @since 1.0
406
+ * @since 1.7 Handling of settings saved messages since UI is its own menu item in the admin menu.
407
+ */
408
+ function superpwa_admin_interface_render() {
409
+
410
+ // Authentication
411
+ if ( ! current_user_can( 'manage_options' ) ) {
412
+ return;
413
+ }
414
+
415
+ // Handing save settings
416
+ if ( isset( $_GET['settings-updated'] ) ) {
417
+
418
+ // Add settings saved message with the class of "updated"
419
+ add_settings_error( 'superpwa_settings_group', 'superpwa_settings_saved_message', __( 'Settings saved.', 'super-progressive-web-apps' ), 'updated' );
420
+
421
+ // Show Settings Saved Message
422
+ settings_errors( 'superpwa_settings_group' );
423
+ }
424
+
425
+ ?>
426
+
427
+ <div class="wrap">
428
+ <h1>Super Progressive Web Apps <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
429
+
430
+ <form action="options.php" method="post" enctype="multipart/form-data">
431
+ <?php
432
+ // Output nonce, action, and option_page fields for a settings page.
433
+ settings_fields( 'superpwa_settings_group' );
434
+
435
+ // Basic Application Settings
436
+ do_settings_sections( 'superpwa_basic_settings_section' ); // Page slug
437
+
438
+ // Status
439
+ do_settings_sections( 'superpwa_pwa_status_section' ); // Page slug
440
+
441
+ // Output save settings button
442
+ submit_button( __('Save Settings', 'super-progressive-web-apps') );
443
+ ?>
444
+ </form>
445
+ </div>
446
+ <?php
447
+ }
admin/admin-ui-setup.php CHANGED
@@ -1,372 +1,372 @@
1
- <?php
2
- /**
3
- * Admin setup for the plugin
4
- *
5
- * @since 1.0
6
- * @function superpwa_add_menu_links() Add admin menu pages
7
- * @function superpwa_register_settings Register Settings
8
- * @function superpwa_validater_and_sanitizer() Validate And Sanitize User Input Before Its Saved To Database
9
- * @function superpwa_get_settings() Get settings from database
10
- * @function superpwa_enqueue_css_js() Enqueue CSS and JS
11
- * @function superpwa_after_save_settings_todo() Todo list after saving admin options
12
- * @function superpwa_footer_text() Admin footer text
13
- * @function superpwa_footer_version() Admin footer version
14
- */
15
-
16
- // Exit if accessed directly
17
- if ( ! defined( 'ABSPATH' ) ) exit;
18
-
19
- /**
20
- * Add admin menu pages
21
- *
22
- * @since 1.0
23
- * @refer https://developer.wordpress.org/plugins/administration-menus/
24
- */
25
- function superpwa_add_menu_links() {
26
-
27
- // Main menu page
28
- add_menu_page( __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), __( 'SuperPWA', 'super-progressive-web-apps' ), 'manage_options', 'superpwa','superpwa_admin_interface_render', SUPERPWA_PATH_SRC. 'admin/img/superpwa-menu-icon.png', 100 );
29
-
30
- // Settings page - Same as main menu page
31
- add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), __( 'Settings', 'super-progressive-web-apps' ), 'manage_options', 'superpwa', 'superpwa_admin_interface_render' );
32
-
33
- // Add-Ons page
34
- add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), __( 'Add-Ons', 'super-progressive-web-apps' ), 'manage_options', 'superpwa-addons', 'superpwa_addons_interface_render' );
35
- }
36
- add_action( 'admin_menu', 'superpwa_add_menu_links' );
37
-
38
- /**
39
- * Register Settings
40
- *
41
- * @since 1.0
42
- */
43
- function superpwa_register_settings() {
44
-
45
- // Register Setting
46
- register_setting(
47
- 'superpwa_settings_group', // Group name
48
- 'superpwa_settings', // Setting name = html form <input> name on settings form
49
- 'superpwa_validater_and_sanitizer' // Input sanitizer
50
- );
51
-
52
- // Basic Application Settings
53
- add_settings_section(
54
- 'superpwa_basic_settings_section', // ID
55
- __return_false(), // Title
56
- '__return_false', // Callback Function
57
- 'superpwa_basic_settings_section' // Page slug
58
- );
59
-
60
- // Application Name
61
- add_settings_field(
62
- 'superpwa_app_name', // ID
63
- __('Application Name', 'super-progressive-web-apps'), // Title
64
- 'superpwa_app_name_cb', // CB
65
- 'superpwa_basic_settings_section', // Page slug
66
- 'superpwa_basic_settings_section' // Settings Section ID
67
- );
68
-
69
- // Application Short Name
70
- add_settings_field(
71
- 'superpwa_app_short_name', // ID
72
- __('Application Short Name', 'super-progressive-web-apps'), // Title
73
- 'superpwa_app_short_name_cb', // CB
74
- 'superpwa_basic_settings_section', // Page slug
75
- 'superpwa_basic_settings_section' // Settings Section ID
76
- );
77
-
78
- // Description
79
- add_settings_field(
80
- 'superpwa_description', // ID
81
- __( 'Description', 'super-progressive-web-apps' ), // Title
82
- 'superpwa_description_cb', // CB
83
- 'superpwa_basic_settings_section', // Page slug
84
- 'superpwa_basic_settings_section' // Settings Section ID
85
- );
86
-
87
- // Application Icon
88
- add_settings_field(
89
- 'superpwa_icons', // ID
90
- __('Application Icon', 'super-progressive-web-apps'), // Title
91
- 'superpwa_app_icon_cb', // Callback function
92
- 'superpwa_basic_settings_section', // Page slug
93
- 'superpwa_basic_settings_section' // Settings Section ID
94
- );
95
-
96
- // Splash Screen Icon
97
- add_settings_field(
98
- 'superpwa_splash_icon', // ID
99
- __('Splash Screen Icon', 'super-progressive-web-apps'), // Title
100
- 'superpwa_splash_icon_cb', // Callback function
101
- 'superpwa_basic_settings_section', // Page slug
102
- 'superpwa_basic_settings_section' // Settings Section ID
103
- );
104
-
105
- // Splash Screen Background Color
106
- add_settings_field(
107
- 'superpwa_background_color', // ID
108
- __('Background Color', 'super-progressive-web-apps'), // Title
109
- 'superpwa_background_color_cb', // CB
110
- 'superpwa_basic_settings_section', // Page slug
111
- 'superpwa_basic_settings_section' // Settings Section ID
112
- );
113
-
114
- // Theme Color
115
- add_settings_field(
116
- 'superpwa_theme_color', // ID
117
- __('Theme Color', 'super-progressive-web-apps'), // Title
118
- 'superpwa_theme_color_cb', // CB
119
- 'superpwa_basic_settings_section', // Page slug
120
- 'superpwa_basic_settings_section' // Settings Section ID
121
- );
122
-
123
- // Start URL
124
- add_settings_field(
125
- 'superpwa_start_url', // ID
126
- __('Start Page', 'super-progressive-web-apps'), // Title
127
- 'superpwa_start_url_cb', // CB
128
- 'superpwa_basic_settings_section', // Page slug
129
- 'superpwa_basic_settings_section' // Settings Section ID
130
- );
131
-
132
- // Offline Page
133
- add_settings_field(
134
- 'superpwa_offline_page', // ID
135
- __('Offline Page', 'super-progressive-web-apps'), // Title
136
- 'superpwa_offline_page_cb', // CB
137
- 'superpwa_basic_settings_section', // Page slug
138
- 'superpwa_basic_settings_section' // Settings Section ID
139
- );
140
-
141
- // Orientation
142
- add_settings_field(
143
- 'superpwa_orientation', // ID
144
- __('Orientation', 'super-progressive-web-apps'), // Title
145
- 'superpwa_orientation_cb', // CB
146
- 'superpwa_basic_settings_section', // Page slug
147
- 'superpwa_basic_settings_section' // Settings Section ID
148
- );
149
-
150
- // Display
151
- add_settings_field(
152
- 'superpwa_display', // ID
153
- __('Display', 'super-progressive-web-apps'), // Title
154
- 'superpwa_display_cb', // CB
155
- 'superpwa_basic_settings_section', // Page slug
156
- 'superpwa_basic_settings_section' // Settings Section ID
157
- );
158
-
159
- // PWA Status
160
- add_settings_section(
161
- 'superpwa_pwa_status_section', // ID
162
- __('Status', 'super-progressive-web-apps'), // Title
163
- '__return_false', // Callback Function
164
- 'superpwa_pwa_status_section' // Page slug
165
- );
166
-
167
- // Manifest status
168
- add_settings_field(
169
- 'superpwa_manifest_status', // ID
170
- __('Manifest', 'super-progressive-web-apps'), // Title
171
- 'superpwa_manifest_status_cb', // CB
172
- 'superpwa_pwa_status_section', // Page slug
173
- 'superpwa_pwa_status_section' // Settings Section ID
174
- );
175
-
176
- // Service Worker status
177
- add_settings_field(
178
- 'superpwa_sw_status', // ID
179
- __('Service Worker', 'super-progressive-web-apps'), // Title
180
- 'superpwa_sw_status_cb', // CB
181
- 'superpwa_pwa_status_section', // Page slug
182
- 'superpwa_pwa_status_section' // Settings Section ID
183
- );
184
-
185
- // HTTPS status
186
- add_settings_field(
187
- 'superpwa_https_status', // ID
188
- __('HTTPS', 'super-progressive-web-apps'), // Title
189
- 'superpwa_https_status_cb', // CB
190
- 'superpwa_pwa_status_section', // Page slug
191
- 'superpwa_pwa_status_section' // Settings Section ID
192
- );
193
- }
194
- add_action( 'admin_init', 'superpwa_register_settings' );
195
-
196
- /**
197
- * Validate and sanitize user input before its saved to database
198
- *
199
- * @author Arun Basil Lal
200
- *
201
- * @param (array) $settings Values passed from the Settings API from SuperPWA > Settings
202
- *
203
- * @since 1.0
204
- * @since 1.3 Added splash_icon
205
- * @since 1.6 Added description
206
- * @since 2.0 Limit app_short_name to 12 characters
207
- * @since 2.0.1 Added is_static_sw and is_static_manifest
208
- */
209
- function superpwa_validater_and_sanitizer( $settings ) {
210
-
211
- // Sanitize Application Name
212
- $settings['app_name'] = sanitize_text_field( $settings['app_name'] ) == '' ? get_bloginfo( 'name' ) : sanitize_text_field( $settings['app_name'] );
213
-
214
- // Sanitize Application Short Name
215
- $settings['app_short_name'] = substr( sanitize_text_field( $settings['app_short_name'] ) == '' ? get_bloginfo( 'name' ) : sanitize_text_field( $settings['app_short_name'] ), 0, 12 );
216
-
217
- // Sanitize description
218
- $settings['description'] = sanitize_text_field( $settings['description'] );
219
-
220
- // Sanitize hex color input for background_color
221
- $settings['background_color'] = preg_match( '/#([a-f0-9]{3}){1,2}\b/i', $settings['background_color'] ) ? sanitize_text_field( $settings['background_color'] ) : '#D5E0EB';
222
-
223
- // Sanitize hex color input for theme_color
224
- $settings['theme_color'] = preg_match( '/#([a-f0-9]{3}){1,2}\b/i', $settings['theme_color'] ) ? sanitize_text_field( $settings['theme_color'] ) : '#D5E0EB';
225
-
226
- // Sanitize application icon
227
- $settings['icon'] = sanitize_text_field( $settings['icon'] ) == '' ? superpwa_httpsify( SUPERPWA_PATH_SRC . 'public/images/logo.png' ) : sanitize_text_field( superpwa_httpsify( $settings['icon'] ) );
228
-
229
- // Sanitize splash screen icon
230
- $settings['splash_icon'] = sanitize_text_field( superpwa_httpsify( $settings['splash_icon'] ) );
231
-
232
- /**
233
- * Get current settings already saved in the database.
234
- *
235
- * When the SuperPWA > Settings page is saved, the form does not have the values for
236
- * is_static_sw or is_static_manifest. So this is added here to match the already saved
237
- * values in the database.
238
- */
239
- $current_settings = superpwa_get_settings();
240
-
241
- if ( ! isset( $settings['is_static_sw'] ) ) {
242
- $settings['is_static_sw'] = $current_settings['is_static_sw'];
243
- }
244
-
245
- if ( ! isset( $settings['is_static_manifest'] ) ) {
246
- $settings['is_static_manifest'] = $current_settings['is_static_manifest'];
247
- }
248
-
249
- return $settings;
250
- }
251
-
252
- /**
253
- * Get settings from database
254
- *
255
- * @return (Array) A merged array of default and settings saved in database.
256
- *
257
- * @author Arun Basil Lal
258
- *
259
- * @since 1.0
260
- * @since 2.0 Added display
261
- * @since 2.0.1 Added is_static_manifest. 1 for static files, 0 for dynamic files.
262
- * @since 2.0.1 Added is_static_sw. 1 for static files, 0 for dynamic files.
263
- */
264
- function superpwa_get_settings() {
265
-
266
- $defaults = array(
267
- 'app_name' => get_bloginfo( 'name' ),
268
- 'app_short_name' => substr( get_bloginfo( 'name' ), 0, 12 ),
269
- 'description' => get_bloginfo( 'description' ),
270
- 'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
271
- 'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
272
- 'background_color' => '#D5E0EB',
273
- 'theme_color' => '#D5E0EB',
274
- 'start_url' => 0,
275
- 'start_url_amp' => 0,
276
- 'offline_page' => 0,
277
- 'orientation' => 1,
278
- 'display' => 1,
279
- 'is_static_manifest'=> 0,
280
- 'is_static_sw' => 0,
281
- );
282
-
283
- $settings = get_option( 'superpwa_settings', $defaults );
284
-
285
- return $settings;
286
- }
287
-
288
- /**
289
- * Todo list after saving admin options
290
- *
291
- * Regenerate manifest
292
- * Regenerate service worker
293
- *
294
- * @author Arun Basil Lal
295
- *
296
- * @since 1.0
297
- */
298
- function superpwa_after_save_settings_todo() {
299
-
300
- // Regenerate manifest
301
- superpwa_generate_manifest();
302
-
303
- // Regenerate service worker
304
- superpwa_generate_sw();
305
- }
306
- add_action( 'add_option_superpwa_settings', 'superpwa_after_save_settings_todo' );
307
- add_action( 'update_option_superpwa_settings', 'superpwa_after_save_settings_todo' );
308
-
309
- /**
310
- * Enqueue CSS and JS
311
- *
312
- * @since 1.0
313
- */
314
- function superpwa_enqueue_css_js( $hook ) {
315
-
316
- // Load only on SuperPWA plugin pages
317
- if ( strpos( $hook, 'superpwa' ) === false ) {
318
- return;
319
- }
320
-
321
- // Color picker CSS
322
- // @refer https://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/
323
- wp_enqueue_style( 'wp-color-picker' );
324
-
325
- // Everything needed for media upload
326
- wp_enqueue_media();
327
-
328
- // Main JS
329
- wp_enqueue_script( 'superpwa-main-js', SUPERPWA_PATH_SRC . 'admin/js/main.js', array( 'wp-color-picker' ), SUPERPWA_VERSION, true );
330
- }
331
- add_action( 'admin_enqueue_scripts', 'superpwa_enqueue_css_js' );
332
-
333
- /**
334
- * Admin footer text
335
- *
336
- * A function to add footer text to the settings page of the plugin.
337
- * @since 1.2
338
- * @refer https://codex.wordpress.org/Function_Reference/get_current_screen
339
- */
340
- function superpwa_footer_text( $default ) {
341
-
342
- // Retun default on non-plugin pages
343
- $screen = get_current_screen();
344
- if ( strpos( $screen->id, 'superpwa' ) === false ) {
345
- return $default;
346
- }
347
-
348
- $superpwa_footer_text = sprintf( __( 'If you like SuperPWA, please <a href="%s" target="_blank">make a donation</a> or leave a <a href="%s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating to support continued development. Thanks a bunch!', 'super-progressive-web-apps' ),
349
- 'https://millionclues.com/donate/',
350
- 'https://wordpress.org/support/plugin/super-progressive-web-apps/reviews/?rate=5#new-post'
351
- );
352
-
353
- return $superpwa_footer_text;
354
- }
355
- add_filter( 'admin_footer_text', 'superpwa_footer_text' );
356
-
357
- /**
358
- * Admin footer version
359
- *
360
- * @since 1.0
361
- */
362
- function superpwa_footer_version( $default ) {
363
-
364
- // Retun default on non-plugin pages
365
- $screen = get_current_screen();
366
- if ( strpos( $screen->id, 'superpwa' ) === false ) {
367
- return $default;
368
- }
369
-
370
- return 'SuperPWA ' . SUPERPWA_VERSION;
371
- }
372
  add_filter( 'update_footer', 'superpwa_footer_version', 11 );
1
+ <?php
2
+ /**
3
+ * Admin setup for the plugin
4
+ *
5
+ * @since 1.0
6
+ * @function superpwa_add_menu_links() Add admin menu pages
7
+ * @function superpwa_register_settings Register Settings
8
+ * @function superpwa_validater_and_sanitizer() Validate And Sanitize User Input Before Its Saved To Database
9
+ * @function superpwa_get_settings() Get settings from database
10
+ * @function superpwa_enqueue_css_js() Enqueue CSS and JS
11
+ * @function superpwa_after_save_settings_todo() Todo list after saving admin options
12
+ * @function superpwa_footer_text() Admin footer text
13
+ * @function superpwa_footer_version() Admin footer version
14
+ */
15
+
16
+ // Exit if accessed directly
17
+ if ( ! defined( 'ABSPATH' ) ) exit;
18
+
19
+ /**
20
+ * Add admin menu pages
21
+ *
22
+ * @since 1.0
23
+ * @refer https://developer.wordpress.org/plugins/administration-menus/
24
+ */
25
+ function superpwa_add_menu_links() {
26
+
27
+ // Main menu page
28
+ add_menu_page( __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), __( 'SuperPWA', 'super-progressive-web-apps' ), 'manage_options', 'superpwa','superpwa_admin_interface_render', SUPERPWA_PATH_SRC. 'admin/img/superpwa-menu-icon.png', 100 );
29
+
30
+ // Settings page - Same as main menu page
31
+ add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), __( 'Settings', 'super-progressive-web-apps' ), 'manage_options', 'superpwa', 'superpwa_admin_interface_render' );
32
+
33
+ // Add-Ons page
34
+ add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), __( 'Add-Ons', 'super-progressive-web-apps' ), 'manage_options', 'superpwa-addons', 'superpwa_addons_interface_render' );
35
+ }
36
+ add_action( 'admin_menu', 'superpwa_add_menu_links' );
37
+
38
+ /**
39
+ * Register Settings
40
+ *
41
+ * @since 1.0
42
+ */
43
+ function superpwa_register_settings() {
44
+
45
+ // Register Setting
46
+ register_setting(
47
+ 'superpwa_settings_group', // Group name
48
+ 'superpwa_settings', // Setting name = html form <input> name on settings form
49
+ 'superpwa_validater_and_sanitizer' // Input sanitizer
50
+ );
51
+
52
+ // Basic Application Settings
53
+ add_settings_section(
54
+ 'superpwa_basic_settings_section', // ID
55
+ __return_false(), // Title
56
+ '__return_false', // Callback Function
57
+ 'superpwa_basic_settings_section' // Page slug
58
+ );
59
+
60
+ // Application Name
61
+ add_settings_field(
62
+ 'superpwa_app_name', // ID
63
+ __('Application Name', 'super-progressive-web-apps'), // Title
64
+ 'superpwa_app_name_cb', // CB
65
+ 'superpwa_basic_settings_section', // Page slug
66
+ 'superpwa_basic_settings_section' // Settings Section ID
67
+ );
68
+
69
+ // Application Short Name
70
+ add_settings_field(
71
+ 'superpwa_app_short_name', // ID
72
+ __('Application Short Name', 'super-progressive-web-apps'), // Title
73
+ 'superpwa_app_short_name_cb', // CB
74
+ 'superpwa_basic_settings_section', // Page slug
75
+ 'superpwa_basic_settings_section' // Settings Section ID
76
+ );
77
+
78
+ // Description
79
+ add_settings_field(
80
+ 'superpwa_description', // ID
81
+ __( 'Description', 'super-progressive-web-apps' ), // Title
82
+ 'superpwa_description_cb', // CB
83
+ 'superpwa_basic_settings_section', // Page slug
84
+ 'superpwa_basic_settings_section' // Settings Section ID
85
+ );
86
+
87
+ // Application Icon
88
+ add_settings_field(
89
+ 'superpwa_icons', // ID
90
+ __('Application Icon', 'super-progressive-web-apps'), // Title
91
+ 'superpwa_app_icon_cb', // Callback function
92
+ 'superpwa_basic_settings_section', // Page slug
93
+ 'superpwa_basic_settings_section' // Settings Section ID
94
+ );
95
+
96
+ // Splash Screen Icon
97
+ add_settings_field(
98
+ 'superpwa_splash_icon', // ID
99
+ __('Splash Screen Icon', 'super-progressive-web-apps'), // Title
100
+ 'superpwa_splash_icon_cb', // Callback function
101
+ 'superpwa_basic_settings_section', // Page slug
102
+ 'superpwa_basic_settings_section' // Settings Section ID
103
+ );
104
+
105
+ // Splash Screen Background Color
106
+ add_settings_field(
107
+ 'superpwa_background_color', // ID
108
+ __('Background Color', 'super-progressive-web-apps'), // Title
109
+ 'superpwa_background_color_cb', // CB
110
+ 'superpwa_basic_settings_section', // Page slug
111
+ 'superpwa_basic_settings_section' // Settings Section ID
112
+ );
113
+
114
+ // Theme Color
115
+ add_settings_field(
116
+ 'superpwa_theme_color', // ID
117
+ __('Theme Color', 'super-progressive-web-apps'), // Title
118
+ 'superpwa_theme_color_cb', // CB
119
+ 'superpwa_basic_settings_section', // Page slug
120
+ 'superpwa_basic_settings_section' // Settings Section ID
121
+ );
122
+
123
+ // Start URL
124
+ add_settings_field(
125
+ 'superpwa_start_url', // ID
126
+ __('Start Page', 'super-progressive-web-apps'), // Title
127
+ 'superpwa_start_url_cb', // CB
128
+ 'superpwa_basic_settings_section', // Page slug
129
+ 'superpwa_basic_settings_section' // Settings Section ID
130
+ );
131
+
132
+ // Offline Page
133
+ add_settings_field(
134
+ 'superpwa_offline_page', // ID
135
+ __('Offline Page', 'super-progressive-web-apps'), // Title
136
+ 'superpwa_offline_page_cb', // CB
137
+ 'superpwa_basic_settings_section', // Page slug
138
+ 'superpwa_basic_settings_section' // Settings Section ID
139
+ );
140
+
141
+ // Orientation
142
+ add_settings_field(
143
+ 'superpwa_orientation', // ID
144
+ __('Orientation', 'super-progressive-web-apps'), // Title
145
+ 'superpwa_orientation_cb', // CB
146
+ 'superpwa_basic_settings_section', // Page slug
147
+ 'superpwa_basic_settings_section' // Settings Section ID
148
+ );
149
+
150
+ // Display
151
+ add_settings_field(
152
+ 'superpwa_display', // ID
153
+ __('Display', 'super-progressive-web-apps'), // Title
154
+ 'superpwa_display_cb', // CB
155
+ 'superpwa_basic_settings_section', // Page slug
156
+ 'superpwa_basic_settings_section' // Settings Section ID
157
+ );
158
+
159
+ // PWA Status
160
+ add_settings_section(
161
+ 'superpwa_pwa_status_section', // ID
162
+ __('Status', 'super-progressive-web-apps'), // Title
163
+ '__return_false', // Callback Function
164
+ 'superpwa_pwa_status_section' // Page slug
165
+ );
166
+
167
+ // Manifest status
168
+ add_settings_field(
169
+ 'superpwa_manifest_status', // ID
170
+ __('Manifest', 'super-progressive-web-apps'), // Title
171
+ 'superpwa_manifest_status_cb', // CB
172
+ 'superpwa_pwa_status_section', // Page slug
173
+ 'superpwa_pwa_status_section' // Settings Section ID
174
+ );
175
+
176
+ // Service Worker status
177
+ add_settings_field(
178
+ 'superpwa_sw_status', // ID
179
+ __('Service Worker', 'super-progressive-web-apps'), // Title
180
+ 'superpwa_sw_status_cb', // CB
181
+ 'superpwa_pwa_status_section', // Page slug
182
+ 'superpwa_pwa_status_section' // Settings Section ID
183
+ );
184
+
185
+ // HTTPS status
186
+ add_settings_field(
187
+ 'superpwa_https_status', // ID
188
+ __('HTTPS', 'super-progressive-web-apps'), // Title
189
+ 'superpwa_https_status_cb', // CB
190
+ 'superpwa_pwa_status_section', // Page slug
191
+ 'superpwa_pwa_status_section' // Settings Section ID
192
+ );
193
+ }
194
+ add_action( 'admin_init', 'superpwa_register_settings' );
195
+
196
+ /**
197
+ * Validate and sanitize user input before its saved to database
198
+ *
199
+ * @author Arun Basil Lal
200
+ *
201
+ * @param (array) $settings Values passed from the Settings API from SuperPWA > Settings
202
+ *
203
+ * @since 1.0
204
+ * @since 1.3 Added splash_icon
205
+ * @since 1.6 Added description
206
+ * @since 2.0 Limit app_short_name to 12 characters
207
+ * @since 2.0.1 Added is_static_sw and is_static_manifest
208
+ */
209
+ function superpwa_validater_and_sanitizer( $settings ) {
210
+
211
+ // Sanitize Application Name
212
+ $settings['app_name'] = sanitize_text_field( $settings['app_name'] ) == '' ? get_bloginfo( 'name' ) : sanitize_text_field( $settings['app_name'] );
213
+
214
+ // Sanitize Application Short Name
215
+ $settings['app_short_name'] = substr( sanitize_text_field( $settings['app_short_name'] ) == '' ? get_bloginfo( 'name' ) : sanitize_text_field( $settings['app_short_name'] ), 0, 12 );
216
+
217
+ // Sanitize description
218
+ $settings['description'] = sanitize_text_field( $settings['description'] );
219
+
220
+ // Sanitize hex color input for background_color
221
+ $settings['background_color'] = preg_match( '/#([a-f0-9]{3}){1,2}\b/i', $settings['background_color'] ) ? sanitize_text_field( $settings['background_color'] ) : '#D5E0EB';
222
+
223
+ // Sanitize hex color input for theme_color
224
+ $settings['theme_color'] = preg_match( '/#([a-f0-9]{3}){1,2}\b/i', $settings['theme_color'] ) ? sanitize_text_field( $settings['theme_color'] ) : '#D5E0EB';
225
+
226
+ // Sanitize application icon
227
+ $settings['icon'] = sanitize_text_field( $settings['icon'] ) == '' ? superpwa_httpsify( SUPERPWA_PATH_SRC . 'public/images/logo.png' ) : sanitize_text_field( superpwa_httpsify( $settings['icon'] ) );
228
+
229
+ // Sanitize splash screen icon
230
+ $settings['splash_icon'] = sanitize_text_field( superpwa_httpsify( $settings['splash_icon'] ) );
231
+
232
+ /**
233
+ * Get current settings already saved in the database.
234
+ *
235
+ * When the SuperPWA > Settings page is saved, the form does not have the values for
236
+ * is_static_sw or is_static_manifest. So this is added here to match the already saved
237
+ * values in the database.
238
+ */
239
+ $current_settings = superpwa_get_settings();
240
+
241
+ if ( ! isset( $settings['is_static_sw'] ) ) {
242
+ $settings['is_static_sw'] = $current_settings['is_static_sw'];
243
+ }
244
+
245
+ if ( ! isset( $settings['is_static_manifest'] ) ) {
246
+ $settings['is_static_manifest'] = $current_settings['is_static_manifest'];
247
+ }
248
+
249
+ return $settings;
250
+ }
251
+
252
+ /**
253
+ * Get settings from database
254
+ *
255
+ * @return (Array) A merged array of default and settings saved in database.
256
+ *
257
+ * @author Arun Basil Lal
258
+ *
259
+ * @since 1.0
260
+ * @since 2.0 Added display
261
+ * @since 2.0.1 Added is_static_manifest. 1 for static files, 0 for dynamic files.
262
+ * @since 2.0.1 Added is_static_sw. 1 for static files, 0 for dynamic files.
263
+ */
264
+ function superpwa_get_settings() {
265
+
266
+ $defaults = array(
267
+ 'app_name' => get_bloginfo( 'name' ),
268
+ 'app_short_name' => substr( get_bloginfo( 'name' ), 0, 12 ),
269
+ 'description' => get_bloginfo( 'description' ),
270
+ 'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
271
+ 'splash_icon' => SUPERPWA_PATH_SRC . 'public/images/logo-512x512.png',
272
+ 'background_color' => '#D5E0EB',
273
+ 'theme_color' => '#D5E0EB',
274
+ 'start_url' => 0,
275
+ 'start_url_amp' => 0,
276
+ 'offline_page' => 0,
277
+ 'orientation' => 1,
278
+ 'display' => 1,
279
+ 'is_static_manifest'=> 0,
280
+ 'is_static_sw' => 0,
281
+ );
282
+
283
+ $settings = get_option( 'superpwa_settings', $defaults );
284
+
285
+ return $settings;
286
+ }
287
+
288
+ /**
289
+ * Todo list after saving admin options
290
+ *
291
+ * Regenerate manifest
292
+ * Regenerate service worker
293
+ *
294
+ * @author Arun Basil Lal
295
+ *
296
+ * @since 1.0
297
+ */
298
+ function superpwa_after_save_settings_todo() {
299
+
300
+ // Regenerate manifest
301
+ superpwa_generate_manifest();
302
+
303
+ // Regenerate service worker
304
+ superpwa_generate_sw();
305
+ }
306
+ add_action( 'add_option_superpwa_settings', 'superpwa_after_save_settings_todo' );
307
+ add_action( 'update_option_superpwa_settings', 'superpwa_after_save_settings_todo' );
308
+
309
+ /**
310
+ * Enqueue CSS and JS
311
+ *
312
+ * @since 1.0
313
+ */
314
+ function superpwa_enqueue_css_js( $hook ) {
315
+
316
+ // Load only on SuperPWA plugin pages
317
+ if ( strpos( $hook, 'superpwa' ) === false ) {
318
+ return;
319
+ }
320
+
321
+ // Color picker CSS
322
+ // @refer https://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/
323
+ wp_enqueue_style( 'wp-color-picker' );
324
+
325
+ // Everything needed for media upload
326
+ wp_enqueue_media();
327
+
328
+ // Main JS
329
+ wp_enqueue_script( 'superpwa-main-js', SUPERPWA_PATH_SRC . 'admin/js/main.js', array( 'wp-color-picker' ), SUPERPWA_VERSION, true );
330
+ }
331
+ add_action( 'admin_enqueue_scripts', 'superpwa_enqueue_css_js' );
332
+
333
+ /**
334
+ * Admin footer text
335
+ *
336
+ * A function to add footer text to the settings page of the plugin.
337
+ * @since 1.2
338
+ * @refer https://codex.wordpress.org/Function_Reference/get_current_screen
339
+ */
340
+ function superpwa_footer_text( $default ) {
341
+
342
+ // Retun default on non-plugin pages
343
+ $screen = get_current_screen();
344
+ if ( strpos( $screen->id, 'superpwa' ) === false ) {
345
+ return $default;
346
+ }
347
+
348
+ $superpwa_footer_text = sprintf( __( 'If you like SuperPWA, please <a href="%s" target="_blank">make a donation</a> or leave a <a href="%s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating to support continued development. Thanks a bunch!', 'super-progressive-web-apps' ),
349
+ 'https://millionclues.com/donate/',
350
+ 'https://wordpress.org/support/plugin/super-progressive-web-apps/reviews/?rate=5#new-post'
351
+ );
352
+
353
+ return $superpwa_footer_text;
354
+ }
355
+ add_filter( 'admin_footer_text', 'superpwa_footer_text' );
356
+
357
+ /**
358
+ * Admin footer version
359
+ *
360
+ * @since 1.0
361
+ */
362
+ function superpwa_footer_version( $default ) {
363
+
364
+ // Retun default on non-plugin pages
365
+ $screen = get_current_screen();
366
+ if ( strpos( $screen->id, 'superpwa' ) === false ) {
367
+ return $default;
368
+ }
369
+
370
+ return 'SuperPWA ' . SUPERPWA_VERSION;
371
+ }
372
  add_filter( 'update_footer', 'superpwa_footer_version', 11 );
admin/basic-setup.php CHANGED
@@ -1,460 +1,460 @@
1
- <?php
2
- /**
3
- * Basic setup functions for the plugin
4
- *
5
- * @since 1.0
6
- *
7
- * @function superpwa_activate_plugin() Plugin activatation todo list
8
- * @function superpwa_activation_redirect() Redirect to SuperPWA UI on plugin activation
9
- * @function superpwa_admin_notices() Admin notices
10
- * @function superpwa_network_admin_notices() Network Admin notices
11
- * @function superpwa_upgrader() Plugin upgrade todo list
12
- * @function superpwa_deactivate_plugin() Plugin deactivation todo list
13
- * @function superpwa_load_plugin_textdomain() Load plugin text domain
14
- * @function superpwa_settings_link() Print direct link to plugin settings in plugins list in admin
15
- * @function superpwa_plugin_row_meta() Add donate and other links to plugins list
16
- */
17
-
18
- // Exit if accessed directly
19
- if ( ! defined('ABSPATH') ) exit;
20
-
21
- /**
22
- * Plugin activation todo list
23
- *
24
- * This function runs when user activates the plugin. Used in register_activation_hook()
25
- * On multisites, during network activation, this is fired only for the main site.
26
- * For the rest of the sites, superpwa_upgrader() handles generation of manifest and service worker.
27
- *
28
- * @param $network_active (Boolean) True if the plugin is network activated, false otherwise.
29
- *
30
- * @author Arun Basil Lal
31
- *
32
- * @link https://www.alexgeorgiou.gr/network-activated-wordpress-plugins/ (Thanks Alex!)
33
- *
34
- * @since 1.0
35
- * @since 1.6 register_activation_hook() moved to this file (basic-setup.php) from main plugin file (superpwa.php).
36
- * @since 1.6 Added checks for multisite compatibility.
37
- */
38
- function superpwa_activate_plugin( $network_active ) {
39
-
40
- // Not network active i.e. plugin is activated on a single install (normal WordPress install) or a single site on a multisite network
41
- if ( ! $network_active ) {
42
-
43
- // Set transient for single site activation notice
44
- set_transient( 'superpwa_admin_notice_activation', true, 60 );
45
-
46
- return;
47
- }
48
-
49
- // If we are here, then plugin is network activated on a multisite. Set transient for activation notice on network admin.
50
- set_transient( 'superpwa_network_admin_notice_activation', true, 60 );
51
- }
52
- register_activation_hook( SUPERPWA_PATH_ABS . 'superpwa.php', 'superpwa_activate_plugin' );
53
-
54
- /**
55
- * Redirect to SuperPWA UI on plugin activation.
56
- *
57
- * Will redirect to SuperPWA settings page when plugin is activated.
58
- * Will not redirect if multiple plugins are activated at the same time.
59
- * Will not redirect when activated network wide on multisite. Network admins know their way.
60
- *
61
- * @param (string) $plugin Path to the main plugin file from plugins directory.
62
- * @param (bool) $network_wide True when network activated on multisites. False otherwise.
63
- *
64
- * @author Arun Basil Lal
65
- *
66
- * @since 2.0
67
- * @since 2.1 Added a check to see if WP_Plugins_List_Table class is available.
68
- */
69
- function superpwa_activation_redirect( $plugin, $network_wide ) {
70
-
71
- // Return if not SuperPWA or if plugin is activated network wide.
72
- if ( $plugin !== plugin_basename( SUPERPWA_PLUGIN_FILE ) || $network_wide === true ) {
73
- return false;
74
- }
75
-
76
- if ( ! class_exists( 'WP_Plugins_List_Table' ) ) {
77
- return false;
78
- }
79
-
80
- /**
81
- * An instance of the WP_Plugins_List_Table class.
82
- *
83
- * @link https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-admin/plugins.php#L15
84
- */
85
- $wp_list_table_instance = new WP_Plugins_List_Table();
86
- $current_action = $wp_list_table_instance->current_action();
87
-
88
- // When only one plugin is activated, the current_action() method will return activate.
89
- if ( $current_action !== 'activate' ) {
90
- return false;
91
- }
92
-
93
- // Redirect to SuperPWA settings page.
94
- exit( wp_redirect( admin_url( 'admin.php?page=superpwa' ) ) );
95
- }
96
- add_action( 'activated_plugin', 'superpwa_activation_redirect', PHP_INT_MAX, 2 );
97
-
98
- /**
99
- * Admin Notices
100
- *
101
- * @since 1.2 Admin notice on plugin activation
102
- */
103
- function superpwa_admin_notices() {
104
-
105
- // Notices only for admins
106
- if ( ! current_user_can( 'manage_options' ) ) {
107
- return;
108
- }
109
-
110
- // Admin notice on plugin activation
111
- if ( get_transient( 'superpwa_admin_notice_activation' ) ) {
112
-
113
- $superpwa_is_ready = superpwa_is_pwa_ready() ? __( 'Your app is ready with the default settings. ', 'super-progressive-web-apps' ) : '';
114
-
115
- // Do not display link to settings UI if we are already in the UI.
116
- $screen = get_current_screen();
117
- $superpwa_ui_link_text = ( strpos( $screen->id, 'superpwa' ) === false ) ? sprintf( __( '<a href="%s">Customize your app &rarr;</a>', 'super-progressive-web-apps' ), admin_url( 'admin.php?page=superpwa' ) ) : '';
118
-
119
- echo '<div class="updated notice is-dismissible"><p>' . __( 'Thank you for installing <strong>Super Progressive Web Apps!</strong> ', 'super-progressive-web-apps' ) . $superpwa_is_ready . $superpwa_ui_link_text . '</p></div>';
120
-
121
- // Delete transient
122
- delete_transient( 'superpwa_admin_notice_activation' );
123
- }
124
-
125
- // Admin notice on plugin upgrade
126
- if ( get_transient( 'superpwa_admin_notice_upgrade_complete' ) ) {
127
-
128
- echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>SuperPWA</strong>: Successfully updated to version %s. Thank you! <a href="%s" target="_blank">Discover new features and read the story &rarr;</a>', 'super-progressive-web-apps' ), SUPERPWA_VERSION, 'https://superpwa.com/category/release-notes/latest/?utm_source=superpwa-plugin&utm_medium=update-success-notice' ) . '</p></div>';
129
-
130
- // Delete transient
131
- delete_transient( 'superpwa_admin_notice_upgrade_complete' );
132
- }
133
- }
134
- add_action( 'admin_notices', 'superpwa_admin_notices' );
135
-
136
- /**
137
- * Network Admin notices
138
- *
139
- * @since 1.6 Admin notice on multisite network activation
140
- */
141
- function superpwa_network_admin_notices() {
142
-
143
- // Notices only for admins
144
- if ( ! current_user_can( 'manage_options' ) ) {
145
- return;
146
- }
147
-
148
- // Network admin notice on multisite network activation
149
- if ( get_transient( 'superpwa_network_admin_notice_activation' ) ) {
150
-
151
- $superpwa_is_ready = superpwa_is_pwa_ready() ? 'Your app is ready on the main website with the default settings. ' : '';
152
-
153
- echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( 'Thank you for installing <strong>Super Progressive Web Apps!</strong> '. $superpwa_is_ready .'<a href="%s">Customize your app &rarr;</a><br/>Note: manifest and service worker for the individual websites will be generated on the first visit to the respective WordPress admin.', 'super-progressive-web-apps' ), admin_url( 'admin.php?page=superpwa' ) ) . '</p></div>';
154
-
155
- // Delete transient
156
- delete_transient( 'superpwa_network_admin_notice_activation' );
157
- }
158
-
159
- // Network admin notice on plugin upgrade
160
- if ( get_transient( 'superpwa_admin_notice_upgrade_complete' ) ) {
161
-
162
- echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>SuperPWA</strong>: Successfully updated to version %s. Thank you! <a href="%s" target="_blank">Discover new features and read the story &rarr;</a>', 'super-progressive-web-apps' ), SUPERPWA_VERSION, 'https://superpwa.com/category/release-notes/latest/?utm_source=superpwa-plugin&utm_medium=update-success-notice-multisite' ) . '</p></div>';
163
-
164
- // Delete transient
165
- delete_transient( 'superpwa_admin_notice_upgrade_complete' );
166
- }
167
- }
168
- add_action( 'network_admin_notices', 'superpwa_network_admin_notices' );
169
-
170
- /**
171
- * Plugin upgrade todo list
172
- *
173
- * @since 1.3.1
174
- * @since 1.4 Added orientation setting and theme_color to database when upgrading from pre 1.4 versions.
175
- * @since 1.6 Added multisite compatibility.
176
- */
177
- function superpwa_upgrader() {
178
-
179
- $current_ver = get_option( 'superpwa_version' );
180
-
181
- // Return if we have already done this todo
182
- if ( version_compare( $current_ver, SUPERPWA_VERSION, '==' ) ) {
183
- return;
184
- }
185
-
186
- /**
187
- * Todo list for fresh install.
188
- *
189
- * On a multisite, during network activation, the activation hook (and activation todo) is not fired.
190
- * Manifest and service worker is generated the first time the wp-admin is loaded (when admin_init is fired).
191
- */
192
- if ( $current_ver === false ) {
193
-
194
- // Generate manifest
195
- superpwa_generate_manifest();
196
-
197
- // Generate service worker
198
- superpwa_generate_sw();
199
-
200
- if ( is_multisite() ) {
201
-
202
- // For multisites, save the activation status of current blog.
203
- superpwa_multisite_activation_status( true );
204
- }
205
-
206
- // Save SuperPWA version to database.
207
- add_option( 'superpwa_version', SUPERPWA_VERSION );
208
-
209
- return;
210
- }
211
-
212
- /**
213
- * Add orientation and theme_color to database when upgrading from pre 1.4 versions.
214
- *
215
- * Until 1.4, there was no UI for orientation and theme_color.
216
- * In the manifest, orientation was hard coded as 'natural'.
217
- * background_color had UI and this value was used for both background_color and theme_color in the manifest.
218
- *
219
- * @since 1.4
220
- */
221
- if ( version_compare( $current_ver, '1.3.1', '<=' ) ) {
222
-
223
- // Get settings
224
- $settings = superpwa_get_settings();
225
-
226
- // Orientation was set as 'natural' until version 1.4. Set it as 1, which is 'portrait'.
227
- $settings['orientation'] = 1;
228
-
229
- // theme_color was same as background_color until version 1.4
230
- $settings['theme_color'] = $settings['background_color'];
231
-
232
- // Write settings back to database
233
- update_option( 'superpwa_settings', $settings );
234
- }
235
-
236
- /**
237
- * Delete existing service worker for single sites that use OneSignal.
238
- *
239
- * For OneSignal compatibility, in version 1.8 the service worker filename is renamed.
240
- * If OneSignal is active, by this point, the new filename will be filtered in.
241
- * This upgrade routine restores the defaul service worker filename and deletes the existing service worker.
242
- * Also adds back the filter for new filename. OneSignal compatibility for multisites is not available at this point.
243
- *
244
- * @since 1.8
245
- */
246
- if ( version_compare( $current_ver, '1.7.1', '<=' ) && class_exists( 'OneSignal' ) && ! is_multisite() ) {
247
-
248
- // Restore the default service worker filename of SuperPWA.
249
- remove_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
250
-
251
- // Delete service worker
252
- superpwa_delete_sw();
253
-
254
- // Change service worker filename to match OneSignal's service worker.
255
- add_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
256
- }
257
-
258
- /**
259
- * Add display to database when upgrading from pre 2.0 versions.
260
- * Delete manifest and service worker files.
261
- *
262
- * Until 2.0, there was no UI for display.
263
- * In the manifest, display was hard coded as 'standalone'.
264
- *
265
- * Starting with 2.0, manifest and service worker files are dynamic and no longer static.
266
- *
267
- * @since 2.0
268
- */
269
- if ( version_compare( $current_ver, '1.9', '<=' ) ) {
270
-
271
- // Get settings
272
- $settings = superpwa_get_settings();
273
-
274
- // Display was set as 'standalone' until version 2.0. Set it as 1, which is 'standalone'.
275
- $settings['display'] = 1;
276
-
277
- // Write settings back to database
278
- update_option( 'superpwa_settings', $settings );
279
- }
280
-
281
- /**
282
- * Add file state variables to database
283
- *
284
- * @since 2.0.1
285
- */
286
- if ( version_compare( $current_ver, '2.0', '<=' ) ) {
287
-
288
- // Get settings
289
- $settings = superpwa_get_settings();
290
-
291
- // 1 for static files, 0 for dynamic files (default).
292
- $settings['is_static_manifest'] = 0;
293
- $settings['is_static_sw'] = 0;
294
-
295
- // Write settings back to database
296
- update_option( 'superpwa_settings', $settings );
297
- }
298
-
299
- // Re-generate manifest
300
- superpwa_generate_manifest();
301
-
302
- // Re-generate service worker
303
- superpwa_generate_sw();
304
-
305
- // Add current version to database
306
- update_option( 'superpwa_version', SUPERPWA_VERSION );
307
-
308
- // For multisites, save the activation status of current blog.
309
- superpwa_multisite_activation_status( true );
310
-
311
- // Set transient for upgrade complete notice
312
- set_transient( 'superpwa_admin_notice_upgrade_complete', true, 60 );
313
- }
314
- add_action( 'admin_init', 'superpwa_upgrader' );
315
-
316
- /**
317
- * Plugin deactivation todo list
318
- *
319
- * Runs during deactivation.
320
- * During uninstall uninstall.php is also executed.
321
- *
322
- * @param $network_active (Boolean) True if the plugin is network activated, false otherwise.
323
- * @link https://www.alexgeorgiou.gr/network-activated-wordpress-plugins/ (Thanks Alex!)
324
- *
325
- * @since 1.0
326
- * @since 1.6 register_deactivation_hook() moved to this file (basic-setup.php) from main plugin file (superpwa.php)
327
- */
328
- function superpwa_deactivate_plugin( $network_active ) {
329
-
330
- // Delete manifest
331
- superpwa_delete_manifest();
332
-
333
- // Delete service worker
334
- superpwa_delete_sw();
335
-
336
- // For multisites, save the de-activation status of current blog.
337
- superpwa_multisite_activation_status( false );
338
-
339
- // Run the network deactivator during network deactivation
340
- if ( $network_active === true ) {
341
- superpwa_multisite_network_deactivator();
342
- }
343
- }
344
- register_deactivation_hook( SUPERPWA_PATH_ABS . 'superpwa.php', 'superpwa_deactivate_plugin' );
345
-
346
- /**
347
- * Load plugin text domain
348
- *
349
- * @since 1.0
350
- */
351
- function superpwa_load_plugin_textdomain() {
352
- load_plugin_textdomain( 'super-progressive-web-apps', false, '/super-progressive-web-apps/languages/' );
353
- }
354
- add_action( 'plugins_loaded', 'superpwa_load_plugin_textdomain' );
355
-
356
- /**
357
- * Print direct link to plugin settings in plugins list in admin
358
- *
359
- * @since 1.0
360
- */
361
- function superpwa_settings_link( $links ) {
362
-
363
- return array_merge(
364
- array(
365
- 'settings' => '<a href="' . admin_url( 'admin.php?page=superpwa' ) . '">' . __( 'Settings', 'super-progressive-web-apps' ) . '</a>'
366
- ),
367
- $links
368
- );
369
- }
370
- add_filter( 'plugin_action_links_' . plugin_basename( SUPERPWA_PLUGIN_FILE ), 'superpwa_settings_link' );
371
-
372
- /**
373
- * Add donate and other links to plugins list
374
- *
375
- * @since 1.0
376
- */
377
- function superpwa_plugin_row_meta( $links, $file ) {
378
-
379
- if ( strpos( $file, 'superpwa.php' ) !== false ) {
380
- $new_links = array(
381
- 'demo' => '<a href="https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=plugin_row_meta" target="_blank">' . __( 'Demo', 'super-progressive-web-apps' ) . '</a>',
382
- );
383
- $links = array_merge( $links, $new_links );
384
- }
385
-
386
- return $links;
387
- }
388
- add_filter( 'plugin_row_meta', 'superpwa_plugin_row_meta', 10, 2 );
389
-
390
- /**
391
- * Adds rewrite rules to handle request to SW javascript and Manifest json.
392
- *
393
- * @since 2.0
394
- *
395
- * @uses superpwa_get_sw_filename()
396
- * @uses superpwa_get_manifest_filename()
397
- */
398
- function superpwa_add_rewrite_rules() {
399
- $sw_filename = superpwa_get_sw_filename();
400
- add_rewrite_rule( "^/{$sw_filename}$",
401
- "index.php?{$sw_filename}=1"
402
- );
403
-
404
- $manifest_filename = superpwa_get_manifest_filename();
405
- add_rewrite_rule( "^/{$manifest_filename}$",
406
- "index.php?{$manifest_filename}=1"
407
- );
408
- }
409
-
410
- /**
411
- * Generates SW and Manifest on the fly.
412
- *
413
- * This way no physical files have to be placed on WP root folder. Hallelujah!
414
- *
415
- * @author Maria Daniel Deepak <daniel@danieldeepak.com>
416
- *
417
- * @uses superpwa_get_sw_filename()
418
- * @uses superpwa_get_manifest_filename()
419
- * @uses superpwa_manifest_template()
420
- * @uses superpwa_sw_template()
421
- *
422
- * @since 2.0
423
- * @since 2.1 uses http_build_query() instead of implode() to convert query_vars to string.
424
- */
425
- function superpwa_generate_sw_and_manifest_on_fly( $query ) {
426
- if ( ! property_exists( $query, 'query_vars' ) || ! is_array( $query->query_vars ) ) {
427
- return;
428
- }
429
- $query_vars_as_string = http_build_query( $query->query_vars );
430
- $manifest_filename = superpwa_get_manifest_filename();
431
- $sw_filename = superpwa_get_sw_filename();
432
-
433
- if ( strpos( $query_vars_as_string, $manifest_filename ) !== false ) {
434
- // Generate manifest from Settings and send the response w/ header.
435
- header( 'Content-Type: application/json' );
436
- echo json_encode( superpwa_manifest_template() );
437
- exit();
438
- }
439
- if ( strpos( $query_vars_as_string, $sw_filename ) !== false ) {
440
- header( 'Content-Type: text/javascript' );
441
- echo superpwa_sw_template();
442
- exit();
443
- }
444
- }
445
-
446
- /**
447
- * Sets up the hooks once.
448
- *
449
- * Possibly put in the same order as execution for better understanding.
450
- *
451
- * @link https://codex.wordpress.org/Plugin_API/Action_Reference Actions run during a typical Request.
452
- * @link https://codex.wordpress.org/Plugin_API/Action_Reference/plugins_loaded
453
- *
454
- * @since 2.0
455
- */
456
- function superpwa_setup_hooks() {
457
- add_action( 'init', 'superpwa_add_rewrite_rules' );
458
- add_action( 'parse_request', 'superpwa_generate_sw_and_manifest_on_fly' );
459
- }
460
  add_action( 'plugins_loaded', 'superpwa_setup_hooks' );
1
+ <?php
2
+ /**
3
+ * Basic setup functions for the plugin
4
+ *
5
+ * @since 1.0
6
+ *
7
+ * @function superpwa_activate_plugin() Plugin activatation todo list
8
+ * @function superpwa_activation_redirect() Redirect to SuperPWA UI on plugin activation
9
+ * @function superpwa_admin_notices() Admin notices
10
+ * @function superpwa_network_admin_notices() Network Admin notices
11
+ * @function superpwa_upgrader() Plugin upgrade todo list
12
+ * @function superpwa_deactivate_plugin() Plugin deactivation todo list
13
+ * @function superpwa_load_plugin_textdomain() Load plugin text domain
14
+ * @function superpwa_settings_link() Print direct link to plugin settings in plugins list in admin
15
+ * @function superpwa_plugin_row_meta() Add donate and other links to plugins list
16
+ */
17
+
18
+ // Exit if accessed directly
19
+ if ( ! defined('ABSPATH') ) exit;
20
+
21
+ /**
22
+ * Plugin activation todo list
23
+ *
24
+ * This function runs when user activates the plugin. Used in register_activation_hook()
25
+ * On multisites, during network activation, this is fired only for the main site.
26
+ * For the rest of the sites, superpwa_upgrader() handles generation of manifest and service worker.
27
+ *
28
+ * @param $network_active (Boolean) True if the plugin is network activated, false otherwise.
29
+ *
30
+ * @author Arun Basil Lal
31
+ *
32
+ * @link https://www.alexgeorgiou.gr/network-activated-wordpress-plugins/ (Thanks Alex!)
33
+ *
34
+ * @since 1.0
35
+ * @since 1.6 register_activation_hook() moved to this file (basic-setup.php) from main plugin file (superpwa.php).
36
+ * @since 1.6 Added checks for multisite compatibility.
37
+ */
38
+ function superpwa_activate_plugin( $network_active ) {
39
+
40
+ // Not network active i.e. plugin is activated on a single install (normal WordPress install) or a single site on a multisite network
41
+ if ( ! $network_active ) {
42
+
43
+ // Set transient for single site activation notice
44
+ set_transient( 'superpwa_admin_notice_activation', true, 60 );
45
+
46
+ return;
47
+ }
48
+
49
+ // If we are here, then plugin is network activated on a multisite. Set transient for activation notice on network admin.
50
+ set_transient( 'superpwa_network_admin_notice_activation', true, 60 );
51
+ }
52
+ register_activation_hook( SUPERPWA_PATH_ABS . 'superpwa.php', 'superpwa_activate_plugin' );
53
+
54
+ /**
55
+ * Redirect to SuperPWA UI on plugin activation.
56
+ *
57
+ * Will redirect to SuperPWA settings page when plugin is activated.
58
+ * Will not redirect if multiple plugins are activated at the same time.
59
+ * Will not redirect when activated network wide on multisite. Network admins know their way.
60
+ *
61
+ * @param (string) $plugin Path to the main plugin file from plugins directory.
62
+ * @param (bool) $network_wide True when network activated on multisites. False otherwise.
63
+ *
64
+ * @author Arun Basil Lal
65
+ *
66
+ * @since 2.0
67
+ * @since 2.1 Added a check to see if WP_Plugins_List_Table class is available.
68
+ */
69
+ function superpwa_activation_redirect( $plugin, $network_wide ) {
70
+
71
+ // Return if not SuperPWA or if plugin is activated network wide.
72
+ if ( $plugin !== plugin_basename( SUPERPWA_PLUGIN_FILE ) || $network_wide === true ) {
73
+ return false;
74
+ }
75
+
76
+ if ( ! class_exists( 'WP_Plugins_List_Table' ) ) {
77
+ return false;
78
+ }
79
+
80
+ /**
81
+ * An instance of the WP_Plugins_List_Table class.
82
+ *
83
+ * @link https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-admin/plugins.php#L15
84
+ */
85
+ $wp_list_table_instance = new WP_Plugins_List_Table();
86
+ $current_action = $wp_list_table_instance->current_action();
87
+
88
+ // When only one plugin is activated, the current_action() method will return activate.
89
+ if ( $current_action !== 'activate' ) {
90
+ return false;
91
+ }
92
+
93
+ // Redirect to SuperPWA settings page.
94
+ exit( wp_redirect( admin_url( 'admin.php?page=superpwa' ) ) );
95
+ }
96
+ add_action( 'activated_plugin', 'superpwa_activation_redirect', PHP_INT_MAX, 2 );
97
+
98
+ /**
99
+ * Admin Notices
100
+ *
101
+ * @since 1.2 Admin notice on plugin activation
102
+ */
103
+ function superpwa_admin_notices() {
104
+
105
+ // Notices only for admins
106
+ if ( ! current_user_can( 'manage_options' ) ) {
107
+ return;
108
+ }
109
+
110
+ // Admin notice on plugin activation
111
+ if ( get_transient( 'superpwa_admin_notice_activation' ) ) {
112
+
113
+ $superpwa_is_ready = superpwa_is_pwa_ready() ? __( 'Your app is ready with the default settings. ', 'super-progressive-web-apps' ) : '';
114
+
115
+ // Do not display link to settings UI if we are already in the UI.
116
+ $screen = get_current_screen();
117
+ $superpwa_ui_link_text = ( strpos( $screen->id, 'superpwa' ) === false ) ? sprintf( __( '<a href="%s">Customize your app &rarr;</a>', 'super-progressive-web-apps' ), admin_url( 'admin.php?page=superpwa' ) ) : '';
118
+
119
+ echo '<div class="updated notice is-dismissible"><p>' . __( 'Thank you for installing <strong>Super Progressive Web Apps!</strong> ', 'super-progressive-web-apps' ) . $superpwa_is_ready . $superpwa_ui_link_text . '</p></div>';
120
+
121
+ // Delete transient
122
+ delete_transient( 'superpwa_admin_notice_activation' );
123
+ }
124
+
125
+ // Admin notice on plugin upgrade
126
+ if ( get_transient( 'superpwa_admin_notice_upgrade_complete' ) ) {
127
+
128
+ echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>SuperPWA</strong>: Successfully updated to version %s. Thank you! <a href="%s" target="_blank">Discover new features and read the story &rarr;</a>', 'super-progressive-web-apps' ), SUPERPWA_VERSION, 'https://superpwa.com/category/release-notes/latest/?utm_source=superpwa-plugin&utm_medium=update-success-notice' ) . '</p></div>';
129
+
130
+ // Delete transient
131
+ delete_transient( 'superpwa_admin_notice_upgrade_complete' );
132
+ }
133
+ }
134
+ add_action( 'admin_notices', 'superpwa_admin_notices' );
135
+
136
+ /**
137
+ * Network Admin notices
138
+ *
139
+ * @since 1.6 Admin notice on multisite network activation
140
+ */
141
+ function superpwa_network_admin_notices() {
142
+
143
+ // Notices only for admins
144
+ if ( ! current_user_can( 'manage_options' ) ) {
145
+ return;
146
+ }
147
+
148
+ // Network admin notice on multisite network activation
149
+ if ( get_transient( 'superpwa_network_admin_notice_activation' ) ) {
150
+
151
+ $superpwa_is_ready = superpwa_is_pwa_ready() ? 'Your app is ready on the main website with the default settings. ' : '';
152
+
153
+ echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( 'Thank you for installing <strong>Super Progressive Web Apps!</strong> '. $superpwa_is_ready .'<a href="%s">Customize your app &rarr;</a><br/>Note: manifest and service worker for the individual websites will be generated on the first visit to the respective WordPress admin.', 'super-progressive-web-apps' ), admin_url( 'admin.php?page=superpwa' ) ) . '</p></div>';
154
+
155
+ // Delete transient
156
+ delete_transient( 'superpwa_network_admin_notice_activation' );
157
+ }
158
+
159
+ // Network admin notice on plugin upgrade
160
+ if ( get_transient( 'superpwa_admin_notice_upgrade_complete' ) ) {
161
+
162
+ echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>SuperPWA</strong>: Successfully updated to version %s. Thank you! <a href="%s" target="_blank">Discover new features and read the story &rarr;</a>', 'super-progressive-web-apps' ), SUPERPWA_VERSION, 'https://superpwa.com/category/release-notes/latest/?utm_source=superpwa-plugin&utm_medium=update-success-notice-multisite' ) . '</p></div>';
163
+
164
+ // Delete transient
165
+ delete_transient( 'superpwa_admin_notice_upgrade_complete' );
166
+ }
167
+ }
168
+ add_action( 'network_admin_notices', 'superpwa_network_admin_notices' );
169
+
170
+ /**
171
+ * Plugin upgrade todo list
172
+ *
173
+ * @since 1.3.1
174
+ * @since 1.4 Added orientation setting and theme_color to database when upgrading from pre 1.4 versions.
175
+ * @since 1.6 Added multisite compatibility.
176
+ */
177
+ function superpwa_upgrader() {
178
+
179
+ $current_ver = get_option( 'superpwa_version' );
180
+
181
+ // Return if we have already done this todo
182
+ if ( version_compare( $current_ver, SUPERPWA_VERSION, '==' ) ) {
183
+ return;
184
+ }
185
+
186
+ /**
187
+ * Todo list for fresh install.
188
+ *
189
+ * On a multisite, during network activation, the activation hook (and activation todo) is not fired.
190
+ * Manifest and service worker is generated the first time the wp-admin is loaded (when admin_init is fired).
191
+ */
192
+ if ( $current_ver === false ) {
193
+
194
+ // Generate manifest
195
+ superpwa_generate_manifest();
196
+
197
+ // Generate service worker
198
+ superpwa_generate_sw();
199
+
200
+ if ( is_multisite() ) {
201
+
202
+ // For multisites, save the activation status of current blog.
203
+ superpwa_multisite_activation_status( true );
204
+ }
205
+
206
+ // Save SuperPWA version to database.
207
+ add_option( 'superpwa_version', SUPERPWA_VERSION );
208
+
209
+ return;
210
+ }
211
+
212
+ /**
213
+ * Add orientation and theme_color to database when upgrading from pre 1.4 versions.
214
+ *
215
+ * Until 1.4, there was no UI for orientation and theme_color.
216
+ * In the manifest, orientation was hard coded as 'natural'.
217
+ * background_color had UI and this value was used for both background_color and theme_color in the manifest.
218
+ *
219
+ * @since 1.4
220
+ */
221
+ if ( version_compare( $current_ver, '1.3.1', '<=' ) ) {
222
+
223
+ // Get settings
224
+ $settings = superpwa_get_settings();
225
+
226
+ // Orientation was set as 'natural' until version 1.4. Set it as 1, which is 'portrait'.
227
+ $settings['orientation'] = 1;
228
+
229
+ // theme_color was same as background_color until version 1.4
230
+ $settings['theme_color'] = $settings['background_color'];
231
+
232
+ // Write settings back to database
233
+ update_option( 'superpwa_settings', $settings );
234
+ }
235
+
236
+ /**
237
+ * Delete existing service worker for single sites that use OneSignal.
238
+ *
239
+ * For OneSignal compatibility, in version 1.8 the service worker filename is renamed.
240
+ * If OneSignal is active, by this point, the new filename will be filtered in.
241
+ * This upgrade routine restores the defaul service worker filename and deletes the existing service worker.
242
+ * Also adds back the filter for new filename. OneSignal compatibility for multisites is not available at this point.
243
+ *
244
+ * @since 1.8
245
+ */
246
+ if ( version_compare( $current_ver, '1.7.1', '<=' ) && class_exists( 'OneSignal' ) && ! is_multisite() ) {
247
+
248
+ // Restore the default service worker filename of SuperPWA.
249
+ remove_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
250
+
251
+ // Delete service worker
252
+ superpwa_delete_sw();
253
+
254
+ // Change service worker filename to match OneSignal's service worker.
255
+ add_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' );
256
+ }
257
+
258
+ /**
259
+ * Add display to database when upgrading from pre 2.0 versions.
260
+ * Delete manifest and service worker files.
261
+ *
262
+ * Until 2.0, there was no UI for display.
263
+ * In the manifest, display was hard coded as 'standalone'.
264
+ *
265
+ * Starting with 2.0, manifest and service worker files are dynamic and no longer static.
266
+ *
267
+ * @since 2.0
268
+ */
269
+ if ( version_compare( $current_ver, '1.9', '<=' ) ) {
270
+
271
+ // Get settings
272
+ $settings = superpwa_get_settings();
273
+
274
+ // Display was set as 'standalone' until version 2.0. Set it as 1, which is 'standalone'.
275
+ $settings['display'] = 1;
276
+
277
+ // Write settings back to database
278
+ update_option( 'superpwa_settings', $settings );
279
+ }
280
+
281
+ /**
282
+ * Add file state variables to database
283
+ *
284
+ * @since 2.0.1
285
+ */
286
+ if ( version_compare( $current_ver, '2.0', '<=' ) ) {
287
+
288
+ // Get settings
289
+ $settings = superpwa_get_settings();
290
+
291
+ // 1 for static files, 0 for dynamic files (default).
292
+ $settings['is_static_manifest'] = 0;
293
+ $settings['is_static_sw'] = 0;
294
+
295
+ // Write settings back to database
296
+ update_option( 'superpwa_settings', $settings );
297
+ }
298
+
299
+ // Re-generate manifest
300
+ superpwa_generate_manifest();
301
+
302
+ // Re-generate service worker
303
+ superpwa_generate_sw();
304
+
305
+ // Add current version to database
306
+ update_option( 'superpwa_version', SUPERPWA_VERSION );
307
+
308
+ // For multisites, save the activation status of current blog.
309
+ superpwa_multisite_activation_status( true );
310
+
311
+ // Set transient for upgrade complete notice
312
+ set_transient( 'superpwa_admin_notice_upgrade_complete', true, 60 );
313
+ }
314
+ add_action( 'admin_init', 'superpwa_upgrader' );
315
+
316
+ /**
317
+ * Plugin deactivation todo list
318
+ *
319
+ * Runs during deactivation.
320
+ * During uninstall uninstall.php is also executed.
321
+ *
322
+ * @param $network_active (Boolean) True if the plugin is network activated, false otherwise.
323
+ * @link https://www.alexgeorgiou.gr/network-activated-wordpress-plugins/ (Thanks Alex!)
324
+ *
325
+ * @since 1.0
326
+ * @since 1.6 register_deactivation_hook() moved to this file (basic-setup.php) from main plugin file (superpwa.php)
327
+ */
328
+ function superpwa_deactivate_plugin( $network_active ) {
329
+
330
+ // Delete manifest
331
+ superpwa_delete_manifest();
332
+
333
+ // Delete service worker
334
+ superpwa_delete_sw();
335
+
336
+ // For multisites, save the de-activation status of current blog.
337
+ superpwa_multisite_activation_status( false );
338
+
339
+ // Run the network deactivator during network deactivation
340
+ if ( $network_active === true ) {
341
+ superpwa_multisite_network_deactivator();
342
+ }
343
+ }
344
+ register_deactivation_hook( SUPERPWA_PATH_ABS . 'superpwa.php', 'superpwa_deactivate_plugin' );
345
+
346
+ /**
347
+ * Load plugin text domain
348
+ *
349
+ * @since 1.0
350
+ */
351
+ function superpwa_load_plugin_textdomain() {
352
+ load_plugin_textdomain( 'super-progressive-web-apps', false, '/super-progressive-web-apps/languages/' );
353
+ }
354
+ add_action( 'plugins_loaded', 'superpwa_load_plugin_textdomain' );
355
+
356
+ /**
357
+ * Print direct link to plugin settings in plugins list in admin
358
+ *
359
+ * @since 1.0
360
+ */
361
+ function superpwa_settings_link( $links ) {
362
+
363
+ return array_merge(
364
+ array(
365
+ 'settings' => '<a href="' . admin_url( 'admin.php?page=superpwa' ) . '">' . __( 'Settings', 'super-progressive-web-apps' ) . '</a>'
366
+ ),
367
+ $links
368
+ );
369
+ }
370
+ add_filter( 'plugin_action_links_' . plugin_basename( SUPERPWA_PLUGIN_FILE ), 'superpwa_settings_link' );
371
+
372
+ /**
373
+ * Add donate and other links to plugins list
374
+ *
375
+ * @since 1.0
376
+ */
377
+ function superpwa_plugin_row_meta( $links, $file ) {
378
+
379
+ if ( strpos( $file, 'superpwa.php' ) !== false ) {
380
+ $new_links = array(
381
+ 'demo' => '<a href="https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=plugin_row_meta" target="_blank">' . __( 'Demo', 'super-progressive-web-apps' ) . '</a>',
382
+ );
383
+ $links = array_merge( $links, $new_links );
384
+ }
385
+
386
+ return $links;
387
+ }
388
+ add_filter( 'plugin_row_meta', 'superpwa_plugin_row_meta', 10, 2 );
389
+
390
+ /**
391
+ * Adds rewrite rules to handle request to SW javascript and Manifest json.
392
+ *
393
+ * @since 2.0
394
+ *
395
+ * @uses superpwa_get_sw_filename()
396
+ * @uses superpwa_get_manifest_filename()
397
+ */
398
+ function superpwa_add_rewrite_rules() {
399
+ $sw_filename = superpwa_get_sw_filename();
400
+ add_rewrite_rule( "^/{$sw_filename}$",
401
+ "index.php?{$sw_filename}=1"
402
+ );
403
+
404
+ $manifest_filename = superpwa_get_manifest_filename();
405
+ add_rewrite_rule( "^/{$manifest_filename}$",
406
+ "index.php?{$manifest_filename}=1"
407
+ );
408
+ }
409
+
410
+ /**
411
+ * Generates SW and Manifest on the fly.
412
+ *
413
+ * This way no physical files have to be placed on WP root folder. Hallelujah!
414
+ *
415
+ * @author Maria Daniel Deepak <daniel@danieldeepak.com>
416
+ *
417
+ * @uses superpwa_get_sw_filename()
418
+ * @uses superpwa_get_manifest_filename()
419
+ * @uses superpwa_manifest_template()
420
+ * @uses superpwa_sw_template()
421
+ *
422
+ * @since 2.0
423
+ * @since 2.1 uses http_build_query() instead of implode() to convert query_vars to string.
424
+ */
425
+ function superpwa_generate_sw_and_manifest_on_fly( $query ) {
426
+ if ( ! property_exists( $query, 'query_vars' ) || ! is_array( $query->query_vars ) ) {
427
+ return;
428
+ }
429
+ $query_vars_as_string = http_build_query( $query->query_vars );
430
+ $manifest_filename = superpwa_get_manifest_filename();
431
+ $sw_filename = superpwa_get_sw_filename();
432
+
433
+ if ( strpos( $query_vars_as_string, $manifest_filename ) !== false ) {
434
+ // Generate manifest from Settings and send the response w/ header.
435
+ header( 'Content-Type: application/json' );
436
+ echo json_encode( superpwa_manifest_template() );
437
+ exit();
438
+ }
439
+ if ( strpos( $query_vars_as_string, $sw_filename ) !== false ) {
440
+ header( 'Content-Type: text/javascript' );
441
+ echo superpwa_sw_template();
442
+ exit();
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Sets up the hooks once.
448
+ *
449
+ * Possibly put in the same order as execution for better understanding.
450
+ *
451
+ * @link https://codex.wordpress.org/Plugin_API/Action_Reference Actions run during a typical Request.
452
+ * @link https://codex.wordpress.org/Plugin_API/Action_Reference/plugins_loaded
453
+ *
454
+ * @since 2.0
455
+ */
456
+ function superpwa_setup_hooks() {
457
+ add_action( 'init', 'superpwa_add_rewrite_rules' );
458
+ add_action( 'parse_request', 'superpwa_generate_sw_and_manifest_on_fly' );
459
+ }
460
  add_action( 'plugins_loaded', 'superpwa_setup_hooks' );
admin/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
admin/js/main.js CHANGED
@@ -1,42 +1,42 @@
1
- jQuery(document).ready(function($){
2
- $('.superpwa-colorpicker').wpColorPicker(); // Color picker
3
- $('.superpwa-icon-upload').click(function(e) { // Application Icon upload
4
- e.preventDefault();
5
- var superpwa_meda_uploader = wp.media({
6
- title: 'Application Icon',
7
- button: {
8
- text: 'Select Icon'
9
- },
10
- multiple: false // Set this to true to allow multiple files to be selected
11
- })
12
- .on('select', function() {
13
- var attachment = superpwa_meda_uploader.state().get('selection').first().toJSON();
14
- $('.superpwa-icon').val(attachment.url);
15
- })
16
- .open();
17
- });
18
- $('.superpwa-splash-icon-upload').click(function(e) { // Splash Screen Icon upload
19
- e.preventDefault();
20
- var superpwa_meda_uploader = wp.media({
21
- title: 'Splash Screen Icon',
22
- button: {
23
- text: 'Select Icon'
24
- },
25
- multiple: false // Set this to true to allow multiple files to be selected
26
- })
27
- .on('select', function() {
28
- var attachment = superpwa_meda_uploader.state().get('selection').first().toJSON();
29
- $('.superpwa-splash-icon').val(attachment.url);
30
- })
31
- .open();
32
- });
33
- $('.superpwa-app-short-name').on('input', function(e) { // Warn when app_short_name exceeds 12 characters.
34
- if ( $('.superpwa-app-short-name').val().length > 12 ) {
35
- $('.superpwa-app-short-name').css({'color': '#dc3232'});
36
- $('#superpwa-app-short-name-limit').css({'color': '#dc3232'});
37
- } else {
38
- $('.superpwa-app-short-name').css({'color': 'inherit'});
39
- $('#superpwa-app-short-name-limit').css({'color': 'inherit'});
40
- }
41
- });
42
  });
1
+ jQuery(document).ready(function($){
2
+ $('.superpwa-colorpicker').wpColorPicker(); // Color picker
3
+ $('.superpwa-icon-upload').click(function(e) { // Application Icon upload
4
+ e.preventDefault();
5
+ var superpwa_meda_uploader = wp.media({
6
+ title: 'Application Icon',
7
+ button: {
8
+ text: 'Select Icon'
9
+ },
10
+ multiple: false // Set this to true to allow multiple files to be selected
11
+ })
12
+ .on('select', function() {
13
+ var attachment = superpwa_meda_uploader.state().get('selection').first().toJSON();
14
+ $('.superpwa-icon').val(attachment.url);
15
+ })
16
+ .open();
17
+ });
18
+ $('.superpwa-splash-icon-upload').click(function(e) { // Splash Screen Icon upload
19
+ e.preventDefault();
20
+ var superpwa_meda_uploader = wp.media({
21
+ title: 'Splash Screen Icon',
22
+ button: {
23
+ text: 'Select Icon'
24
+ },
25
+ multiple: false // Set this to true to allow multiple files to be selected
26
+ })
27
+ .on('select', function() {
28
+ var attachment = superpwa_meda_uploader.state().get('selection').first().toJSON();
29
+ $('.superpwa-splash-icon').val(attachment.url);
30
+ })
31
+ .open();
32
+ });
33
+ $('.superpwa-app-short-name').on('input', function(e) { // Warn when app_short_name exceeds 12 characters.
34
+ if ( $('.superpwa-app-short-name').val().length > 12 ) {
35
+ $('.superpwa-app-short-name').css({'color': '#dc3232'});
36
+ $('#superpwa-app-short-name-limit').css({'color': '#dc3232'});
37
+ } else {
38
+ $('.superpwa-app-short-name').css({'color': 'inherit'});
39
+ $('#superpwa-app-short-name-limit').css({'color': 'inherit'});
40
+ }
41
+ });
42
  });
composer.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "name": "superpwa/super-progressive-web-apps",
3
- "description": "Super Progressive Web Apps WordPress plugin",
4
- "type": "wordpress-plugin",
5
- "license": "GPL-2.0-or-later",
6
- "authors": [
7
- {
8
- "name": "Arun Basil Lal",
9
- "email": "arun@superpwa.com"
10
- },
11
- {
12
- "name": "Jose Varghese",
13
- "email": "jose@superpwa.com"
14
- },
15
- {
16
- "name": "Maria Daniel Deepak",
17
- "email": "daniel@danieldeepak.com"
18
- }
19
- ],
20
- "minimum-stability": "stable",
21
- "require": {},
22
- "require-dev": {
23
- "squizlabs/php_codesniffer": "^3.3",
24
- "wp-coding-standards/wpcs": "^1.2",
25
- "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0"
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
composer.lock DELETED
@@ -1,178 +0,0 @@
1
- {
2
- "_readme": [
3
- "This file locks the dependencies of your project to a known state",
4
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
- "This file is @generated automatically"
6
- ],
7
- "content-hash": "79c1036666580515751ce8911524cb95",
8
- "packages": [],
9
- "packages-dev": [
10
- {
11
- "name": "dealerdirect/phpcodesniffer-composer-installer",
12
- "version": "v0.5.0",
13
- "source": {
14
- "type": "git",
15
- "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
16
- "reference": "e749410375ff6fb7a040a68878c656c2e610b132"
17
- },
18
- "dist": {
19
- "type": "zip",
20
- "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132",
21
- "reference": "e749410375ff6fb7a040a68878c656c2e610b132",
22
- "shasum": ""
23
- },
24
- "require": {
25
- "composer-plugin-api": "^1.0",
26
- "php": "^5.3|^7",
27
- "squizlabs/php_codesniffer": "^2|^3"
28
- },
29
- "require-dev": {
30
- "composer/composer": "*",
31
- "phpcompatibility/php-compatibility": "^9.0",
32
- "sensiolabs/security-checker": "^4.1.0"
33
- },
34
- "type": "composer-plugin",
35
- "extra": {
36
- "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
37
- },
38
- "autoload": {
39
- "psr-4": {
40
- "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
41
- }
42
- },
43
- "notification-url": "https://packagist.org/downloads/",
44
- "license": [
45
- "MIT"
46
- ],
47
- "authors": [
48
- {
49
- "name": "Franck Nijhof",
50
- "email": "franck.nijhof@dealerdirect.com",
51
- "homepage": "http://www.frenck.nl",
52
- "role": "Developer / IT Manager"
53
- }
54
- ],
55
- "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
56
- "homepage": "http://www.dealerdirect.com",
57
- "keywords": [
58
- "PHPCodeSniffer",
59
- "PHP_CodeSniffer",
60
- "code quality",
61
- "codesniffer",
62
- "composer",
63
- "installer",
64
- "phpcs",
65
- "plugin",
66
- "qa",
67
- "quality",
68
- "standard",
69
- "standards",
70
- "style guide",
71
- "stylecheck",
72
- "tests"
73
- ],
74
- "time": "2018-10-26T13:21:45+00:00"
75
- },
76
- {
77
- "name": "squizlabs/php_codesniffer",
78
- "version": "3.3.2",
79
- "source": {
80
- "type": "git",
81
- "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
82
- "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e"
83
- },
84
- "dist": {
85
- "type": "zip",
86
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e",
87
- "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e",
88
- "shasum": ""
89
- },
90
- "require": {
91
- "ext-simplexml": "*",
92
- "ext-tokenizer": "*",
93
- "ext-xmlwriter": "*",
94
- "php": ">=5.4.0"
95
- },
96
- "require-dev": {
97
- "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
98
- },
99
- "bin": [
100
- "bin/phpcs",
101
- "bin/phpcbf"
102
- ],
103
- "type": "library",
104
- "extra": {
105
- "branch-alias": {
106
- "dev-master": "3.x-dev"
107
- }
108
- },
109
- "notification-url": "https://packagist.org/downloads/",
110
- "license": [
111
- "BSD-3-Clause"
112
- ],
113
- "authors": [
114
- {
115
- "name": "Greg Sherwood",
116
- "role": "lead"
117
- }
118
- ],
119
- "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
120
- "homepage": "http://www.squizlabs.com/php-codesniffer",
121
- "keywords": [
122
- "phpcs",
123
- "standards"
124
- ],
125
- "time": "2018-09-23T23:08:17+00:00"
126
- },
127
- {
128
- "name": "wp-coding-standards/wpcs",
129
- "version": "1.2.0",
130
- "source": {
131
- "type": "git",
132
- "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
133
- "reference": "7aa217ab38156c5cb4eae0f04ae376027c407a9b"
134
- },
135
- "dist": {
136
- "type": "zip",
137
- "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/7aa217ab38156c5cb4eae0f04ae376027c407a9b",
138
- "reference": "7aa217ab38156c5cb4eae0f04ae376027c407a9b",
139
- "shasum": ""
140
- },
141
- "require": {
142
- "php": ">=5.3",
143
- "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2"
144
- },
145
- "require-dev": {
146
- "phpcompatibility/php-compatibility": "^9.0"
147
- },
148
- "suggest": {
149
- "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
150
- },
151
- "type": "phpcodesniffer-standard",
152
- "notification-url": "https://packagist.org/downloads/",
153
- "license": [
154
- "MIT"
155
- ],
156
- "authors": [
157
- {
158
- "name": "Contributors",
159
- "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors"
160
- }
161
- ],
162
- "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
163
- "keywords": [
164
- "phpcs",
165
- "standards",
166
- "wordpress"
167
- ],
168
- "time": "2018-11-12T10:13:12+00:00"
169
- }
170
- ],
171
- "aliases": [],
172
- "minimum-stability": "stable",
173
- "stability-flags": [],
174
- "prefer-stable": false,
175
- "prefer-lowest": false,
176
- "platform": [],
177
- "platform-dev": []
178
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/common.php CHANGED
@@ -1,243 +1,243 @@
1
- <?php
2
- /**
3
- * Operations and common functions of SuperPWA
4
- *
5
- * @since 1.0
6
- *
7
- * @function superpwa_is_amp() Check if any AMP plugin is installed
8
- * @function superpwa_get_start_url() Return Start Page URL
9
- * @function superpwa_httpsify() Convert http URL to https
10
- * @function superpwa_is_pwa_ready() Check if PWA is ready
11
- * @function superpwa_file_exists() Check if file exists
12
- * @function superpwa_is_static() Check if service worker or manifest is static or dynamic
13
- * @function superpwa_get_bloginfo() Returns WordPress URL v/s Site URL depending on the status of the file.
14
- */
15
-
16
- // Exit if accessed directly
17
- if ( ! defined( 'ABSPATH' ) ) exit;
18
-
19
- /**
20
- * Check if any AMP plugin is installed
21
- *
22
- * @return (string|bool) AMP page url on success, false otherwise
23
- *
24
- * @author Arun Basil Lal
25
- * @author Maria Daniel Deepak <daniel@danieldeepak.com>
26
- *
27
- * @since 1.2
28
- * @since 1.9 Added support for tagDiv AMP
29
- * @since 2.0 require wp-admin/includes/plugin.php if is_plugin_active isn't defined
30
- */
31
- function superpwa_is_amp() {
32
-
33
- if ( ! function_exists( 'is_plugin_active' ) ) {
34
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
35
- }
36
-
37
- // AMP for WordPress - https://wordpress.org/plugins/amp
38
- if ( is_plugin_active( 'amp/amp.php' ) ) {
39
- return defined( 'AMP_QUERY_VAR' ) ? AMP_QUERY_VAR . '/' : 'amp/';
40
- }
41
-
42
- // AMP for WP - https://wordpress.org/plugins/accelerated-mobile-pages/
43
- if ( is_plugin_active( 'accelerated-mobile-pages/accelerated-moblie-pages.php' ) ) {
44
- return defined( 'AMPFORWP_AMP_QUERY_VAR' ) ? AMPFORWP_AMP_QUERY_VAR . '/' : 'amp/';
45
- }
46
-
47
- // Better AMP - https://wordpress.org/plugins/better-amp/
48
- if ( is_plugin_active( 'better-amp/better-amp.php' ) ) {
49
- return 'amp/';
50
- }
51
-
52
- // AMP Supremacy - https://wordpress.org/plugins/amp-supremacy/
53
- if ( is_plugin_active( 'amp-supremacy/amp-supremacy.php' ) ) {
54
- return 'amp/';
55
- }
56
-
57
- // WP AMP - https://wordpress.org/plugins/wp-amp-ninja/
58
- if ( is_plugin_active( 'wp-amp-ninja/wp-amp-ninja.php' ) ) {
59
- return '?wpamp';
60
- }
61
-
62
- // tagDiv AMP - http://forum.tagdiv.com/tagdiv-amp/
63
- if ( is_plugin_active( 'td-amp/td-amp.php' ) ) {
64
- return defined( 'AMP_QUERY_VAR' ) ? AMP_QUERY_VAR . '/' : 'amp/';
65
- }
66
-
67
- return false;
68
- }
69
-
70
- /**
71
- * Return Start Page URL
72
- *
73
- * @param $rel (boolean) False by default. Set to true to return a relative URL (for use in manifest)
74
- *
75
- * @return (string) URL to be set as the start_url in manifest and startPage in service worker
76
- *
77
- * @since 1.2
78
- * @since 1.3.1 Force HTTPS by replacing http:// with https://
79
- * @since 1.6 Use superpwa_httpsify() to force HTTPS.
80
- * @since 1.6 Removed forcing of trailing slash and added dot (.) to the beginning.
81
- * @since 1.7 Added filter superpwa_manifest_start_url when $rel = true, for use with manifest. First ever filter in SuperPWA.
82
- */
83
- function superpwa_get_start_url( $rel = false ) {
84
-
85
- // Get Settings
86
- $settings = superpwa_get_settings();
87
-
88
- // Start Page
89
- $start_url = get_permalink( $settings['start_url'] ) ? get_permalink( $settings['start_url'] ) : superpwa_get_bloginfo( 'sw' );
90
-
91
- // Force HTTPS
92
- $start_url = superpwa_httpsify( $start_url );
93
-
94
- // AMP URL
95
- if ( superpwa_is_amp() !== false && isset( $settings['start_url_amp'] ) && $settings['start_url_amp'] == 1 ) {
96
- $start_url = trailingslashit( $start_url ) . superpwa_is_amp();
97
- }
98
-
99
- // Relative URL for manifest
100
- if ( $rel === true ) {
101
-
102
- // Make start_url relative for manifest
103
- $start_url = ( parse_url( $start_url, PHP_URL_PATH ) == '' ) ? '.' : parse_url( $start_url, PHP_URL_PATH );
104
-
105
- return apply_filters( 'superpwa_manifest_start_url', $start_url );
106
- }
107
-
108
- return $start_url;
109
- }
110
-
111
- /**
112
- * Convert http URL to https
113
- *
114
- * @param $url (string) The URL to convert to https
115
- *
116
- * @return (string) Returns the converted URL
117
- *
118
- * @since 1.6
119
- */
120
- function superpwa_httpsify( $url ) {
121
- return str_replace( 'http://', 'https://', $url );
122
- }
123
-
124
- /**
125
- * Check if PWA is ready
126
- *
127
- * Check for HTTPS.
128
- * Check if manifest is generated.
129
- * Check if service worker is generated.
130
- *
131
- * @return (bool) True if PWA is ready. False otherwise
132
- *
133
- * @author Arun Basil Lal
134
- *
135
- * @since 1.8.1
136
- * @since 2.0.1 replaced superpwa_get_contents() with superpwa_file_exists() to accommodate dynamic files.
137
- */
138
- function superpwa_is_pwa_ready() {
139
-
140
- if (
141
- is_ssl() &&
142
- superpwa_file_exists( superpwa_manifest( 'src' ) ) &&
143
- superpwa_file_exists( superpwa_sw( 'src' ) )
144
- ) {
145
- return apply_filters( 'superpwa_is_pwa_ready', true );
146
- }
147
-
148
- return false;
149
- }
150
-
151
- /**
152
- * Check if file exists
153
- *
154
- * Not to be confused with file_exists PHP function.
155
- * In SuperPWA context, file exists if the response code is 200.
156
- *
157
- * @param $file (string) URL to check
158
- *
159
- * @return (bool) True, if file exists. False otherwise.
160
- *
161
- * @author Arun Basil Lal
162
- * @author Maria Daniel Deepak <daniel@danieldeepak.com>
163
- *
164
- * @since 2.0.1
165
- */
166
- function superpwa_file_exists( $file ) {
167
-
168
- $response = wp_remote_head( $file, array( 'sslverify' => false ) );
169
- $response_code = wp_remote_retrieve_response_code( $response );
170
-
171
- if ( 200 === $response_code ) {
172
- return true;
173
- }
174
-
175
- return false;
176
- }
177
-
178
- /**
179
- * Check if service worker or manifest is static or dynamic
180
- *
181
- * @param (string) $file keyword 'manifest' to test manifest and 'sw' to test service worker.
182
- *
183
- * @return (bool) True if the file is static. False otherwise.
184
- *
185
- * @author Arun Basil Lal
186
- *
187
- * @since 2.0.1
188
- */
189
- function superpwa_is_static( $file = 'manifest' ) {
190
-
191
- // Get Settings
192
- $settings = superpwa_get_settings();
193
-
194
- switch ( $file ) {
195
-
196
- case 'sw':
197
-
198
- if ( $settings['is_static_sw'] === 1 ) {
199
- return true;
200
- }
201
-
202
- return false;
203
- break;
204
-
205
- case 'manifest':
206
- default:
207
-
208
- if ( $settings['is_static_manifest'] === 1 ) {
209
- return true;
210
- }
211
-
212
- return false;
213
- break;
214
- }
215
- }
216
-
217
- /**
218
- * Returns WordPress URL v/s Site URL depending on the status of the file.
219
- *
220
- * Static files are generated in the root directory of WordPress. So if static
221
- * files are used, the WordPress URL will be needed for many use cases, like
222
- * offline page, start_url etc.
223
- *
224
- * The status of the service worker is mostly relevant since the service worker
225
- * can work on the folder it is located and its sub folders. Not the folders above
226
- * its own directory.
227
- *
228
- * @param (string) $file keyword 'manifest' to test manifest and 'sw' to test service worker.
229
- *
230
- * @return (string) get_bloginfo( 'wpurl' ) if file is static. get_bloginfo( 'url' ) otherwise.
231
- *
232
- * @author Arun Basil Lal
233
- *
234
- * @since 2.0.1
235
- */
236
- function superpwa_get_bloginfo( $file = 'sw' ) {
237
-
238
- if ( superpwa_is_static( $file ) ) {
239
- return get_bloginfo( 'wpurl' );
240
- }
241
-
242
- return get_bloginfo( 'url' );
243
  }
1
+ <?php
2
+ /**
3
+ * Operations and common functions of SuperPWA
4
+ *
5
+ * @since 1.0
6
+ *
7
+ * @function superpwa_is_amp() Check if any AMP plugin is installed
8
+ * @function superpwa_get_start_url() Return Start Page URL
9
+ * @function superpwa_httpsify() Convert http URL to https
10
+ * @function superpwa_is_pwa_ready() Check if PWA is ready
11
+ * @function superpwa_file_exists() Check if file exists
12
+ * @function superpwa_is_static() Check if service worker or manifest is static or dynamic
13
+ * @function superpwa_get_bloginfo() Returns WordPress URL v/s Site URL depending on the status of the file.
14
+ */
15
+
16
+ // Exit if accessed directly
17
+ if ( ! defined( 'ABSPATH' ) ) exit;
18
+
19
+ /**
20
+ * Check if any AMP plugin is installed
21
+ *
22
+ * @return (string|bool) AMP page url on success, false otherwise
23
+ *
24
+ * @author Arun Basil Lal
25
+ * @author Maria Daniel Deepak <daniel@danieldeepak.com>
26
+ *
27
+ * @since 1.2
28
+ * @since 1.9 Added support for tagDiv AMP
29
+ * @since 2.0 require wp-admin/includes/plugin.php if is_plugin_active isn't defined
30
+ */
31
+ function superpwa_is_amp() {
32
+
33
+ if ( ! function_exists( 'is_plugin_active' ) ) {
34
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
35
+ }
36
+
37
+ // AMP for WordPress - https://wordpress.org/plugins/amp
38
+ if ( is_plugin_active( 'amp/amp.php' ) ) {
39
+ return defined( 'AMP_QUERY_VAR' ) ? AMP_QUERY_VAR . '/' : 'amp/';
40
+ }
41
+
42
+ // AMP for WP - https://wordpress.org/plugins/accelerated-mobile-pages/
43
+ if ( is_plugin_active( 'accelerated-mobile-pages/accelerated-moblie-pages.php' ) ) {
44
+ return defined( 'AMPFORWP_AMP_QUERY_VAR' ) ? AMPFORWP_AMP_QUERY_VAR . '/' : 'amp/';
45
+ }
46
+
47
+ // Better AMP - https://wordpress.org/plugins/better-amp/
48
+ if ( is_plugin_active( 'better-amp/better-amp.php' ) ) {
49
+ return 'amp/';
50
+ }
51
+
52
+ // AMP Supremacy - https://wordpress.org/plugins/amp-supremacy/
53
+ if ( is_plugin_active( 'amp-supremacy/amp-supremacy.php' ) ) {
54
+ return 'amp/';
55
+ }
56
+
57
+ // WP AMP - https://wordpress.org/plugins/wp-amp-ninja/
58
+ if ( is_plugin_active( 'wp-amp-ninja/wp-amp-ninja.php' ) ) {
59
+ return '?wpamp';
60
+ }
61
+
62
+ // tagDiv AMP - http://forum.tagdiv.com/tagdiv-amp/
63
+ if ( is_plugin_active( 'td-amp/td-amp.php' ) ) {
64
+ return defined( 'AMP_QUERY_VAR' ) ? AMP_QUERY_VAR . '/' : 'amp/';
65
+ }
66
+
67
+ return false;
68
+ }
69
+
70
+ /**
71
+ * Return Start Page URL
72
+ *
73
+ * @param $rel (boolean) False by default. Set to true to return a relative URL (for use in manifest)
74
+ *
75
+ * @return (string) URL to be set as the start_url in manifest and startPage in service worker
76
+ *
77
+ * @since 1.2
78
+ * @since 1.3.1 Force HTTPS by replacing http:// with https://
79
+ * @since 1.6 Use superpwa_httpsify() to force HTTPS.
80
+ * @since 1.6 Removed forcing of trailing slash and added dot (.) to the beginning.
81
+ * @since 1.7 Added filter superpwa_manifest_start_url when $rel = true, for use with manifest. First ever filter in SuperPWA.
82
+ */
83
+ function superpwa_get_start_url( $rel = false ) {
84
+
85
+ // Get Settings
86
+ $settings = superpwa_get_settings();
87
+
88
+ // Start Page
89
+ $start_url = get_permalink( $settings['start_url'] ) ? get_permalink( $settings['start_url'] ) : superpwa_get_bloginfo( 'sw' );
90
+
91
+ // Force HTTPS
92
+ $start_url = superpwa_httpsify( $start_url );
93
+
94
+ // AMP URL
95
+ if ( superpwa_is_amp() !== false && isset( $settings['start_url_amp'] ) && $settings['start_url_amp'] == 1 ) {
96
+ $start_url = trailingslashit( $start_url ) . superpwa_is_amp();
97
+ }
98
+
99
+ // Relative URL for manifest
100
+ if ( $rel === true ) {
101
+
102
+ // Make start_url relative for manifest
103
+ $start_url = ( parse_url( $start_url, PHP_URL_PATH ) == '' ) ? '.' : parse_url( $start_url, PHP_URL_PATH );
104
+
105
+ return apply_filters( 'superpwa_manifest_start_url', $start_url );
106
+ }
107
+
108
+ return $start_url;
109
+ }
110
+
111
+ /**
112
+ * Convert http URL to https
113
+ *
114
+ * @param $url (string) The URL to convert to https
115
+ *
116
+ * @return (string) Returns the converted URL
117
+ *
118
+ * @since 1.6
119
+ */
120
+ function superpwa_httpsify( $url ) {
121
+ return str_replace( 'http://', 'https://', $url );
122
+ }
123
+
124
+ /**
125
+ * Check if PWA is ready
126
+ *
127
+ * Check for HTTPS.
128
+ * Check if manifest is generated.
129
+ * Check if service worker is generated.
130
+ *
131
+ * @return (bool) True if PWA is ready. False otherwise
132
+ *
133
+ * @author Arun Basil Lal
134
+ *
135
+ * @since 1.8.1
136
+ * @since 2.0.1 replaced superpwa_get_contents() with superpwa_file_exists() to accommodate dynamic files.
137
+ */
138
+ function superpwa_is_pwa_ready() {
139
+
140
+ if (
141
+ is_ssl() &&
142
+ superpwa_file_exists( superpwa_manifest( 'src' ) ) &&
143
+ superpwa_file_exists( superpwa_sw( 'src' ) )
144
+ ) {
145
+ return apply_filters( 'superpwa_is_pwa_ready', true );
146
+ }
147
+
148
+ return false;
149
+ }
150
+
151
+ /**
152
+ * Check if file exists
153
+ *
154
+ * Not to be confused with file_exists PHP function.
155
+ * In SuperPWA context, file exists if the response code is 200.
156
+ *
157
+ * @param $file (string) URL to check
158
+ *
159
+ * @return (bool) True, if file exists. False otherwise.
160
+ *
161
+ * @author Arun Basil Lal
162
+ * @author Maria Daniel Deepak <daniel@danieldeepak.com>
163
+ *
164
+ * @since 2.0.1
165
+ */
166
+ function superpwa_file_exists( $file ) {
167
+
168
+ $response = wp_remote_head( $file, array( 'sslverify' => false ) );
169
+ $response_code = wp_remote_retrieve_response_code( $response );
170
+
171
+ if ( 200 === $response_code ) {
172
+ return true;
173
+ }
174
+
175
+ return false;
176
+ }
177
+
178
+ /**
179
+ * Check if service worker or manifest is static or dynamic
180
+ *
181
+ * @param (string) $file keyword 'manifest' to test manifest and 'sw' to test service worker.
182
+ *
183
+ * @return (bool) True if the file is static. False otherwise.
184
+ *
185
+ * @author Arun Basil Lal
186
+ *
187
+ * @since 2.0.1
188
+ */
189
+ function superpwa_is_static( $file = 'manifest' ) {
190
+
191
+ // Get Settings
192
+ $settings = superpwa_get_settings();
193
+
194
+ switch ( $file ) {
195
+
196
+ case 'sw':
197
+
198
+ if ( $settings['is_static_sw'] === 1 ) {
199
+ return true;
200
+ }
201
+
202
+ return false;
203
+ break;
204
+
205
+ case 'manifest':
206
+ default:
207
+
208
+ if ( $settings['is_static_manifest'] === 1 ) {
209
+ return true;
210
+ }
211
+
212
+ return false;
213
+ break;
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Returns WordPress URL v/s Site URL depending on the status of the file.
219
+ *
220
+ * Static files are generated in the root directory of WordPress. So if static
221
+ * files are used, the WordPress URL will be needed for many use cases, like
222
+ * offline page, start_url etc.
223
+ *
224
+ * The status of the service worker is mostly relevant since the service worker
225
+ * can work on the folder it is located and its sub folders. Not the folders above
226
+ * its own directory.
227
+ *
228
+ * @param (string) $file keyword 'manifest' to test manifest and 'sw' to test service worker.
229
+ *
230
+ * @return (string) get_bloginfo( 'wpurl' ) if file is static. get_bloginfo( 'url' ) otherwise.
231
+ *
232
+ * @author Arun Basil Lal
233
+ *
234
+ * @since 2.0.1
235
+ */
236
+ function superpwa_get_bloginfo( $file = 'sw' ) {
237
+
238
+ if ( superpwa_is_static( $file ) ) {
239
+ return get_bloginfo( 'wpurl' );
240
+ }
241
+
242
+ return get_bloginfo( 'url' );
243
  }
functions/filesystem.php CHANGED
@@ -1,107 +1,107 @@
1
- <?php
2
- /**
3
- * Filesystem Operations
4
- *
5
- * @since 1.0
6
- *
7
- * @function superpwa_wp_filesystem_init() Initialize the WP filesystem
8
- * @function superpwa_put_contents() Write to a file using WP_Filesystem() functions
9
- * @function superpwa_get_contents() Read contents of a file using WP_Filesystem() functions
10
- * @function superpwa_delete() Delete a file
11
- */
12
-
13
- // Exit if accessed directly
14
- if ( ! defined('ABSPATH') ) exit;
15
-
16
- /**
17
- * Initialize the WP filesystem
18
- *
19
- * @since 1.0
20
- */
21
- function superpwa_wp_filesystem_init() {
22
-
23
- global $wp_filesystem;
24
-
25
- if ( empty( $wp_filesystem ) ) {
26
- require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/file.php' );
27
- WP_Filesystem();
28
- }
29
- }
30
-
31
- /**
32
- * Write to a file using WP_Filesystem() functions
33
- *
34
- * @param $file Filename with path
35
- * @param $content Contents to be written to the file. Default null
36
- * @return True on success, false if file isn't passed or if writing failed.
37
- *
38
- * @since 1.0
39
- */
40
- function superpwa_put_contents( $file, $content = null ) {
41
-
42
- // Return false if no filename is provided
43
- if ( empty( $file ) ) {
44
- return false;
45
- }
46
-
47
- // Initialize the WP filesystem
48
- superpwa_wp_filesystem_init();
49
- global $wp_filesystem;
50
-
51
- if( ! $wp_filesystem->put_contents( $file, $content, 0644) ) {
52
- return false;
53
- }
54
-
55
- return true;
56
- }
57
-
58
- /**
59
- * Read contents of a file using WP_Filesystem() functions
60
- *
61
- * @param $file Filename with path.
62
- * @param $array Set true to return read data as an array. False by default.
63
- * @return (string|bool) The function returns the read data or false on failure.
64
- *
65
- * @since 1.0
66
- */
67
- function superpwa_get_contents( $file, $array = false ) {
68
-
69
- // Return false if no filename is provided
70
- if ( empty( $file ) ) {
71
- return false;
72
- }
73
-
74
- // Initialize the WP filesystem
75
- superpwa_wp_filesystem_init();
76
- global $wp_filesystem;
77
-
78
- // Reads entire file into a string
79
- if ( $array == false ) {
80
- return $wp_filesystem->get_contents( $file );
81
- }
82
-
83
- // Reads entire file into an array
84
- return $wp_filesystem->get_contents_array( $file );
85
- }
86
-
87
- /**
88
- * Delete a file
89
- *
90
- * @param $file Filename with path
91
- * @return bool True on success, false otherwise
92
- *
93
- * @since 1.0
94
- */
95
- function superpwa_delete( $file ) {
96
-
97
- // Return false if no filename is provided
98
- if ( empty( $file ) ) {
99
- return false;
100
- }
101
-
102
- // Initialize the WP filesystem
103
- superpwa_wp_filesystem_init();
104
- global $wp_filesystem;
105
-
106
- return $wp_filesystem->delete( $file );
107
  }
1
+ <?php
2
+ /**
3
+ * Filesystem Operations
4
+ *
5
+ * @since 1.0
6
+ *
7
+ * @function superpwa_wp_filesystem_init() Initialize the WP filesystem
8
+ * @function superpwa_put_contents() Write to a file using WP_Filesystem() functions
9
+ * @function superpwa_get_contents() Read contents of a file using WP_Filesystem() functions
10
+ * @function superpwa_delete() Delete a file
11
+ */
12
+
13
+ // Exit if accessed directly
14
+ if ( ! defined('ABSPATH') ) exit;
15
+
16
+ /**
17
+ * Initialize the WP filesystem
18
+ *
19
+ * @since 1.0
20
+ */
21
+ function superpwa_wp_filesystem_init() {
22
+
23
+ global $wp_filesystem;
24
+
25
+ if ( empty( $wp_filesystem ) ) {
26
+ require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/file.php' );
27
+ WP_Filesystem();
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Write to a file using WP_Filesystem() functions
33
+ *
34
+ * @param $file Filename with path
35
+ * @param $content Contents to be written to the file. Default null
36
+ * @return True on success, false if file isn't passed or if writing failed.
37
+ *
38
+ * @since 1.0
39
+ */
40
+ function superpwa_put_contents( $file, $content = null ) {
41
+
42
+ // Return false if no filename is provided
43
+ if ( empty( $file ) ) {
44
+ return false;
45
+ }
46
+
47
+ // Initialize the WP filesystem
48
+ superpwa_wp_filesystem_init();
49
+ global $wp_filesystem;
50
+
51
+ if( ! $wp_filesystem->put_contents( $file, $content, 0644) ) {
52
+ return false;
53
+ }
54
+
55
+ return true;
56
+ }
57
+
58
+ /**
59
+ * Read contents of a file using WP_Filesystem() functions
60
+ *
61
+ * @param $file Filename with path.
62
+ * @param $array Set true to return read data as an array. False by default.
63
+ * @return (string|bool) The function returns the read data or false on failure.
64
+ *
65
+ * @since 1.0
66
+ */
67
+ function superpwa_get_contents( $file, $array = false ) {
68
+
69
+ // Return false if no filename is provided
70
+ if ( empty( $file ) ) {
71
+ return false;
72
+ }
73
+
74
+ // Initialize the WP filesystem
75
+ superpwa_wp_filesystem_init();
76
+ global $wp_filesystem;
77
+
78
+ // Reads entire file into a string
79
+ if ( $array == false ) {
80
+ return $wp_filesystem->get_contents( $file );
81
+ }
82
+
83
+ // Reads entire file into an array
84
+ return $wp_filesystem->get_contents_array( $file );
85
+ }
86
+
87
+ /**
88
+ * Delete a file
89
+ *
90
+ * @param $file Filename with path
91
+ * @return bool True on success, false otherwise
92
+ *
93
+ * @since 1.0
94
+ */
95
+ function superpwa_delete( $file ) {
96
+
97
+ // Return false if no filename is provided
98
+ if ( empty( $file ) ) {
99
+ return false;
100
+ }
101
+
102
+ // Initialize the WP filesystem
103
+ superpwa_wp_filesystem_init();
104
+ global $wp_filesystem;
105
+
106
+ return $wp_filesystem->delete( $file );
107
  }
functions/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
functions/multisite.php CHANGED
@@ -1,106 +1,106 @@
1
- <?php
2
- /**
3
- * Functions for compatibility with WordPress multisites
4
- *
5
- * @since 1.6
6
- *
7
- * @function superpwa_multisite_filename_postfix() Filename postfix for multisites
8
- * @function superpwa_multisite_activation_status() Save activation status for current blog id
9
- * @function superpwa_multisite_network_deactivator() Handle multisite network deactivation
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) exit;
14
-
15
- /**
16
- * Filename postfix for multisites
17
- *
18
- * @return (string) Returns the current blog ID on a multisite. An empty string otherwise
19
- *
20
- * @since 1.6
21
- */
22
- function superpwa_multisite_filename_postfix() {
23
-
24
- // Return empty string if not a multisite
25
- if ( ! is_multisite() ) {
26
- return '';
27
- }
28
-
29
- return '-' . get_current_blog_id();
30
- }
31
-
32
- /**
33
- * Save activation status for current blog id
34
- *
35
- * For clean multisite uninstall.
36
- * Manifest and service worker are deleted during deactivation.
37
- * Database settings are cleaned during uninstall
38
- *
39
- * @param (bool) $status True when plugin is activated, false when deactivated.
40
- *
41
- * @since 1.6
42
- */
43
- function superpwa_multisite_activation_status( $status ) {
44
-
45
- // Only for multisites
46
- if ( ! is_multisite() || ! isset( $status ) ) {
47
- return;
48
- }
49
-
50
- // Get current list of sites where SuperPWA is activated.
51
- $superpwa_sites = get_site_option( 'superpwa_active_sites', array() );
52
-
53
- // Set the status for the current blog.
54
- $superpwa_sites[ get_current_blog_id() ] = $status;
55
-
56
- // Save it back to the database.
57
- update_site_option( 'superpwa_active_sites', $superpwa_sites );
58
- }
59
-
60
- /**
61
- * Handle multisite network deactivation
62
- *
63
- * Deletes manifest and service worker of all sub-sites.
64
- * Sets the deactivation status for each site.
65
- *
66
- * Not used when wp_is_large_network() is true. Deleting that many files and db options will most likely time out.
67
- * This also this gives the user an option to decide if SuperPWA should handle this by changing the defenition of wp_is_large_network.
68
- * @link https://developer.wordpress.org/reference/functions/wp_is_large_network/
69
- */
70
- function superpwa_multisite_network_deactivator() {
71
-
72
- // Do not run on large networks
73
- if ( wp_is_large_network() ) {
74
- return;
75
- }
76
-
77
- // Retrieve the list of blog ids where SuperPWA is active. (saved with blog_id as $key and activation_status as $value)
78
- $superpwa_sites = get_site_option( 'superpwa_active_sites' );
79
-
80
- // Loop through each active site.
81
- foreach( $superpwa_sites as $blog_id => $actviation_status ) {
82
-
83
- // Switch to each blog
84
- switch_to_blog( $blog_id );
85
-
86
- // Delete manifest
87
- superpwa_delete_manifest();
88
-
89
- // Delete service worker
90
- superpwa_delete_sw();
91
-
92
- /**
93
- * Delete SuperPWA version info for current blog.
94
- *
95
- * This is required so that superpwa_upgrader() will run and create the manifest and service worker on next activation.
96
- * Known edge case: Database upgrade that relies on the version number will fail if user deactivates and later activates after SuperPWA is updated.
97
- */
98
- delete_option( 'superpwa_version' );
99
-
100
- // Save the de-activation status of current blog.
101
- superpwa_multisite_activation_status( false );
102
-
103
- // Return to main site
104
- restore_current_blog();
105
- }
106
  }
1
+ <?php
2
+ /**
3
+ * Functions for compatibility with WordPress multisites
4
+ *
5
+ * @since 1.6
6
+ *
7
+ * @function superpwa_multisite_filename_postfix() Filename postfix for multisites
8
+ * @function superpwa_multisite_activation_status() Save activation status for current blog id
9
+ * @function superpwa_multisite_network_deactivator() Handle multisite network deactivation
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) exit;
14
+
15
+ /**
16
+ * Filename postfix for multisites
17
+ *
18
+ * @return (string) Returns the current blog ID on a multisite. An empty string otherwise
19
+ *
20
+ * @since 1.6
21
+ */
22
+ function superpwa_multisite_filename_postfix() {
23
+
24
+ // Return empty string if not a multisite
25
+ if ( ! is_multisite() ) {
26
+ return '';
27
+ }
28
+
29
+ return '-' . get_current_blog_id();
30
+ }
31
+
32
+ /**
33
+ * Save activation status for current blog id
34
+ *
35
+ * For clean multisite uninstall.
36
+ * Manifest and service worker are deleted during deactivation.
37
+ * Database settings are cleaned during uninstall
38
+ *
39
+ * @param (bool) $status True when plugin is activated, false when deactivated.
40
+ *
41
+ * @since 1.6
42
+ */
43
+ function superpwa_multisite_activation_status( $status ) {
44
+
45
+ // Only for multisites
46
+ if ( ! is_multisite() || ! isset( $status ) ) {
47
+ return;
48
+ }
49
+
50
+ // Get current list of sites where SuperPWA is activated.
51
+ $superpwa_sites = get_site_option( 'superpwa_active_sites', array() );
52
+
53
+ // Set the status for the current blog.
54
+ $superpwa_sites[ get_current_blog_id() ] = $status;
55
+
56
+ // Save it back to the database.
57
+ update_site_option( 'superpwa_active_sites', $superpwa_sites );
58
+ }
59
+
60
+ /**
61
+ * Handle multisite network deactivation
62
+ *
63
+ * Deletes manifest and service worker of all sub-sites.
64
+ * Sets the deactivation status for each site.
65
+ *
66
+ * Not used when wp_is_large_network() is true. Deleting that many files and db options will most likely time out.
67
+ * This also this gives the user an option to decide if SuperPWA should handle this by changing the defenition of wp_is_large_network.
68
+ * @link https://developer.wordpress.org/reference/functions/wp_is_large_network/
69
+ */
70
+ function superpwa_multisite_network_deactivator() {
71
+
72
+ // Do not run on large networks
73
+ if ( wp_is_large_network() ) {
74
+ return;
75
+ }
76
+
77
+ // Retrieve the list of blog ids where SuperPWA is active. (saved with blog_id as $key and activation_status as $value)
78
+ $superpwa_sites = get_site_option( 'superpwa_active_sites' );
79
+
80
+ // Loop through each active site.
81
+ foreach( $superpwa_sites as $blog_id => $actviation_status ) {
82
+
83
+ // Switch to each blog
84
+ switch_to_blog( $blog_id );
85
+
86
+ // Delete manifest
87
+ superpwa_delete_manifest();
88
+
89
+ // Delete service worker
90
+ superpwa_delete_sw();
91
+
92
+ /**
93
+ * Delete SuperPWA version info for current blog.
94
+ *
95
+ * This is required so that superpwa_upgrader() will run and create the manifest and service worker on next activation.
96
+ * Known edge case: Database upgrade that relies on the version number will fail if user deactivates and later activates after SuperPWA is updated.
97
+ */
98
+ delete_option( 'superpwa_version' );
99
+
100
+ // Save the de-activation status of current blog.
101
+ superpwa_multisite_activation_status( false );
102
+
103
+ // Return to main site
104
+ restore_current_blog();
105
+ }
106
  }
includes/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
languages/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
languages/super-progressive-web-apps-fr_FR.po CHANGED
@@ -1,480 +1,480 @@
1
- # Copyright (C) 2018 Super Progressive Web Apps
2
- # This file is distributed under the same license as the Super Progressive Web Apps package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Super Progressive Web Apps 1.8\n"
6
- "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/super-progressive-"
7
- "web-apps\n"
8
- "POT-Creation-Date: 2018-06-11 15:50:32+00:00\n"
9
- "PO-Revision-Date: 2018-06-11 21:30+0530\n"
10
- "Last-Translator: WP Media <contact@wp-rocket.me>\n"
11
- "Language-Team: \n"
12
- "Language: fr_FR\n"
13
- "MIME-Version: 1.0\n"
14
- "Content-Type: text/plain; charset=UTF-8\n"
15
- "Content-Transfer-Encoding: 8bit\n"
16
- "X-Generator: Poedit 2.0.8\n"
17
- "Plural-Forms: nplurals=2; plural=(n > 1);\n"
18
-
19
- #: 3rd-party/onesignal.php:190
20
- msgid ""
21
- "<strong>SuperPWA</strong> is not compatible with OneSignal on multisites "
22
- "yet. Disable one of these plugins until the compatibility is available."
23
- "<br>Please refer to the <a href=\"%s\" target=\"_blank\">OneSignal "
24
- "integration documentation</a> for more info. "
25
- msgstr ""
26
-
27
- #: 3rd-party/onesignal.php:212
28
- msgid ""
29
- "<strong>Action Required to integrate SuperPWA with OneSignal:</strong><br>1. "
30
- "Go to <a href=\"%s\" target=\"_blank\">OneSignal Configuration > Scroll down "
31
- "to Advanced Settings &rarr;</a><br>2. Enable <strong>Use my own manifest."
32
- "json</strong><br>3. Set <code>%s</code>as <strong>Custom manifest.json URL</"
33
- "strong> and Save Settings.<br>Please refer the <a href=\"%s\" target=\"_blank"
34
- "\">OneSignal integration documentation</a> for more info. "
35
- msgstr ""
36
-
37
- #. Plugin Name of the plugin/theme
38
- #: addons/utm-tracking.php:35 admin/admin-ui-setup.php:28
39
- #: admin/admin-ui-setup.php:31 admin/admin-ui-setup.php:34
40
- msgid "Super Progressive Web Apps"
41
- msgstr "Super Progressive Web Apps"
42
-
43
- #: addons/utm-tracking.php:35 admin/admin-ui-render-addons.php:49
44
- msgid "UTM Tracking"
45
- msgstr "Suivi UTM"
46
-
47
- #: addons/utm-tracking.php:146
48
- msgid "Current Start URL"
49
- msgstr "URL de départ actuelle"
50
-
51
- #: addons/utm-tracking.php:155
52
- msgid "Campaign Source"
53
- msgstr "Source de Campagne"
54
-
55
- #: addons/utm-tracking.php:164
56
- msgid "Campaign Medium"
57
- msgstr "Medium de la Campagne"
58
-
59
- #: addons/utm-tracking.php:173
60
- msgid "Campaign Name"
61
- msgstr "Nom de la Campagne"
62
-
63
- #: addons/utm-tracking.php:182
64
- msgid "Campaign Term"
65
- msgstr "Terme de la Campagne"
66
-
67
- #: addons/utm-tracking.php:191
68
- msgid "Campaign Content"
69
- msgstr "Contenu de la Campagne"
70
-
71
- #: addons/utm-tracking.php:234
72
- msgid ""
73
- "This add-on automatically adds UTM campaign parameters to the <code>Start "
74
- "Page</code> URL in your <a href=\"%s\" target=\"_blank\">manifest</a>. This "
75
- "will help you identify visitors coming specifically from your app. <a href="
76
- "\"%s\" target=\"_blank\">Read more</a> about UTM Tracking."
77
- msgstr ""
78
- "Ce module ajoute automatiquement les paramètres de campagne UTM à l'URL de "
79
- "la <code>Page de Départ</code> dans votre <a href=\"%s\" target=\"_blank"
80
- "\">manifeste</a> . Cela vous aidera à identifier les visiteurs provenant "
81
- "spécifiquement de votre application. <a href=\"%s\" target=\"_blank\">En "
82
- "savoir plus</a> sur le Suivi UTM."
83
-
84
- #: addons/utm-tracking.php:264
85
- msgid ""
86
- "Campaign Source is mandatory and defaults to <code>superpwa</code>. The "
87
- "remaining fields are optional."
88
- msgstr ""
89
- "La source de la Campagne est obligatoire et utilise par défaut "
90
- "<code>superpwa</code>. Les autres champs sont facultatifs."
91
-
92
- #: addons/utm-tracking.php:362 admin/admin-ui-render-settings.php:360
93
- msgid "Settings saved."
94
- msgstr "Réglages enregistrés."
95
-
96
- #: addons/utm-tracking.php:371
97
- msgid "UTM Tracking for"
98
- msgstr "Suivi UTM pour"
99
-
100
- #: addons/utm-tracking.php:382 admin/admin-ui-render-settings.php:383
101
- msgid "Save Settings"
102
- msgstr "Sauvegarder les réglages"
103
-
104
- #: admin/admin-ui-render-addons.php:50
105
- msgid ""
106
- "Track visits from your app by adding UTM tracking parameters to the Start "
107
- "Page URL."
108
- msgstr ""
109
- "Suivez les visites de votre application en ajoutant les paramètres de suivi "
110
- "UTM à l’URL de page de départ."
111
-
112
- #: admin/admin-ui-render-addons.php:55
113
- msgid "Customize Settings &rarr;"
114
- msgstr "Personnaliser les paramètres de &rarr;"
115
-
116
- #: admin/admin-ui-render-addons.php:60
117
- msgid "Apple Touch Icons"
118
- msgstr "Icônes Apple Touch"
119
-
120
- #: admin/admin-ui-render-addons.php:61
121
- msgid ""
122
- "Set the Application Icon and Splash Screen Icon as Apple Touch Icons for "
123
- "compatibility with iOS devices."
124
- msgstr ""
125
- "Définir l’icône de l’Application et l’icône de l’écran d’accueil comme les "
126
- "icônes Apple Touch pour la compatibilité avec les appareils iOS."
127
-
128
- #: admin/admin-ui-render-addons.php:66
129
- msgid "More Details &rarr;"
130
- msgstr "Plus de détails &rarr;"
131
-
132
- #: admin/admin-ui-render-addons.php:115
133
- msgid "<strong>Add-On activated: %s.</strong> <a href=\"%s\"%s>%s</a>"
134
- msgstr "<strong>Module activé : %s.</strong> <a href=\"%s\" %s=\"\">%s</a>"
135
-
136
- #: admin/admin-ui-render-addons.php:123
137
- msgid "Add-On deactivated"
138
- msgstr "Module désactivé"
139
-
140
- #: admin/admin-ui-render-addons.php:135
141
- msgid "Add-Ons for"
142
- msgstr "Modules pour"
143
-
144
- #: admin/admin-ui-render-addons.php:137
145
- msgid "Add-Ons extend the functionality of SuperPWA."
146
- msgstr "Les modules étendent les fonctionnalités de SuperPWA."
147
-
148
- #: admin/admin-ui-render-addons.php:177 admin/admin-ui-render-addons.php:349
149
- msgid "Deactivate"
150
- msgstr "Désactiver"
151
-
152
- #: admin/admin-ui-render-addons.php:182
153
- msgid "More information about %s"
154
- msgstr "Plus d’informations sur %s"
155
-
156
- #: admin/admin-ui-render-addons.php:182
157
- msgid "More Details"
158
- msgstr "Plus de détails"
159
-
160
- #: admin/admin-ui-render-addons.php:197
161
- msgid ""
162
- "<span class=\"compatibility-compatible\"><strong>Add-On active.</strong> <a "
163
- "href=\"%s\"%s>%s</a></span>"
164
- msgstr ""
165
- "<span class=\"compatibility-compatible\"><strong>Le module actif.</strong> "
166
- "<a href=\"%s\" %s=\"\">%s</a></span>"
167
-
168
- #: admin/admin-ui-render-addons.php:200
169
- msgid ""
170
- "<span class=\"compatibility-compatible\"><strong>Compatible</strong> with "
171
- "your version of SuperPWA</span>"
172
- msgstr ""
173
- "<span class=\"compatibility-compatible\"><strong>Compatible</strong> avec "
174
- "votre version de SuperPWA</span>"
175
-
176
- #: admin/admin-ui-render-addons.php:203
177
- msgid ""
178
- "<span class=\"compatibility-incompatible\"><strong>Please upgrade</strong> "
179
- "to the latest version of SuperPWA</span>"
180
- msgstr ""
181
- "<span class=\"compatibility-incompatible\"><strong>Veuillez mettre à niveau</"
182
- "strong> vers la dernière version de SuperPWA</span>"
183
-
184
- #: admin/admin-ui-render-addons.php:217
185
- msgid "SuperPWA Newsletter"
186
- msgstr "Newsletter de SuperPWA"
187
-
188
- #: admin/admin-ui-render-addons.php:221
189
- msgid ""
190
- "Learn more about Progressive Web Apps<br>and get latest updates about "
191
- "SuperPWA"
192
- msgstr ""
193
- "En savoir plus sur les Progressive Web Apps<br>et recevez les dernières "
194
- "actualités de SuperPWA"
195
-
196
- #: admin/admin-ui-render-addons.php:229
197
- msgid "Enter your email"
198
- msgstr "Entrez votre email"
199
-
200
- #: admin/admin-ui-render-addons.php:231
201
- msgid "Subscribe"
202
- msgstr "S'abonner"
203
-
204
- #: admin/admin-ui-render-addons.php:233
205
- msgid ""
206
- "we'll share our <code>root</code> password before we share your email with "
207
- "anyone else."
208
- msgstr ""
209
- "nous partagerons notre mot de passe <code>root</code> avant de partager "
210
- "votre email avec qui que ce soit d'autre."
211
-
212
- #: admin/admin-ui-render-addons.php:345
213
- msgid "Activate"
214
- msgstr "Activer"
215
-
216
- #: admin/admin-ui-render-addons.php:354
217
- msgid "Install"
218
- msgstr "Installer"
219
-
220
- #: admin/admin-ui-render-settings.php:60
221
- msgid ""
222
- "Used when there is insufficient space to display the full name of the "
223
- "application. <code>12</code> characters or less."
224
- msgstr ""
225
- "Utilisé lorsque l'espace est insuffisant pour afficher le nom complet de "
226
- "l'application. <code>12</code> caractères ou moins."
227
-
228
- #: admin/admin-ui-render-settings.php:83
229
- msgid "A brief description of what your app is about."
230
- msgstr "Une brève description du sujet sur lequel porte votre application."
231
-
232
- #: admin/admin-ui-render-settings.php:104
233
- #: admin/admin-ui-render-settings.php:127
234
- msgid "Choose Icon"
235
- msgstr "Choisir une icône"
236
-
237
- #: admin/admin-ui-render-settings.php:108
238
- msgid ""
239
- "This will be the icon of your app when installed on the phone. Must be a "
240
- "<code>PNG</code> image exactly <code>192x192</code> in size."
241
- msgstr ""
242
- "Ce sera l'icône de votre application lorsqu'elle est installée sur un "
243
- "smartphone. Elle doit être une image <code>PNG</code> d'exactement "
244
- "<code>192x192</code> pixels."
245
-
246
- #: admin/admin-ui-render-settings.php:131
247
- msgid ""
248
- "This icon will be displayed on the splash screen of your app on supported "
249
- "devices. Must be a <code>PNG</code> image exactly <code>512x512</code> in "
250
- "size."
251
- msgstr ""
252
- "Cette icône sera affichée sur l'écran de démarrage de votre application sur "
253
- "les appareils compatibles. Ça doit être une image <code>PNG</code> "
254
- "d'exactement <code>512x512</code> pixels."
255
-
256
- #: admin/admin-ui-render-settings.php:151
257
- msgid "Background color of the splash screen."
258
- msgstr "Couleur d’arrière-plan de l’écran de démarrage."
259
-
260
- #: admin/admin-ui-render-settings.php:171
261
- msgid ""
262
- "Theme color is used on supported devices to tint the UI elements of the "
263
- "browser and app switcher. When in doubt, use the same color as "
264
- "<code>Background Color</code>."
265
- msgstr ""
266
- "La couleur du thème est utilisée sur les appareils pris en charge pour "
267
- "personnaliser la teinte des éléments d’interface utilisateur du navigateur "
268
- "et du switcher d’app. En cas de doute, utilisez la même couleur que la "
269
- "<code>Couleur d’arrière-plan</code>."
270
-
271
- #: admin/admin-ui-render-settings.php:194
272
- msgid "&mdash; Homepage &mdash;"
273
- msgstr "&mdash; Page d’accueil &mdash;"
274
-
275
- #: admin/admin-ui-render-settings.php:201
276
- msgid ""
277
- "Specify the page to load when the application is launched from a device. "
278
- "Current start page is <code>%s</code>"
279
- msgstr ""
280
- "Spécifiez la page à charger lorsque l'application est lancée à partir d'un "
281
- "appareil. La page d'accueil actuelle est <code>%s</code>"
282
-
283
- #: admin/admin-ui-render-settings.php:209
284
- msgid "Use AMP version of the start page."
285
- msgstr "Utiliser la version AMP de la page de démarrage."
286
-
287
- #: admin/admin-ui-render-settings.php:215
288
- msgid ""
289
- "Do not check this if your start page is the homepage, the blog index, or the "
290
- "archives page. AMP for WordPress does not create AMP versions for these "
291
- "pages."
292
- msgstr ""
293
- "Ne cochez pas cette case si votre page de départ est la page d'accueil de "
294
- "votre site, l'index du blog ou la page d'archives. AMP pour WordPress ne "
295
- "crée pas de versions AMP pour ces pages."
296
-
297
- #: admin/admin-ui-render-settings.php:241
298
- msgid "&mdash; Default &mdash;"
299
- msgstr "&mdash; Par défaut &mdash;"
300
-
301
- #: admin/admin-ui-render-settings.php:248
302
- msgid ""
303
- "Offline page is displayed when the device is offline and the requested page "
304
- "is not already cached. Current offline page is <code>%s</code>"
305
- msgstr ""
306
- "La page hors connexion s’affiche lorsque l'appareil est hors connexion et "
307
- "que la page demandée n’est pas déjà mise en cache. La page hors connexion "
308
- "actuelle est <code>%s</code>"
309
-
310
- #: admin/admin-ui-render-settings.php:268
311
- msgid "Follow Device Orientation"
312
- msgstr "Suivre l'orientation de l'appareil"
313
-
314
- #: admin/admin-ui-render-settings.php:271
315
- msgid "Portrait"
316
- msgstr "Portrait"
317
-
318
- #: admin/admin-ui-render-settings.php:274
319
- msgid "Landscape"
320
- msgstr "Paysage"
321
-
322
- #: admin/admin-ui-render-settings.php:280
323
- msgid ""
324
- "Set the orientation of your app on devices. When set to <code>Follow Device "
325
- "Orientation</code> your app will rotate as the device is rotated."
326
- msgstr ""
327
- "Définissez l'orientation de votre application sur les appareils. Lorsque "
328
- "l'option <code>Suivre l'orientation de l'appareil</code> est définie, votre "
329
- "application tourne en fonction de l'appareil."
330
-
331
- #: admin/admin-ui-render-settings.php:302
332
- msgid ""
333
- "Manifest generated successfully. You can <a href=\"%s\" target=\"_blank"
334
- "\">see it here &rarr;</a>"
335
- msgstr ""
336
- "Le manifeste a été généré avec succès. Vous pouvez <a href=\"%s\" target="
337
- "\"_blank\">le voir ici &rarr;</a>"
338
-
339
- #: admin/admin-ui-render-settings.php:305
340
- msgid ""
341
- "Manifest generation failed. Check if WordPress can write to your root folder "
342
- "(the same folder with wp-config.php). <a href=\"%s\" target=\"_blank\">Read "
343
- "more &rarr;</a>"
344
- msgstr ""
345
- "Échec de génération du manifeste. Vérifiez si WordPress peut écrire dans "
346
- "votre dossier racine (même dossier que wp-config.php). <a href=\"%s\" target="
347
- "\"_blank\">En savoir plux &rarr;</a>"
348
-
349
- #: admin/admin-ui-render-settings.php:320
350
- msgid "Service worker generated successfully."
351
- msgstr "Service Worker généré avec succès."
352
-
353
- #: admin/admin-ui-render-settings.php:323
354
- msgid ""
355
- "Service worker generation failed. Check if WordPress can write to your root "
356
- "folder (the same folder with wp-config.php). <a href=\"%s\" target=\"_blank"
357
- "\">Read more &rarr;</a>"
358
- msgstr ""
359
- "La génération de Service Worker a échouée. Vérifiez si WordPress peut écrire "
360
- "dans votre dossier racine (même dossier que wp-config.php). <a href=\"%s\" "
361
- "target=\"_blank\">En savoir plus &rarr;</a>"
362
-
363
- #: admin/admin-ui-render-settings.php:336
364
- msgid "Your website is served over HTTPS."
365
- msgstr "Votre site Web est servi via HTTPS."
366
-
367
- #: admin/admin-ui-render-settings.php:339
368
- msgid ""
369
- "Progressive Web Apps require that your website is served over HTTPS. Please "
370
- "contact your host to add a SSL certificate to your domain."
371
- msgstr ""
372
- "Les applications Web progressives exigent que votre site est desservie via "
373
- "HTTPS. Contactez votre hébergeur pour ajouter un certificat SSL à votre "
374
- "domaine."
375
-
376
- #. Author of the plugin/theme
377
- #: admin/admin-ui-setup.php:28
378
- msgid "SuperPWA"
379
- msgstr "SuperPWA"
380
-
381
- #: admin/admin-ui-setup.php:31 admin/basic-setup.php:278
382
- msgid "Settings"
383
- msgstr "Réglages"
384
-
385
- #: admin/admin-ui-setup.php:34
386
- msgid "Add-Ons"
387
- msgstr "Add-ons"
388
-
389
- #: admin/admin-ui-setup.php:63
390
- msgid "Application Name"
391
- msgstr "Nom de l’application"
392
-
393
- #: admin/admin-ui-setup.php:72
394
- msgid "Application Short Name"
395
- msgstr "Nom court de l’application"
396
-
397
- #: admin/admin-ui-setup.php:81
398
- msgid "Description"
399
- msgstr "Description"
400
-
401
- #: admin/admin-ui-setup.php:90
402
- msgid "Application Icon"
403
- msgstr "Icône de l’application"
404
-
405
- #: admin/admin-ui-setup.php:99
406
- msgid "Splash Screen Icon"
407
- msgstr "Icône de l’écran de démarrage"
408
-
409
- #: admin/admin-ui-setup.php:108
410
- msgid "Background Color"
411
- msgstr "Couleur d'arrière plan"
412
-
413
- #: admin/admin-ui-setup.php:117
414
- msgid "Theme Color"
415
- msgstr "Couleur du thème"
416
-
417
- #: admin/admin-ui-setup.php:126
418
- msgid "Start Page"
419
- msgstr "Page de départ"
420
-
421
- #: admin/admin-ui-setup.php:135
422
- msgid "Offline Page"
423
- msgstr "Page hors ligne"
424
-
425
- #: admin/admin-ui-setup.php:144
426
- msgid "Orientation"
427
- msgstr "Orientation"
428
-
429
- #: admin/admin-ui-setup.php:153
430
- msgid "Status"
431
- msgstr "Statut"
432
-
433
- #: admin/admin-ui-setup.php:161
434
- msgid "Manifest"
435
- msgstr "Manifeste"
436
-
437
- #: admin/admin-ui-setup.php:170
438
- msgid "Service Worker"
439
- msgstr "Service Worker"
440
-
441
- #: admin/admin-ui-setup.php:179
442
- msgid "HTTPS"
443
- msgstr "HTTPS"
444
-
445
- #: admin/admin-ui-setup.php:305
446
- msgid ""
447
- "If you like SuperPWA, please <a href=\"%s\" target=\"_blank\">make a "
448
- "donation</a> or leave a <a href=\"%s\" target=\"_blank\">&#9733;&#9733;"
449
- "&#9733;&#9733;&#9733;</a> rating to support continued development. Thanks a "
450
- "bunch!"
451
- msgstr ""
452
- "Si vous aimez SuperPWA, <a href=\"%s\" target=\"_blank\">faites un don</a> "
453
- "ou laissez une note <a href=\"%s\" target=\"_blank\">&#9733;&#9733;&#9733;"
454
- "&#9733;&#9733;</a> pour soutenir son développement. Merci beaucoup !"
455
-
456
- #: admin/basic-setup.php:82 admin/basic-setup.php:116
457
- msgid ""
458
- "<strong>SuperPWA</strong>: Successfully updated to version %s. Thank you! <a "
459
- "href=\"%s\" target=\"_blank\">Discover new features and read the story &rarr;"
460
- "</a>"
461
- msgstr ""
462
- "<strong>SuperPWA</strong>: Succès de la mise à jour vers la version %s. "
463
- "Merci ! <a href=\"%s\" target=\"_blank\">Découvrez les nouvelles "
464
- "fonctionnalités et lisez notre histoire &rarr;</a>"
465
-
466
- #: admin/basic-setup.php:294
467
- msgid "Demo"
468
- msgstr "Démo"
469
-
470
- #. Plugin URI of the plugin/theme
471
- msgid "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=plugin-uri"
472
- msgstr "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=plugin-uri"
473
-
474
- #. Description of the plugin/theme
475
- msgid "Convert your WordPress website into a Progressive Web App"
476
- msgstr "Transformer votre site WordPress en une application Web progressive"
477
-
478
- #. Author URI of the plugin/theme
479
- msgid "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=author-uri"
480
- msgstr "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=author-uri"
1
+ # Copyright (C) 2018 Super Progressive Web Apps
2
+ # This file is distributed under the same license as the Super Progressive Web Apps package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Super Progressive Web Apps 1.8\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/super-progressive-"
7
+ "web-apps\n"
8
+ "POT-Creation-Date: 2018-06-11 15:50:32+00:00\n"
9
+ "PO-Revision-Date: 2018-06-11 21:30+0530\n"
10
+ "Last-Translator: WP Media <contact@wp-rocket.me>\n"
11
+ "Language-Team: \n"
12
+ "Language: fr_FR\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Content-Type: text/plain; charset=UTF-8\n"
15
+ "Content-Transfer-Encoding: 8bit\n"
16
+ "X-Generator: Poedit 2.0.8\n"
17
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
18
+
19
+ #: 3rd-party/onesignal.php:190
20
+ msgid ""
21
+ "<strong>SuperPWA</strong> is not compatible with OneSignal on multisites "
22
+ "yet. Disable one of these plugins until the compatibility is available."
23
+ "<br>Please refer to the <a href=\"%s\" target=\"_blank\">OneSignal "
24
+ "integration documentation</a> for more info. "
25
+ msgstr ""
26
+
27
+ #: 3rd-party/onesignal.php:212
28
+ msgid ""
29
+ "<strong>Action Required to integrate SuperPWA with OneSignal:</strong><br>1. "
30
+ "Go to <a href=\"%s\" target=\"_blank\">OneSignal Configuration > Scroll down "
31
+ "to Advanced Settings &rarr;</a><br>2. Enable <strong>Use my own manifest."
32
+ "json</strong><br>3. Set <code>%s</code>as <strong>Custom manifest.json URL</"
33
+ "strong> and Save Settings.<br>Please refer the <a href=\"%s\" target=\"_blank"
34
+ "\">OneSignal integration documentation</a> for more info. "
35
+ msgstr ""
36
+
37
+ #. Plugin Name of the plugin/theme
38
+ #: addons/utm-tracking.php:35 admin/admin-ui-setup.php:28
39
+ #: admin/admin-ui-setup.php:31 admin/admin-ui-setup.php:34
40
+ msgid "Super Progressive Web Apps"
41
+ msgstr "Super Progressive Web Apps"
42
+
43
+ #: addons/utm-tracking.php:35 admin/admin-ui-render-addons.php:49
44
+ msgid "UTM Tracking"
45
+ msgstr "Suivi UTM"
46
+
47
+ #: addons/utm-tracking.php:146
48
+ msgid "Current Start URL"
49
+ msgstr "URL de départ actuelle"
50
+
51
+ #: addons/utm-tracking.php:155
52
+ msgid "Campaign Source"
53
+ msgstr "Source de Campagne"
54
+
55
+ #: addons/utm-tracking.php:164
56
+ msgid "Campaign Medium"
57
+ msgstr "Medium de la Campagne"
58
+
59
+ #: addons/utm-tracking.php:173
60
+ msgid "Campaign Name"
61
+ msgstr "Nom de la Campagne"
62
+
63
+ #: addons/utm-tracking.php:182
64
+ msgid "Campaign Term"
65
+ msgstr "Terme de la Campagne"
66
+
67
+ #: addons/utm-tracking.php:191
68
+ msgid "Campaign Content"
69
+ msgstr "Contenu de la Campagne"
70
+
71
+ #: addons/utm-tracking.php:234
72
+ msgid ""
73
+ "This add-on automatically adds UTM campaign parameters to the <code>Start "
74
+ "Page</code> URL in your <a href=\"%s\" target=\"_blank\">manifest</a>. This "
75
+ "will help you identify visitors coming specifically from your app. <a href="
76
+ "\"%s\" target=\"_blank\">Read more</a> about UTM Tracking."
77
+ msgstr ""
78
+ "Ce module ajoute automatiquement les paramètres de campagne UTM à l'URL de "
79
+ "la <code>Page de Départ</code> dans votre <a href=\"%s\" target=\"_blank"
80
+ "\">manifeste</a> . Cela vous aidera à identifier les visiteurs provenant "
81
+ "spécifiquement de votre application. <a href=\"%s\" target=\"_blank\">En "
82
+ "savoir plus</a> sur le Suivi UTM."
83
+
84
+ #: addons/utm-tracking.php:264
85
+ msgid ""
86
+ "Campaign Source is mandatory and defaults to <code>superpwa</code>. The "
87
+ "remaining fields are optional."
88
+ msgstr ""
89
+ "La source de la Campagne est obligatoire et utilise par défaut "
90
+ "<code>superpwa</code>. Les autres champs sont facultatifs."
91
+
92
+ #: addons/utm-tracking.php:362 admin/admin-ui-render-settings.php:360
93
+ msgid "Settings saved."
94
+ msgstr "Réglages enregistrés."
95
+
96
+ #: addons/utm-tracking.php:371
97
+ msgid "UTM Tracking for"
98
+ msgstr "Suivi UTM pour"
99
+
100
+ #: addons/utm-tracking.php:382 admin/admin-ui-render-settings.php:383
101
+ msgid "Save Settings"
102
+ msgstr "Sauvegarder les réglages"
103
+
104
+ #: admin/admin-ui-render-addons.php:50
105
+ msgid ""
106
+ "Track visits from your app by adding UTM tracking parameters to the Start "
107
+ "Page URL."
108
+ msgstr ""
109
+ "Suivez les visites de votre application en ajoutant les paramètres de suivi "
110
+ "UTM à l’URL de page de départ."
111
+
112
+ #: admin/admin-ui-render-addons.php:55
113
+ msgid "Customize Settings &rarr;"
114
+ msgstr "Personnaliser les paramètres de &rarr;"
115
+
116
+ #: admin/admin-ui-render-addons.php:60
117
+ msgid "Apple Touch Icons"
118
+ msgstr "Icônes Apple Touch"
119
+
120
+ #: admin/admin-ui-render-addons.php:61
121
+ msgid ""
122
+ "Set the Application Icon and Splash Screen Icon as Apple Touch Icons for "
123
+ "compatibility with iOS devices."
124
+ msgstr ""
125
+ "Définir l’icône de l’Application et l’icône de l’écran d’accueil comme les "
126
+ "icônes Apple Touch pour la compatibilité avec les appareils iOS."
127
+
128
+ #: admin/admin-ui-render-addons.php:66
129
+ msgid "More Details &rarr;"
130
+ msgstr "Plus de détails &rarr;"
131
+
132
+ #: admin/admin-ui-render-addons.php:115
133
+ msgid "<strong>Add-On activated: %s.</strong> <a href=\"%s\"%s>%s</a>"
134
+ msgstr "<strong>Module activé : %s.</strong> <a href=\"%s\" %s=\"\">%s</a>"
135
+
136
+ #: admin/admin-ui-render-addons.php:123
137
+ msgid "Add-On deactivated"
138
+ msgstr "Module désactivé"
139
+
140
+ #: admin/admin-ui-render-addons.php:135
141
+ msgid "Add-Ons for"
142
+ msgstr "Modules pour"
143
+
144
+ #: admin/admin-ui-render-addons.php:137
145
+ msgid "Add-Ons extend the functionality of SuperPWA."
146
+ msgstr "Les modules étendent les fonctionnalités de SuperPWA."
147
+
148
+ #: admin/admin-ui-render-addons.php:177 admin/admin-ui-render-addons.php:349
149
+ msgid "Deactivate"
150
+ msgstr "Désactiver"
151
+
152
+ #: admin/admin-ui-render-addons.php:182
153
+ msgid "More information about %s"
154
+ msgstr "Plus d’informations sur %s"
155
+
156
+ #: admin/admin-ui-render-addons.php:182
157
+ msgid "More Details"
158
+ msgstr "Plus de détails"
159
+
160
+ #: admin/admin-ui-render-addons.php:197
161
+ msgid ""
162
+ "<span class=\"compatibility-compatible\"><strong>Add-On active.</strong> <a "
163
+ "href=\"%s\"%s>%s</a></span>"
164
+ msgstr ""
165
+ "<span class=\"compatibility-compatible\"><strong>Le module actif.</strong> "
166
+ "<a href=\"%s\" %s=\"\">%s</a></span>"
167
+
168
+ #: admin/admin-ui-render-addons.php:200
169
+ msgid ""
170
+ "<span class=\"compatibility-compatible\"><strong>Compatible</strong> with "
171
+ "your version of SuperPWA</span>"
172
+ msgstr ""
173
+ "<span class=\"compatibility-compatible\"><strong>Compatible</strong> avec "
174
+ "votre version de SuperPWA</span>"
175
+
176
+ #: admin/admin-ui-render-addons.php:203
177
+ msgid ""
178
+ "<span class=\"compatibility-incompatible\"><strong>Please upgrade</strong> "
179
+ "to the latest version of SuperPWA</span>"
180
+ msgstr ""
181
+ "<span class=\"compatibility-incompatible\"><strong>Veuillez mettre à niveau</"
182
+ "strong> vers la dernière version de SuperPWA</span>"
183
+
184
+ #: admin/admin-ui-render-addons.php:217
185
+ msgid "SuperPWA Newsletter"
186
+ msgstr "Newsletter de SuperPWA"
187
+
188
+ #: admin/admin-ui-render-addons.php:221
189
+ msgid ""
190
+ "Learn more about Progressive Web Apps<br>and get latest updates about "
191
+ "SuperPWA"
192
+ msgstr ""
193
+ "En savoir plus sur les Progressive Web Apps<br>et recevez les dernières "
194
+ "actualités de SuperPWA"
195
+
196
+ #: admin/admin-ui-render-addons.php:229
197
+ msgid "Enter your email"
198
+ msgstr "Entrez votre email"
199
+
200
+ #: admin/admin-ui-render-addons.php:231
201
+ msgid "Subscribe"
202
+ msgstr "S'abonner"
203
+
204
+ #: admin/admin-ui-render-addons.php:233
205
+ msgid ""
206
+ "we'll share our <code>root</code> password before we share your email with "
207
+ "anyone else."
208
+ msgstr ""
209
+ "nous partagerons notre mot de passe <code>root</code> avant de partager "
210
+ "votre email avec qui que ce soit d'autre."
211
+
212
+ #: admin/admin-ui-render-addons.php:345
213
+ msgid "Activate"
214
+ msgstr "Activer"
215
+
216
+ #: admin/admin-ui-render-addons.php:354
217
+ msgid "Install"
218
+ msgstr "Installer"
219
+
220
+ #: admin/admin-ui-render-settings.php:60
221
+ msgid ""
222
+ "Used when there is insufficient space to display the full name of the "
223
+ "application. <code>12</code> characters or less."
224
+ msgstr ""
225
+ "Utilisé lorsque l'espace est insuffisant pour afficher le nom complet de "
226
+ "l'application. <code>12</code> caractères ou moins."
227
+
228
+ #: admin/admin-ui-render-settings.php:83
229
+ msgid "A brief description of what your app is about."
230
+ msgstr "Une brève description du sujet sur lequel porte votre application."
231
+
232
+ #: admin/admin-ui-render-settings.php:104
233
+ #: admin/admin-ui-render-settings.php:127
234
+ msgid "Choose Icon"
235
+ msgstr "Choisir une icône"
236
+
237
+ #: admin/admin-ui-render-settings.php:108
238
+ msgid ""
239
+ "This will be the icon of your app when installed on the phone. Must be a "
240
+ "<code>PNG</code> image exactly <code>192x192</code> in size."
241
+ msgstr ""
242
+ "Ce sera l'icône de votre application lorsqu'elle est installée sur un "
243
+ "smartphone. Elle doit être une image <code>PNG</code> d'exactement "
244
+ "<code>192x192</code> pixels."
245
+
246
+ #: admin/admin-ui-render-settings.php:131
247
+ msgid ""
248
+ "This icon will be displayed on the splash screen of your app on supported "
249
+ "devices. Must be a <code>PNG</code> image exactly <code>512x512</code> in "
250
+ "size."
251
+ msgstr ""
252
+ "Cette icône sera affichée sur l'écran de démarrage de votre application sur "
253
+ "les appareils compatibles. Ça doit être une image <code>PNG</code> "
254
+ "d'exactement <code>512x512</code> pixels."
255
+
256
+ #: admin/admin-ui-render-settings.php:151
257
+ msgid "Background color of the splash screen."
258
+ msgstr "Couleur d’arrière-plan de l’écran de démarrage."
259
+
260
+ #: admin/admin-ui-render-settings.php:171
261
+ msgid ""
262
+ "Theme color is used on supported devices to tint the UI elements of the "
263
+ "browser and app switcher. When in doubt, use the same color as "
264
+ "<code>Background Color</code>."
265
+ msgstr ""
266
+ "La couleur du thème est utilisée sur les appareils pris en charge pour "
267
+ "personnaliser la teinte des éléments d’interface utilisateur du navigateur "
268
+ "et du switcher d’app. En cas de doute, utilisez la même couleur que la "
269
+ "<code>Couleur d’arrière-plan</code>."
270
+
271
+ #: admin/admin-ui-render-settings.php:194
272
+ msgid "&mdash; Homepage &mdash;"
273
+ msgstr "&mdash; Page d’accueil &mdash;"
274
+
275
+ #: admin/admin-ui-render-settings.php:201
276
+ msgid ""
277
+ "Specify the page to load when the application is launched from a device. "
278
+ "Current start page is <code>%s</code>"
279
+ msgstr ""
280
+ "Spécifiez la page à charger lorsque l'application est lancée à partir d'un "
281
+ "appareil. La page d'accueil actuelle est <code>%s</code>"
282
+
283
+ #: admin/admin-ui-render-settings.php:209
284
+ msgid "Use AMP version of the start page."
285
+ msgstr "Utiliser la version AMP de la page de démarrage."
286
+
287
+ #: admin/admin-ui-render-settings.php:215
288
+ msgid ""
289
+ "Do not check this if your start page is the homepage, the blog index, or the "
290
+ "archives page. AMP for WordPress does not create AMP versions for these "
291
+ "pages."
292
+ msgstr ""
293
+ "Ne cochez pas cette case si votre page de départ est la page d'accueil de "
294
+ "votre site, l'index du blog ou la page d'archives. AMP pour WordPress ne "
295
+ "crée pas de versions AMP pour ces pages."
296
+
297
+ #: admin/admin-ui-render-settings.php:241
298
+ msgid "&mdash; Default &mdash;"
299
+ msgstr "&mdash; Par défaut &mdash;"
300
+
301
+ #: admin/admin-ui-render-settings.php:248
302
+ msgid ""
303
+ "Offline page is displayed when the device is offline and the requested page "
304
+ "is not already cached. Current offline page is <code>%s</code>"
305
+ msgstr ""
306
+ "La page hors connexion s’affiche lorsque l'appareil est hors connexion et "
307
+ "que la page demandée n’est pas déjà mise en cache. La page hors connexion "
308
+ "actuelle est <code>%s</code>"
309
+
310
+ #: admin/admin-ui-render-settings.php:268
311
+ msgid "Follow Device Orientation"
312
+ msgstr "Suivre l'orientation de l'appareil"
313
+
314
+ #: admin/admin-ui-render-settings.php:271
315
+ msgid "Portrait"
316
+ msgstr "Portrait"
317
+
318
+ #: admin/admin-ui-render-settings.php:274
319
+ msgid "Landscape"
320
+ msgstr "Paysage"
321
+
322
+ #: admin/admin-ui-render-settings.php:280
323
+ msgid ""
324
+ "Set the orientation of your app on devices. When set to <code>Follow Device "
325
+ "Orientation</code> your app will rotate as the device is rotated."
326
+ msgstr ""
327
+ "Définissez l'orientation de votre application sur les appareils. Lorsque "
328
+ "l'option <code>Suivre l'orientation de l'appareil</code> est définie, votre "
329
+ "application tourne en fonction de l'appareil."
330
+
331
+ #: admin/admin-ui-render-settings.php:302
332
+ msgid ""
333
+ "Manifest generated successfully. You can <a href=\"%s\" target=\"_blank"
334
+ "\">see it here &rarr;</a>"
335
+ msgstr ""
336
+ "Le manifeste a été généré avec succès. Vous pouvez <a href=\"%s\" target="
337
+ "\"_blank\">le voir ici &rarr;</a>"
338
+
339
+ #: admin/admin-ui-render-settings.php:305
340
+ msgid ""
341
+ "Manifest generation failed. Check if WordPress can write to your root folder "
342
+ "(the same folder with wp-config.php). <a href=\"%s\" target=\"_blank\">Read "
343
+ "more &rarr;</a>"
344
+ msgstr ""
345
+ "Échec de génération du manifeste. Vérifiez si WordPress peut écrire dans "
346
+ "votre dossier racine (même dossier que wp-config.php). <a href=\"%s\" target="
347
+ "\"_blank\">En savoir plux &rarr;</a>"
348
+
349
+ #: admin/admin-ui-render-settings.php:320
350
+ msgid "Service worker generated successfully."
351
+ msgstr "Service Worker généré avec succès."
352
+
353
+ #: admin/admin-ui-render-settings.php:323
354
+ msgid ""
355
+ "Service worker generation failed. Check if WordPress can write to your root "
356
+ "folder (the same folder with wp-config.php). <a href=\"%s\" target=\"_blank"
357
+ "\">Read more &rarr;</a>"
358
+ msgstr ""
359
+ "La génération de Service Worker a échouée. Vérifiez si WordPress peut écrire "
360
+ "dans votre dossier racine (même dossier que wp-config.php). <a href=\"%s\" "
361
+ "target=\"_blank\">En savoir plus &rarr;</a>"
362
+
363
+ #: admin/admin-ui-render-settings.php:336
364
+ msgid "Your website is served over HTTPS."
365
+ msgstr "Votre site Web est servi via HTTPS."
366
+
367
+ #: admin/admin-ui-render-settings.php:339
368
+ msgid ""
369
+ "Progressive Web Apps require that your website is served over HTTPS. Please "
370
+ "contact your host to add a SSL certificate to your domain."
371
+ msgstr ""
372
+ "Les applications Web progressives exigent que votre site est desservie via "
373
+ "HTTPS. Contactez votre hébergeur pour ajouter un certificat SSL à votre "
374
+ "domaine."
375
+
376
+ #. Author of the plugin/theme
377
+ #: admin/admin-ui-setup.php:28
378
+ msgid "SuperPWA"
379
+ msgstr "SuperPWA"
380
+
381
+ #: admin/admin-ui-setup.php:31 admin/basic-setup.php:278
382
+ msgid "Settings"
383
+ msgstr "Réglages"
384
+
385
+ #: admin/admin-ui-setup.php:34
386
+ msgid "Add-Ons"
387
+ msgstr "Add-ons"
388
+
389
+ #: admin/admin-ui-setup.php:63
390
+ msgid "Application Name"
391
+ msgstr "Nom de l’application"
392
+
393
+ #: admin/admin-ui-setup.php:72
394
+ msgid "Application Short Name"
395
+ msgstr "Nom court de l’application"
396
+
397
+ #: admin/admin-ui-setup.php:81
398
+ msgid "Description"
399
+ msgstr "Description"
400
+
401
+ #: admin/admin-ui-setup.php:90
402
+ msgid "Application Icon"
403
+ msgstr "Icône de l’application"
404
+
405
+ #: admin/admin-ui-setup.php:99
406
+ msgid "Splash Screen Icon"
407
+ msgstr "Icône de l’écran de démarrage"
408
+
409
+ #: admin/admin-ui-setup.php:108
410
+ msgid "Background Color"
411
+ msgstr "Couleur d'arrière plan"
412
+
413
+ #: admin/admin-ui-setup.php:117
414
+ msgid "Theme Color"
415
+ msgstr "Couleur du thème"
416
+
417
+ #: admin/admin-ui-setup.php:126
418
+ msgid "Start Page"
419
+ msgstr "Page de départ"
420
+
421
+ #: admin/admin-ui-setup.php:135
422
+ msgid "Offline Page"
423
+ msgstr "Page hors ligne"
424
+
425
+ #: admin/admin-ui-setup.php:144
426
+ msgid "Orientation"
427
+ msgstr "Orientation"
428
+
429
+ #: admin/admin-ui-setup.php:153
430
+ msgid "Status"
431
+ msgstr "Statut"
432
+
433
+ #: admin/admin-ui-setup.php:161
434
+ msgid "Manifest"
435
+ msgstr "Manifeste"
436
+
437
+ #: admin/admin-ui-setup.php:170
438
+ msgid "Service Worker"
439
+ msgstr "Service Worker"
440
+
441
+ #: admin/admin-ui-setup.php:179
442
+ msgid "HTTPS"
443
+ msgstr "HTTPS"
444
+
445
+ #: admin/admin-ui-setup.php:305
446
+ msgid ""
447
+ "If you like SuperPWA, please <a href=\"%s\" target=\"_blank\">make a "
448
+ "donation</a> or leave a <a href=\"%s\" target=\"_blank\">&#9733;&#9733;"
449
+ "&#9733;&#9733;&#9733;</a> rating to support continued development. Thanks a "
450
+ "bunch!"
451
+ msgstr ""
452
+ "Si vous aimez SuperPWA, <a href=\"%s\" target=\"_blank\">faites un don</a> "
453
+ "ou laissez une note <a href=\"%s\" target=\"_blank\">&#9733;&#9733;&#9733;"
454
+ "&#9733;&#9733;</a> pour soutenir son développement. Merci beaucoup !"
455
+
456
+ #: admin/basic-setup.php:82 admin/basic-setup.php:116
457
+ msgid ""
458
+ "<strong>SuperPWA</strong>: Successfully updated to version %s. Thank you! <a "
459
+ "href=\"%s\" target=\"_blank\">Discover new features and read the story &rarr;"
460
+ "</a>"
461
+ msgstr ""
462
+ "<strong>SuperPWA</strong>: Succès de la mise à jour vers la version %s. "
463
+ "Merci ! <a href=\"%s\" target=\"_blank\">Découvrez les nouvelles "
464
+ "fonctionnalités et lisez notre histoire &rarr;</a>"
465
+
466
+ #: admin/basic-setup.php:294
467
+ msgid "Demo"
468
+ msgstr "Démo"
469
+
470
+ #. Plugin URI of the plugin/theme
471
+ msgid "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=plugin-uri"
472
+ msgstr "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=plugin-uri"
473
+
474
+ #. Description of the plugin/theme
475
+ msgid "Convert your WordPress website into a Progressive Web App"
476
+ msgstr "Transformer votre site WordPress en une application Web progressive"
477
+
478
+ #. Author URI of the plugin/theme
479
+ msgid "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=author-uri"
480
+ msgstr "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=author-uri"
license.txt CHANGED
@@ -1,281 +1,281 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 2, June 1991
3
-
4
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
- 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
6
-
7
- Everyone is permitted to copy and distribute verbatim copies
8
- of this license document, but changing it is not allowed.
9
-
10
- Preamble
11
-
12
- The licenses for most software are designed to take away your
13
- freedom to share and change it. By contrast, the GNU General Public
14
- License is intended to guarantee your freedom to share and change free
15
- software--to make sure the software is free for all its users. This
16
- General Public License applies to most of the Free Software
17
- Foundation's software and to any other program whose authors commit to
18
- using it. (Some other Free Software Foundation software is covered by
19
- the GNU Library General Public License instead.) You can apply it to
20
- your programs, too.
21
-
22
- When we speak of free software, we are referring to freedom, not
23
- price. Our General Public Licenses are designed to make sure that you
24
- have the freedom to distribute copies of free software (and charge for
25
- this service if you wish), that you receive source code or can get it
26
- if you want it, that you can change the software or use pieces of it
27
- in new free programs; and that you know you can do these things.
28
-
29
- To protect your rights, we need to make restrictions that forbid
30
- anyone to deny you these rights or to ask you to surrender the rights.
31
- These restrictions translate to certain responsibilities for you if you
32
- distribute copies of the software, or if you modify it.
33
-
34
- For example, if you distribute copies of such a program, whether
35
- gratis or for a fee, you must give the recipients all the rights that
36
- you have. You must make sure that they, too, receive or can get the
37
- source code. And you must show them these terms so they know their
38
- rights.
39
-
40
- We protect your rights with two steps: (1) copyright the software, and
41
- (2) offer you this license which gives you legal permission to copy,
42
- distribute and/or modify the software.
43
-
44
- Also, for each author's protection and ours, we want to make certain
45
- that everyone understands that there is no warranty for this free
46
- software. If the software is modified by someone else and passed on, we
47
- want its recipients to know that what they have is not the original, so
48
- that any problems introduced by others will not reflect on the original
49
- authors' reputations.
50
-
51
- Finally, any free program is threatened constantly by software
52
- patents. We wish to avoid the danger that redistributors of a free
53
- program will individually obtain patent licenses, in effect making the
54
- program proprietary. To prevent this, we have made it clear that any
55
- patent must be licensed for everyone's free use or not licensed at all.
56
-
57
- The precise terms and conditions for copying, distribution and
58
- modification follow.
59
-
60
- GNU GENERAL PUBLIC LICENSE
61
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
62
-
63
- 0. This License applies to any program or other work which contains
64
- a notice placed by the copyright holder saying it may be distributed
65
- under the terms of this General Public License. The "Program", below,
66
- refers to any such program or work, and a "work based on the Program"
67
- means either the Program or any derivative work under copyright law:
68
- that is to say, a work containing the Program or a portion of it,
69
- either verbatim or with modifications and/or translated into another
70
- language. (Hereinafter, translation is included without limitation in
71
- the term "modification".) Each licensee is addressed as "you".
72
-
73
- Activities other than copying, distribution and modification are not
74
- covered by this License; they are outside its scope. The act of
75
- running the Program is not restricted, and the output from the Program
76
- is covered only if its contents constitute a work based on the
77
- Program (independent of having been made by running the Program).
78
- Whether that is true depends on what the Program does.
79
-
80
- 1. You may copy and distribute verbatim copies of the Program's
81
- source code as you receive it, in any medium, provided that you
82
- conspicuously and appropriately publish on each copy an appropriate
83
- copyright notice and disclaimer of warranty; keep intact all the
84
- notices that refer to this License and to the absence of any warranty;
85
- and give any other recipients of the Program a copy of this License
86
- along with the Program.
87
-
88
- You may charge a fee for the physical act of transferring a copy, and
89
- you may at your option offer warranty protection in exchange for a fee.
90
-
91
- 2. You may modify your copy or copies of the Program or any portion
92
- of it, thus forming a work based on the Program, and copy and
93
- distribute such modifications or work under the terms of Section 1
94
- above, provided that you also meet all of these conditions:
95
-
96
- a) You must cause the modified files to carry prominent notices
97
- stating that you changed the files and the date of any change.
98
-
99
- b) You must cause any work that you distribute or publish, that in
100
- whole or in part contains or is derived from the Program or any
101
- part thereof, to be licensed as a whole at no charge to all third
102
- parties under the terms of this License.
103
-
104
- c) If the modified program normally reads commands interactively
105
- when run, you must cause it, when started running for such
106
- interactive use in the most ordinary way, to print or display an
107
- announcement including an appropriate copyright notice and a
108
- notice that there is no warranty (or else, saying that you provide
109
- a warranty) and that users may redistribute the program under
110
- these conditions, and telling the user how to view a copy of this
111
- License. (Exception: if the Program itself is interactive but
112
- does not normally print such an announcement, your work based on
113
- the Program is not required to print an announcement.)
114
-
115
- These requirements apply to the modified work as a whole. If
116
- identifiable sections of that work are not derived from the Program,
117
- and can be reasonably considered independent and separate works in
118
- themselves, then this License, and its terms, do not apply to those
119
- sections when you distribute them as separate works. But when you
120
- distribute the same sections as part of a whole which is a work based
121
- on the Program, the distribution of the whole must be on the terms of
122
- this License, whose permissions for other licensees extend to the
123
- entire whole, and thus to each and every part regardless of who wrote it.
124
- Thus, it is not the intent of this section to claim rights or contest
125
- your rights to work written entirely by you; rather, the intent is to
126
- exercise the right to control the distribution of derivative or
127
- collective works based on the Program.
128
-
129
- In addition, mere aggregation of another work not based on the Program
130
- with the Program (or with a work based on the Program) on a volume of
131
- a storage or distribution medium does not bring the other work under
132
- the scope of this License.
133
-
134
- 3. You may copy and distribute the Program (or a work based on it,
135
- under Section 2) in object code or executable form under the terms of
136
- Sections 1 and 2 above provided that you also do one of the following:
137
-
138
- a) Accompany it with the complete corresponding machine-readable
139
- source code, which must be distributed under the terms of Sections
140
- 1 and 2 above on a medium customarily used for software interchange; or,
141
-
142
- b) Accompany it with a written offer, valid for at least three
143
- years, to give any third party, for a charge no more than your
144
- cost of physically performing source distribution, a complete
145
- machine-readable copy of the corresponding source code, to be
146
- distributed under the terms of Sections 1 and 2 above on a medium
147
- customarily used for software interchange; or,
148
-
149
- c) Accompany it with the information you received as to the offer
150
- to distribute corresponding source code. (This alternative is
151
- allowed only for noncommercial distribution and only if you
152
- received the program in object code or executable form with such
153
- an offer, in accord with Subsection b above.)
154
-
155
- The source code for a work means the preferred form of the work for
156
- making modifications to it. For an executable work, complete source
157
- code means all the source code for all modules it contains, plus any
158
- associated interface definition files, plus the scripts used to
159
- control compilation and installation of the executable. However, as a
160
- special exception, the source code distributed need not include
161
- anything that is normally distributed (in either source or binary
162
- form) with the major components (compiler, kernel, and so on) of the
163
- operating system on which the executable runs, unless that component
164
- itself accompanies the executable.
165
-
166
- If distribution of executable or object code is made by offering
167
- access to copy from a designated place, then offering equivalent
168
- access to copy the source code from the same place counts as
169
- distribution of the source code, even though third parties are not
170
- compelled to copy the source along with the object code.
171
-
172
- 4. You may not copy, modify, sublicense, or distribute the Program
173
- except as expressly provided under this License. Any attempt
174
- otherwise to copy, modify, sublicense or distribute the Program is
175
- void, and will automatically terminate your rights under this License.
176
- However, parties who have received copies, or rights, from you under
177
- this License will not have their licenses terminated so long as such
178
- parties remain in full compliance.
179
-
180
- 5. You are not required to accept this License, since you have not
181
- signed it. However, nothing else grants you permission to modify or
182
- distribute the Program or its derivative works. These actions are
183
- prohibited by law if you do not accept this License. Therefore, by
184
- modifying or distributing the Program (or any work based on the
185
- Program), you indicate your acceptance of this License to do so, and
186
- all its terms and conditions for copying, distributing or modifying
187
- the Program or works based on it.
188
-
189
- 6. Each time you redistribute the Program (or any work based on the
190
- Program), the recipient automatically receives a license from the
191
- original licensor to copy, distribute or modify the Program subject to
192
- these terms and conditions. You may not impose any further
193
- restrictions on the recipients' exercise of the rights granted herein.
194
- You are not responsible for enforcing compliance by third parties to
195
- this License.
196
-
197
- 7. If, as a consequence of a court judgment or allegation of patent
198
- infringement or for any other reason (not limited to patent issues),
199
- conditions are imposed on you (whether by court order, agreement or
200
- otherwise) that contradict the conditions of this License, they do not
201
- excuse you from the conditions of this License. If you cannot
202
- distribute so as to satisfy simultaneously your obligations under this
203
- License and any other pertinent obligations, then as a consequence you
204
- may not distribute the Program at all. For example, if a patent
205
- license would not permit royalty-free redistribution of the Program by
206
- all those who receive copies directly or indirectly through you, then
207
- the only way you could satisfy both it and this License would be to
208
- refrain entirely from distribution of the Program.
209
-
210
- If any portion of this section is held invalid or unenforceable under
211
- any particular circumstance, the balance of the section is intended to
212
- apply and the section as a whole is intended to apply in other
213
- circumstances.
214
-
215
- It is not the purpose of this section to induce you to infringe any
216
- patents or other property right claims or to contest validity of any
217
- such claims; this section has the sole purpose of protecting the
218
- integrity of the free software distribution system, which is
219
- implemented by public license practices. Many people have made
220
- generous contributions to the wide range of software distributed
221
- through that system in reliance on consistent application of that
222
- system; it is up to the author/donor to decide if he or she is willing
223
- to distribute software through any other system and a licensee cannot
224
- impose that choice.
225
-
226
- This section is intended to make thoroughly clear what is believed to
227
- be a consequence of the rest of this License.
228
-
229
- 8. If the distribution and/or use of the Program is restricted in
230
- certain countries either by patents or by copyrighted interfaces, the
231
- original copyright holder who places the Program under this License
232
- may add an explicit geographical distribution limitation excluding
233
- those countries, so that distribution is permitted only in or among
234
- countries not thus excluded. In such case, this License incorporates
235
- the limitation as if written in the body of this License.
236
-
237
- 9. The Free Software Foundation may publish revised and/or new versions
238
- of the General Public License from time to time. Such new versions will
239
- be similar in spirit to the present version, but may differ in detail to
240
- address new problems or concerns.
241
-
242
- Each version is given a distinguishing version number. If the Program
243
- specifies a version number of this License which applies to it and "any
244
- later version", you have the option of following the terms and conditions
245
- either of that version or of any later version published by the Free
246
- Software Foundation. If the Program does not specify a version number of
247
- this License, you may choose any version ever published by the Free Software
248
- Foundation.
249
-
250
- 10. If you wish to incorporate parts of the Program into other free
251
- programs whose distribution conditions are different, write to the author
252
- to ask for permission. For software which is copyrighted by the Free
253
- Software Foundation, write to the Free Software Foundation; we sometimes
254
- make exceptions for this. Our decision will be guided by the two goals
255
- of preserving the free status of all derivatives of our free software and
256
- of promoting the sharing and reuse of software generally.
257
-
258
- NO WARRANTY
259
-
260
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
- FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
- PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
- OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
- TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
- REPAIR OR CORRECTION.
269
-
270
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
- REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
- INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
- OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
- TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
- YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
- PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
- POSSIBILITY OF SUCH DAMAGES.
279
-
280
- END OF TERMS AND CONDITIONS
281
-
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+ 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
6
+
7
+ Everyone is permitted to copy and distribute verbatim copies
8
+ of this license document, but changing it is not allowed.
9
+
10
+ Preamble
11
+
12
+ The licenses for most software are designed to take away your
13
+ freedom to share and change it. By contrast, the GNU General Public
14
+ License is intended to guarantee your freedom to share and change free
15
+ software--to make sure the software is free for all its users. This
16
+ General Public License applies to most of the Free Software
17
+ Foundation's software and to any other program whose authors commit to
18
+ using it. (Some other Free Software Foundation software is covered by
19
+ the GNU Library General Public License instead.) You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ this service if you wish), that you receive source code or can get it
26
+ if you want it, that you can change the software or use pieces of it
27
+ in new free programs; and that you know you can do these things.
28
+
29
+ To protect your rights, we need to make restrictions that forbid
30
+ anyone to deny you these rights or to ask you to surrender the rights.
31
+ These restrictions translate to certain responsibilities for you if you
32
+ distribute copies of the software, or if you modify it.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must give the recipients all the rights that
36
+ you have. You must make sure that they, too, receive or can get the
37
+ source code. And you must show them these terms so they know their
38
+ rights.
39
+
40
+ We protect your rights with two steps: (1) copyright the software, and
41
+ (2) offer you this license which gives you legal permission to copy,
42
+ distribute and/or modify the software.
43
+
44
+ Also, for each author's protection and ours, we want to make certain
45
+ that everyone understands that there is no warranty for this free
46
+ software. If the software is modified by someone else and passed on, we
47
+ want its recipients to know that what they have is not the original, so
48
+ that any problems introduced by others will not reflect on the original
49
+ authors' reputations.
50
+
51
+ Finally, any free program is threatened constantly by software
52
+ patents. We wish to avoid the danger that redistributors of a free
53
+ program will individually obtain patent licenses, in effect making the
54
+ program proprietary. To prevent this, we have made it clear that any
55
+ patent must be licensed for everyone's free use or not licensed at all.
56
+
57
+ The precise terms and conditions for copying, distribution and
58
+ modification follow.
59
+
60
+ GNU GENERAL PUBLIC LICENSE
61
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
62
+
63
+ 0. This License applies to any program or other work which contains
64
+ a notice placed by the copyright holder saying it may be distributed
65
+ under the terms of this General Public License. The "Program", below,
66
+ refers to any such program or work, and a "work based on the Program"
67
+ means either the Program or any derivative work under copyright law:
68
+ that is to say, a work containing the Program or a portion of it,
69
+ either verbatim or with modifications and/or translated into another
70
+ language. (Hereinafter, translation is included without limitation in
71
+ the term "modification".) Each licensee is addressed as "you".
72
+
73
+ Activities other than copying, distribution and modification are not
74
+ covered by this License; they are outside its scope. The act of
75
+ running the Program is not restricted, and the output from the Program
76
+ is covered only if its contents constitute a work based on the
77
+ Program (independent of having been made by running the Program).
78
+ Whether that is true depends on what the Program does.
79
+
80
+ 1. You may copy and distribute verbatim copies of the Program's
81
+ source code as you receive it, in any medium, provided that you
82
+ conspicuously and appropriately publish on each copy an appropriate
83
+ copyright notice and disclaimer of warranty; keep intact all the
84
+ notices that refer to this License and to the absence of any warranty;
85
+ and give any other recipients of the Program a copy of this License
86
+ along with the Program.
87
+
88
+ You may charge a fee for the physical act of transferring a copy, and
89
+ you may at your option offer warranty protection in exchange for a fee.
90
+
91
+ 2. You may modify your copy or copies of the Program or any portion
92
+ of it, thus forming a work based on the Program, and copy and
93
+ distribute such modifications or work under the terms of Section 1
94
+ above, provided that you also meet all of these conditions:
95
+
96
+ a) You must cause the modified files to carry prominent notices
97
+ stating that you changed the files and the date of any change.
98
+
99
+ b) You must cause any work that you distribute or publish, that in
100
+ whole or in part contains or is derived from the Program or any
101
+ part thereof, to be licensed as a whole at no charge to all third
102
+ parties under the terms of this License.
103
+
104
+ c) If the modified program normally reads commands interactively
105
+ when run, you must cause it, when started running for such
106
+ interactive use in the most ordinary way, to print or display an
107
+ announcement including an appropriate copyright notice and a
108
+ notice that there is no warranty (or else, saying that you provide
109
+ a warranty) and that users may redistribute the program under
110
+ these conditions, and telling the user how to view a copy of this
111
+ License. (Exception: if the Program itself is interactive but
112
+ does not normally print such an announcement, your work based on
113
+ the Program is not required to print an announcement.)
114
+
115
+ These requirements apply to the modified work as a whole. If
116
+ identifiable sections of that work are not derived from the Program,
117
+ and can be reasonably considered independent and separate works in
118
+ themselves, then this License, and its terms, do not apply to those
119
+ sections when you distribute them as separate works. But when you
120
+ distribute the same sections as part of a whole which is a work based
121
+ on the Program, the distribution of the whole must be on the terms of
122
+ this License, whose permissions for other licensees extend to the
123
+ entire whole, and thus to each and every part regardless of who wrote it.
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
loader.php CHANGED
@@ -1,31 +1,31 @@
1
- <?php
2
- /**
3
- * Loads the plugin files
4
- *
5
- * @since 1.0
6
- */
7
-
8
- // Exit if accessed directly
9
- if ( ! defined('ABSPATH') ) exit;
10
-
11
- // Load admin
12
- require_once( SUPERPWA_PATH_ABS . 'admin/basic-setup.php' );
13
- require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-setup.php' );
14
- require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-settings.php' );
15
- require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-addons.php' );
16
-
17
- // 3rd party compatibility
18
- require_once( SUPERPWA_PATH_ABS . '3rd-party/onesignal.php' );
19
-
20
- // Load functions
21
- require_once( SUPERPWA_PATH_ABS . 'functions/common.php' );
22
- require_once( SUPERPWA_PATH_ABS . 'functions/filesystem.php' );
23
- require_once( SUPERPWA_PATH_ABS . 'functions/multisite.php' );
24
-
25
- // Public folder
26
- require_once( SUPERPWA_PATH_ABS . 'public/manifest.php' );
27
- require_once( SUPERPWA_PATH_ABS . 'public/sw.php' );
28
-
29
- // Load bundled add-ons
30
- if ( superpwa_addons_status( 'utm_tracking' ) == 'active' ) require_once( SUPERPWA_PATH_ABS . 'addons/utm-tracking.php' );
31
  if ( superpwa_addons_status( 'apple_touch_icons' ) == 'active' ) require_once( SUPERPWA_PATH_ABS . 'addons/apple-touch-icons.php' );
1
+ <?php
2
+ /**
3
+ * Loads the plugin files
4
+ *
5
+ * @since 1.0
6
+ */
7
+
8
+ // Exit if accessed directly
9
+ if ( ! defined('ABSPATH') ) exit;
10
+
11
+ // Load admin
12
+ require_once( SUPERPWA_PATH_ABS . 'admin/basic-setup.php' );
13
+ require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-setup.php' );
14
+ require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-settings.php' );
15
+ require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-addons.php' );
16
+
17
+ // 3rd party compatibility
18
+ require_once( SUPERPWA_PATH_ABS . '3rd-party/onesignal.php' );
19
+
20
+ // Load functions
21
+ require_once( SUPERPWA_PATH_ABS . 'functions/common.php' );
22
+ require_once( SUPERPWA_PATH_ABS . 'functions/filesystem.php' );
23
+ require_once( SUPERPWA_PATH_ABS . 'functions/multisite.php' );
24
+
25
+ // Public folder
26
+ require_once( SUPERPWA_PATH_ABS . 'public/manifest.php' );
27
+ require_once( SUPERPWA_PATH_ABS . 'public/sw.php' );
28
+
29
+ // Load bundled add-ons
30
+ if ( superpwa_addons_status( 'utm_tracking' ) == 'active' ) require_once( SUPERPWA_PATH_ABS . 'addons/utm-tracking.php' );
31
  if ( superpwa_addons_status( 'apple_touch_icons' ) == 'active' ) require_once( SUPERPWA_PATH_ABS . 'addons/apple-touch-icons.php' );
phpcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0"?>
2
- <ruleset name="Super Progressive Web Apps">
3
- <description>Super Progressive Web Apps coding standard</description>
4
-
5
- <rule ref="WordPress-Extra"/>
6
- </ruleset>
 
 
 
 
 
 
public/images/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
public/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
public/js/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
  // Silence is golden
1
+ <?php
2
  // Silence is golden
public/js/register-sw.js CHANGED
@@ -1,7 +1,7 @@
1
- if ('serviceWorker' in navigator) {
2
- window.addEventListener('load', function() {
3
- navigator.serviceWorker.register(superpwa_sw.url)
4
- .then(function(registration) { console.log('SuperPWA service worker ready'); registration.update(); })
5
- .catch(function(error) { console.log('Registration failed with ' + error); });
6
- });
7
  }
1
+ if ('serviceWorker' in navigator) {
2
+ window.addEventListener('load', function() {
3
+ navigator.serviceWorker.register(superpwa_sw.url)
4
+ .then(function(registration) { console.log('SuperPWA service worker ready'); registration.update(); })
5
+ .catch(function(error) { console.log('Registration failed with ' + error); });
6
+ });
7
  }
public/manifest.php CHANGED
@@ -1,348 +1,354 @@
1
- <?php
2
- /**
3
- * Manifest related functions of SuperPWA
4
- *
5
- * @since 1.0
6
- *
7
- * @function superpwa_manifest() Manifest filename, absolute path and link
8
- * @function superpwa_generate_manifest() Generate and write manifest
9
- * @function superpwa_add_manifest_to_wp_head() Add manifest to header (wp_head)
10
- * @function superpwa_register_service_worker() Register service worker in the footer (wp_footer)
11
- * @function superpwa_delete_manifest() Delete manifest
12
- * @function superpwa_get_pwa_icons() Get PWA Icons
13
- * @function superpwa_get_scope() Get navigation scope of PWA
14
- * @function superpwa_get_orientation() Get orientation of PWA
15
- * @function superpwa_get_display() Get display of PWA
16
- */
17
-
18
- // Exit if accessed directly
19
- if ( ! defined( 'ABSPATH' ) ) exit;
20
-
21
- /**
22
- * Returns the Manifest filename.
23
- *
24
- * @since 2.0
25
- *
26
- * @return string
27
- */
28
- function superpwa_get_manifest_filename() {
29
- return 'superpwa-manifest' . superpwa_multisite_filename_postfix() . '.json';
30
- }
31
-
32
- /**
33
- * Manifest filename, absolute path and link
34
- *
35
- * For Multisite compatibility. Used to be constants defined in superpwa.php
36
- * On a multisite, each sub-site needs a different manifest file.
37
- *
38
- * @uses superpwa_get_manifest_filename()
39
- *
40
- * @param $arg filename for manifest filename (replaces SUPERPWA_MANIFEST_FILENAME)
41
- * abs for absolute path to manifest (replaces SUPERPWA_MANIFEST_ABS)
42
- * src for link to manifest (replaces SUPERPWA_MANIFEST_SRC). Default value
43
- *
44
- * @return String filename, absolute path or link to manifest.
45
- *
46
- * @since 1.6
47
- * @since 2.0 src uses home_url instead of network_site_url since manifest is no longer in the root folder.
48
- */
49
- function superpwa_manifest( $arg = 'src' ) {
50
-
51
- $manifest_filename = superpwa_get_manifest_filename();
52
-
53
- switch ( $arg ) {
54
- // TODO: Case `filename` can be deprecated in favor of @see superpwa_get_manifest_filename().
55
- // Name of Manifest file
56
- case 'filename':
57
- return $manifest_filename;
58
- break;
59
-
60
- /**
61
- * Absolute path to manifest.
62
- *
63
- * Note: @since 2.0 manifest is no longer a physical file and absolute path doesn't make sense.
64
- * Also using home_url instead of network_site_url in "src" in 2.0 changes the apparent location of the file.
65
- * However, absolute path is preserved at the "old" location, so that phyiscal files can be deleted when upgrading from pre-2.0 versions.
66
- *
67
- * Since static files are being used in conditions where dynamic files are not possible, this path
68
- * pointing to the root folder of WordPress is still useful.
69
- */
70
- case 'abs':
71
- return trailingslashit( ABSPATH ) . $manifest_filename;
72
- break;
73
-
74
- // Link to manifest
75
- case 'src':
76
- default:
77
-
78
- // Get Settings
79
- $settings = superpwa_get_settings();
80
-
81
- /**
82
- * For static file, return site_url and network_site_url
83
- *
84
- * Static files are generated in the root directory.
85
- * The site_url template tag retrieves the site url for the
86
- * current site (where the WordPress core files reside).
87
- */
88
- if ( $settings['is_static_manifest'] === 1 ) {
89
- return trailingslashit( network_site_url() ) . $manifest_filename;
90
- }
91
-
92
- // For dynamic files, return the home_url
93
- return home_url( '/' ) . $manifest_filename;
94
-
95
- break;
96
- }
97
- }
98
-
99
- /**
100
- * Returns the Manifest template.
101
- *
102
- * @author Maria Daniel Deepak <daniel@danieldeepak.com>
103
- *
104
- * @return array
105
- *
106
- * @since 2.0 Replaces superpwa_generate_manifest()
107
- * @since 2.0 Added display
108
- */
109
- function superpwa_manifest_template() {
110
-
111
- // Get Settings
112
- $settings = superpwa_get_settings();
113
-
114
- $manifest = array();
115
- $manifest['name'] = $settings['app_name'];
116
- $manifest['short_name'] = $settings['app_short_name'];
117
-
118
- // Description
119
- if ( isset( $settings['description'] ) && ! empty( $settings['description'] ) ) {
120
- $manifest['description'] = $settings['description'];
121
- }
122
-
123
- $manifest['icons'] = superpwa_get_pwa_icons();
124
- $manifest['background_color'] = $settings['background_color'];
125
- $manifest['theme_color'] = $settings['theme_color'];
126
- $manifest['display'] = superpwa_get_display();
127
- $manifest['orientation'] = superpwa_get_orientation();
128
- $manifest['start_url'] = superpwa_get_start_url( true );
129
- $manifest['scope'] = superpwa_get_scope();
130
-
131
- /**
132
- * Values that go in to Manifest JSON.
133
- *
134
- * The Web app manifest is a simple JSON file that tells the browser about your web application.
135
- *
136
- * @param array $manifest
137
- */
138
- return apply_filters( 'superpwa_manifest', $manifest );
139
- }
140
-
141
- /**
142
- * Generate and write manifest into WordPress root folder
143
- *
144
- * Starting with 2.0, files are only generated if dynamic files are not possible.
145
- * Some webserver configurations does not load WordPress and attempts to server files directly
146
- * from the server. This returns 404 when files do not exist physically.
147
- *
148
- * @return (boolean) true on success, false on failure.
149
- *
150
- * @author Arun Basil Lal
151
- * @author Maria Daniel Deepak <daniel@danieldeepak.com>
152
- *
153
- * @since 1.0
154
- * @since 1.3 Added support for 512x512 icon.
155
- * @since 1.4 Added orientation and scope.
156
- * @since 1.5 Added gcm_sender_id
157
- * @since 1.6 Added description
158
- * @since 1.8 Removed gcm_sender_id and introduced filter superpwa_manifest. gcm_sender_id is added in /3rd-party/onesignal.php
159
- * @since 2.0 Deprecated since Manifest is generated on the fly {@see superpwa_generate_sw_and_manifest_on_fly()}.
160
- * @since 2.0.1 No longer deprecated since physical files are now generated in certain cases. See funtion description.
161
- */
162
- function superpwa_generate_manifest() {
163
-
164
- // Delete manifest if it exists.
165
- superpwa_delete_manifest();
166
-
167
- // Get Settings
168
- $settings = superpwa_get_settings();
169
-
170
- // Return true if dynamic file returns a 200 response.
171
- if ( superpwa_file_exists( home_url( '/' ) . superpwa_get_manifest_filename() ) && defined( 'WP_CACHE' ) && ! WP_CACHE ) {
172
-
173
- // set file status as dynamic file in database.
174
- $settings['is_static_manifest'] = 0;
175
-
176
- // Write settings back to database.
177
- update_option( 'superpwa_settings', $settings );
178
-
179
- return true;
180
- }
181
-
182
- // Write the manfiest to disk.
183
- if ( superpwa_put_contents( superpwa_manifest( 'abs' ), json_encode( superpwa_manifest_template() ) ) ) {
184
-
185
- // set file status as satic file in database.
186
- $settings['is_static_manifest'] = 1;
187
-
188
- // Write settings back to database.
189
- update_option( 'superpwa_settings', $settings );
190
-
191
- return true;
192
- }
193
-
194
- return false;
195
- }
196
-
197
- /**
198
- * Add manifest to header (wp_head)
199
- *
200
- * @since 1.0
201
- * @since 1.8 Introduced filter superpwa_wp_head_tags
202
- * @since 1.9 Introduced filter superpwa_add_theme_color
203
- */
204
- function superpwa_add_manifest_to_wp_head() {
205
-
206
- $tags = '<!-- Manifest added by SuperPWA - Progressive Web Apps Plugin For WordPress -->' . PHP_EOL;
207
- $tags .= '<link rel="manifest" href="'. parse_url( superpwa_manifest( 'src' ), PHP_URL_PATH ) . '">' . PHP_EOL;
208
-
209
- // theme-color meta tag
210
- if ( apply_filters( 'superpwa_add_theme_color', true ) ) {
211
-
212
- // Get Settings
213
- $settings = superpwa_get_settings();
214
- $tags .= '<meta name="theme-color" content="'. $settings['theme_color'] .'">' . PHP_EOL;
215
- }
216
-
217
- $tags = apply_filters( 'superpwa_wp_head_tags', $tags );
218
-
219
- $tags .= '<!-- / SuperPWA.com -->' . PHP_EOL;
220
-
221
- echo $tags;
222
- }
223
- add_action( 'wp_head', 'superpwa_add_manifest_to_wp_head', 0 );
224
-
225
- /**
226
- * Delete manifest
227
- *
228
- * @return (boolean) true on success, false on failure
229
- *
230
- * @author Arun Basil Lal
231
- *
232
- * @since 1.0
233
- */
234
- function superpwa_delete_manifest() {
235
- return superpwa_delete( superpwa_manifest( 'abs' ) );
236
- }
237
-
238
- /**
239
- * Get PWA Icons
240
- *
241
- * @return array An array of icons to be used as the application icons and splash screen icons
242
- * @since 1.3
243
- */
244
- function superpwa_get_pwa_icons() {
245
-
246
- // Get settings
247
- $settings = superpwa_get_settings();
248
-
249
- // Application icon
250
- $icons_array[] = array(
251
- 'src' => $settings['icon'],
252
- 'sizes' => '192x192', // must be 192x192. Todo: use getimagesize($settings['icon'])[0].'x'.getimagesize($settings['icon'])[1] in the future
253
- 'type' => 'image/png', // must be image/png. Todo: use getimagesize($settings['icon'])['mime']
254
- );
255
-
256
- // Splash screen icon - Added since 1.3
257
- if ( @$settings['splash_icon'] != '' ) {
258
-
259
- $icons_array[] = array(
260
- 'src' => $settings['splash_icon'],
261
- 'sizes' => '512x512', // must be 512x512.
262
- 'type' => 'image/png', // must be image/png
263
- );
264
- }
265
-
266
- return $icons_array;
267
- }
268
-
269
- /**
270
- * Get navigation scope of PWA
271
- *
272
- * @return string Relative path to the folder where WordPress is installed. Same folder as manifest and wp-config.php
273
- * @since 1.4
274
- */
275
- function superpwa_get_scope() {
276
- return parse_url( trailingslashit( superpwa_get_bloginfo( 'sw' ) ), PHP_URL_PATH );
277
- }
278
-
279
- /**
280
- * Get orientation of PWA
281
- *
282
- * @return string Orientation of PWA as set in the plugin settings.
283
- * @since 1.4
284
- */
285
- function superpwa_get_orientation() {
286
-
287
- // Get Settings
288
- $settings = superpwa_get_settings();
289
-
290
- $orientation = isset( $settings['orientation'] ) ? $settings['orientation'] : 0;
291
-
292
- switch ( $orientation ) {
293
-
294
- case 0:
295
- return 'any';
296
- break;
297
-
298
- case 1:
299
- return 'portrait';
300
- break;
301
-
302
- case 2:
303
- return 'landscape';
304
- break;
305
-
306
- default:
307
- return 'any';
308
- }
309
- }
310
-
311
- /**
312
- * Get display of PWA
313
- *
314
- * @return (string) Display of PWA as set in the plugin settings.
315
- *
316
- * @author Jose Varghese
317
- *
318
- * @since 2.0
319
- */
320
- function superpwa_get_display() {
321
-
322
- // Get Settings
323
- $settings = superpwa_get_settings();
324
-
325
- $display = isset( $settings['display'] ) ? $settings['display'] : 1;
326
-
327
- switch ( $display ) {
328
-
329
- case 0:
330
- return 'fullscreen';
331
- break;
332
-
333
- case 1:
334
- return 'standalone';
335
- break;
336
-
337
- case 2:
338
- return 'minimal-ui';
339
- break;
340
-
341
- case 3:
342
- return 'browser';
343
- break;
344
-
345
- default:
346
- return 'standalone';
347
- }
348
- }
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manifest related functions of SuperPWA
4
+ *
5
+ * @since 1.0
6
+ *
7
+ * @function superpwa_manifest() Manifest filename, absolute path and link
8
+ * @function superpwa_generate_manifest() Generate and write manifest
9
+ * @function superpwa_add_manifest_to_wp_head() Add manifest to header (wp_head)
10
+ * @function superpwa_register_service_worker() Register service worker in the footer (wp_footer)
11
+ * @function superpwa_delete_manifest() Delete manifest
12
+ * @function superpwa_get_pwa_icons() Get PWA Icons
13
+ * @function superpwa_get_scope() Get navigation scope of PWA
14
+ * @function superpwa_get_orientation() Get orientation of PWA
15
+ * @function superpwa_get_display() Get display of PWA
16
+ */
17
+
18
+ // Exit if accessed directly
19
+ if ( ! defined( 'ABSPATH' ) ) exit;
20
+
21
+ /**
22
+ * Returns the Manifest filename.
23
+ *
24
+ * @since 2.0
25
+ *
26
+ * @return string
27
+ */
28
+ function superpwa_get_manifest_filename() {
29
+ return 'superpwa-manifest' . superpwa_multisite_filename_postfix() . '.json';
30
+ }
31
+
32
+ /**
33
+ * Manifest filename, absolute path and link
34
+ *
35
+ * For Multisite compatibility. Used to be constants defined in superpwa.php
36
+ * On a multisite, each sub-site needs a different manifest file.
37
+ *
38
+ * @uses superpwa_get_manifest_filename()
39
+ *
40
+ * @param $arg filename for manifest filename (replaces SUPERPWA_MANIFEST_FILENAME)
41
+ * abs for absolute path to manifest (replaces SUPERPWA_MANIFEST_ABS)
42
+ * src for link to manifest (replaces SUPERPWA_MANIFEST_SRC). Default value
43
+ *
44
+ * @return String filename, absolute path or link to manifest.
45
+ *
46
+ * @since 1.6
47
+ * @since 2.0 src uses home_url instead of network_site_url since manifest is no longer in the root folder.
48
+ */
49
+ function superpwa_manifest( $arg = 'src' ) {
50
+
51
+ $manifest_filename = superpwa_get_manifest_filename();
52
+
53
+ switch ( $arg ) {
54
+ // TODO: Case `filename` can be deprecated in favor of @see superpwa_get_manifest_filename().
55
+ // Name of Manifest file
56
+ case 'filename':
57
+ return $manifest_filename;
58
+ break;
59
+
60
+ /**
61
+ * Absolute path to manifest.
62
+ *
63
+ * Note: @since 2.0 manifest is no longer a physical file and absolute path doesn't make sense.
64
+ * Also using home_url instead of network_site_url in "src" in 2.0 changes the apparent location of the file.
65
+ * However, absolute path is preserved at the "old" location, so that phyiscal files can be deleted when upgrading from pre-2.0 versions.
66
+ *
67
+ * Since static files are being used in conditions where dynamic files are not possible, this path
68
+ * pointing to the root folder of WordPress is still useful.
69
+ */
70
+ case 'abs':
71
+ return trailingslashit( ABSPATH ) . $manifest_filename;
72
+ break;
73
+
74
+ // Link to manifest
75
+ case 'src':
76
+ default:
77
+
78
+ // Get Settings
79
+ $settings = superpwa_get_settings();
80
+
81
+ /**
82
+ * For static file, return site_url and network_site_url
83
+ *
84
+ * Static files are generated in the root directory.
85
+ * The site_url template tag retrieves the site url for the
86
+ * current site (where the WordPress core files reside).
87
+ */
88
+ if ( $settings['is_static_manifest'] === 1 ) {
89
+ return trailingslashit( network_site_url() ) . $manifest_filename;
90
+ }
91
+
92
+ // For dynamic files, return the home_url
93
+ return home_url( '/' ) . $manifest_filename;
94
+
95
+ break;
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Returns the Manifest template.
101
+ *
102
+ * @author Maria Daniel Deepak <daniel@danieldeepak.com>
103
+ *
104
+ * @return array
105
+ *
106
+ * @since 2.0 Replaces superpwa_generate_manifest()
107
+ * @since 2.0 Added display
108
+ */
109
+ function superpwa_manifest_template() {
110
+
111
+ // Get Settings
112
+ $settings = superpwa_get_settings();
113
+
114
+ $manifest = array();
115
+ $manifest['name'] = $settings['app_name'];
116
+ $manifest['short_name'] = $settings['app_short_name'];
117
+
118
+ // Description
119
+ if ( isset( $settings['description'] ) && ! empty( $settings['description'] ) ) {
120
+ $manifest['description'] = $settings['description'];
121
+ }
122
+
123
+ $manifest['icons'] = superpwa_get_pwa_icons();
124
+ $manifest['background_color'] = $settings['background_color'];
125
+ $manifest['theme_color'] = $settings['theme_color'];
126
+ $manifest['display'] = superpwa_get_display();
127
+ $manifest['orientation'] = superpwa_get_orientation();
128
+ $manifest['start_url'] = superpwa_get_start_url( true );
129
+ $manifest['scope'] = superpwa_get_scope();
130
+
131
+ /**
132
+ * Values that go in to Manifest JSON.
133
+ *
134
+ * The Web app manifest is a simple JSON file that tells the browser about your web application.
135
+ *
136
+ * @param array $manifest
137
+ */
138
+ return apply_filters( 'superpwa_manifest', $manifest );
139
+ }
140
+
141
+ /**
142
+ * Generate and write manifest into WordPress root folder
143
+ *
144
+ * Starting with 2.0, files are only generated if dynamic files are not possible.
145
+ * Some webserver configurations does not load WordPress and attempts to server files directly
146
+ * from the server. This returns 404 when files do not exist physically.
147
+ *
148
+ * @return (boolean) true on success, false on failure.
149
+ *
150
+ * @author Arun Basil Lal
151
+ * @author Maria Daniel Deepak <daniel@danieldeepak.com>
152
+ *
153
+ * @since 1.0
154
+ * @since 1.3 Added support for 512x512 icon.
155
+ * @since 1.4 Added orientation and scope.
156
+ * @since 1.5 Added gcm_sender_id
157
+ * @since 1.6 Added description
158
+ * @since 1.8 Removed gcm_sender_id and introduced filter superpwa_manifest. gcm_sender_id is added in /3rd-party/onesignal.php
159
+ * @since 2.0 Deprecated since Manifest is generated on the fly {@see superpwa_generate_sw_and_manifest_on_fly()}.
160
+ * @since 2.0.1 No longer deprecated since physical files are now generated in certain cases. See funtion description.
161
+ */
162
+ function superpwa_generate_manifest() {
163
+
164
+ // Delete manifest if it exists.
165
+ superpwa_delete_manifest();
166
+
167
+ // Get Settings
168
+ $settings = superpwa_get_settings();
169
+
170
+ // Return true if dynamic file returns a 200 response.
171
+ if ( superpwa_file_exists( home_url( '/' ) . superpwa_get_manifest_filename() ) && defined( 'WP_CACHE' ) && ! WP_CACHE ) {
172
+
173
+ // set file status as dynamic file in database.
174
+ $settings['is_static_manifest'] = 0;
175
+
176
+ // Write settings back to database.
177
+ update_option( 'superpwa_settings', $settings );
178
+
179
+ return true;
180
+ }
181
+
182
+ // Write the manfiest to disk.
183
+ if ( superpwa_put_contents( superpwa_manifest( 'abs' ), json_encode( superpwa_manifest_template() ) ) ) {
184
+
185
+ // set file status as satic file in database.
186
+ $settings['is_static_manifest'] = 1;
187
+
188
+ // Write settings back to database.
189
+ update_option( 'superpwa_settings', $settings );
190
+
191
+ return true;
192
+ }
193
+
194
+ return false;
195
+ }
196
+
197
+ /**
198
+ * Add manifest to header (wp_head)
199
+ *
200
+ * @since 1.0
201
+ * @since 1.8 Introduced filter superpwa_wp_head_tags
202
+ * @since 1.9 Introduced filter superpwa_add_theme_color
203
+ */
204
+ function superpwa_add_manifest_to_wp_head() {
205
+
206
+ $tags = '<!-- Manifest added by SuperPWA - Progressive Web Apps Plugin For WordPress -->' . PHP_EOL;
207
+ $tags .= '<link rel="manifest" href="'. parse_url( superpwa_manifest( 'src' ), PHP_URL_PATH ) . '">' . PHP_EOL;
208
+
209
+ // theme-color meta tag
210
+ if ( apply_filters( 'superpwa_add_theme_color', true ) ) {
211
+
212
+ // Get Settings
213
+ $settings = superpwa_get_settings();
214
+ $tags .= '<meta name="theme-color" content="'. $settings['theme_color'] .'">' . PHP_EOL;
215
+ }
216
+
217
+ $tags = apply_filters( 'superpwa_wp_head_tags', $tags );
218
+
219
+ $tags .= '<!-- / SuperPWA.com -->' . PHP_EOL;
220
+
221
+ echo $tags;
222
+ }
223
+ add_action( 'wp_head', 'superpwa_add_manifest_to_wp_head', 0 );
224
+
225
+ /**
226
+ * Delete manifest
227
+ *
228
+ * @return (boolean) true on success, false on failure
229
+ *
230
+ * @author Arun Basil Lal
231
+ *
232
+ * @since 1.0
233
+ */
234
+ function superpwa_delete_manifest() {
235
+ return superpwa_delete( superpwa_manifest( 'abs' ) );
236
+ }
237
+
238
+ /**
239
+ * Get PWA Icons
240
+ *
241
+ * @return array An array of icons to be used as the application icons and splash screen icons
242
+ *
243
+ * @author Jose Varghese
244
+ * @since 1.3
245
+ * @since 2.1.1 Added support for Maskable Icons
246
+ *
247
+ */
248
+ function superpwa_get_pwa_icons() {
249
+
250
+ // Get settings
251
+ $settings = superpwa_get_settings();
252
+
253
+ // Application icon
254
+ $icons_array[] = array(
255
+ 'src' => $settings['icon'],
256
+ 'sizes' => '192x192', // must be 192x192. Todo: use getimagesize($settings['icon'])[0].'x'.getimagesize($settings['icon'])[1] in the future
257
+ 'type' => 'image/png', // must be image/png. Todo: use getimagesize($settings['icon'])['mime']
258
+ 'purpose'=> 'any maskable', // any maskable to support adaptive icons
259
+ );
260
+
261
+ // Splash screen icon - Added since 1.3
262
+ if ( @$settings['splash_icon'] != '' ) {
263
+
264
+ $icons_array[] = array(
265
+ 'src' => $settings['splash_icon'],
266
+ 'sizes' => '512x512', // must be 512x512.
267
+ 'type' => 'image/png', // must be image/png
268
+ 'purpose'=> 'any maskable', // any maskable to support adaptive icons
269
+ );
270
+ }
271
+
272
+ return $icons_array;
273
+ }
274
+
275
+ /**
276
+ * Get navigation scope of PWA
277
+ *
278
+ * @return string Relative path to the folder where WordPress is installed. Same folder as manifest and wp-config.php
279
+ * @since 1.4
280
+ */
281
+ function superpwa_get_scope() {
282
+ return parse_url( trailingslashit( superpwa_get_bloginfo( 'sw' ) ), PHP_URL_PATH );
283
+ }
284
+
285
+ /**
286
+ * Get orientation of PWA
287
+ *
288
+ * @return string Orientation of PWA as set in the plugin settings.
289
+ * @since 1.4
290
+ */
291
+ function superpwa_get_orientation() {
292
+
293
+ // Get Settings
294
+ $settings = superpwa_get_settings();
295
+
296
+ $orientation = isset( $settings['orientation'] ) ? $settings['orientation'] : 0;
297
+
298
+ switch ( $orientation ) {
299
+
300
+ case 0:
301
+ return 'any';
302
+ break;
303
+
304
+ case 1:
305
+ return 'portrait';
306
+ break;
307
+
308
+ case 2:
309
+ return 'landscape';
310
+ break;
311
+
312
+ default:
313
+ return 'any';
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Get display of PWA
319
+ *
320
+ * @return (string) Display of PWA as set in the plugin settings.
321
+ *
322
+ * @author Jose Varghese
323
+ *
324
+ * @since 2.0
325
+ */
326
+ function superpwa_get_display() {
327
+
328
+ // Get Settings
329
+ $settings = superpwa_get_settings();
330
+
331
+ $display = isset( $settings['display'] ) ? $settings['display'] : 1;
332
+
333
+ switch ( $display ) {
334
+
335
+ case 0:
336
+ return 'fullscreen';
337
+ break;
338
+
339
+ case 1:
340
+ return 'standalone';
341
+ break;
342
+
343
+ case 2:
344
+ return 'minimal-ui';
345
+ break;
346
+
347
+ case 3:
348
+ return 'browser';
349
+ break;
350
+
351
+ default:
352
+ return 'standalone';
353
+ }
354
+ }
public/sw.php CHANGED
@@ -1,351 +1,351 @@
1
- <?php
2
- /**
3
- * Service worker related functions of SuperPWA
4
- *
5
- * @since 1.0
6
- *
7
- * @function superpwa_sw() Service worker filename, absolute path and link
8
- * @function superpwa_generate_sw() Generate and write service worker into sw.js
9
- * @function superpwa_sw_template() Service worker tempalte
10
- * @function superpwa_register_sw() Register service worker
11
- * @function superpwa_delete_sw() Delete service worker
12
- * @function superpwa_offline_page_images() Add images from offline page to filesToCache
13
- */
14
-
15
- // Exit if accessed directly
16
- if ( ! defined( 'ABSPATH' ) ) exit;
17
-
18
- /**
19
- * Returns the Service worker's filename.
20
- *
21
- * @since 2.0
22
- *
23
- * @return string
24
- */
25
- function superpwa_get_sw_filename() {
26
- return apply_filters( 'superpwa_sw_filename', 'superpwa-sw' . superpwa_multisite_filename_postfix() . '.js' );
27
- }
28
-
29
- /**
30
- * Service worker filename, absolute path and link
31
- *
32
- * For Multisite compatibility. Used to be constants defined in superpwa.php
33
- * On a multisite, each sub-site needs a different service worker.
34
- *
35
- * @param $arg filename for service worker filename (replaces SUPERPWA_SW_FILENAME)
36
- * abs for absolute path to service worker (replaces SUPERPWA_SW_ABS)
37
- * src for link to service worker (replaces SUPERPWA_SW_SRC). Default value
38
- *
39
- * @return (string) filename, absolute path or link to manifest.
40
- *
41
- * @since 1.6
42
- * @since 1.7 src to service worker is made relative to accomodate for domain mapped multisites.
43
- * @since 1.8 Added filter superpwa_sw_filename.
44
- * @since 2.0 src actually returns the link and the URL_PATH is extracted in superpwa_register_sw().
45
- * @since 2.0 src uses home_url instead of network_site_url since manifest is no longer in the root folder.
46
- */
47
- function superpwa_sw( $arg = 'src' ) {
48
-
49
- $sw_filename = superpwa_get_sw_filename();
50
-
51
- switch( $arg ) {
52
- // TODO: Case `filename` can be deprecated in favor of @see superpwa_get_sw_filename().
53
- // Name of service worker file
54
- case 'filename':
55
- return $sw_filename;
56
- break;
57
-
58
- /**
59
- * Absolute path to service worker. SW must be in the root folder.
60
- *
61
- * @since 2.0 service worker is no longer a physical file and absolute path doesn't make sense.
62
- * Also using home_url instead of network_site_url in "src" in 2.0 changes the apparent location of the file.
63
- * However, absolute path is preserved at the "old" location, so that phyiscal files can be deleted when upgrading from pre-2.0 versions.
64
- */
65
- case 'abs':
66
- return trailingslashit( ABSPATH ) . $sw_filename;
67
- break;
68
-
69
- // Link to service worker
70
- case 'src':
71
- default:
72
-
73
- // Get Settings
74
- $settings = superpwa_get_settings();
75
-
76
- /**
77
- * For static file, return site_url and network_site_url
78
- *
79
- * Static files are generated in the root directory.
80
- * The site_url template tag retrieves the site url for the
81
- * current site (where the WordPress core files reside).
82
- */
83
- if ( $settings['is_static_sw'] === 1 ) {
84
- return trailingslashit( network_site_url() ) . $sw_filename;
85
- }
86
-
87
- // For dynamic files, return the home_url
88
- return home_url( '/' ) . $sw_filename;
89
-
90
- break;
91
- }
92
- }
93
-
94
- /**
95
- * Generate and write service worker into superpwa-sw.js
96
- *
97
- * Starting with 2.0, files are only generated if dynamic files are not possible.
98
- * Some webserver configurations does not load WordPress and attempts to server files directly
99
- * from the server. This returns 404 when files do not exist physically.
100
- *
101
- * @return (boolean) true on success, false on failure.
102
- *
103
- * @author Arun Basil Lal
104
- *
105
- * @since 1.0
106
- * @since 2.0 Deprecated since Service worker is generated on the fly {@see superpwa_generate_sw_and_manifest_on_fly()}.
107
- * @since 2.0.1 No longer deprecated since physical files are now generated in certain cases. See funtion description.
108
- *
109
- */
110
- function superpwa_generate_sw() {
111
-
112
- // Delete service worker if it exists
113
- superpwa_delete_sw();
114
-
115
- // Get Settings
116
- $settings = superpwa_get_settings();
117
-
118
- // Return true if dynamic file returns a 200 response.
119
- if ( superpwa_file_exists( home_url( '/' ) . superpwa_get_sw_filename() ) && defined( 'WP_CACHE' ) && ! WP_CACHE ) {
120
-
121
- // set file status as dynamic file in database.
122
- $settings['is_static_sw'] = 0;
123
-
124
- // Write settings back to database.
125
- update_option( 'superpwa_settings', $settings );
126
-
127
- return true;
128
- }
129
-
130
- if ( superpwa_put_contents( superpwa_sw( 'abs' ), superpwa_sw_template() ) ) {
131
-
132
- // set file status as satic file in database.
133
- $settings['is_static_sw'] = 1;
134
-
135
- // Write settings back to database.
136
- update_option( 'superpwa_settings', $settings );
137
-
138
- return true;
139
- }
140
-
141
- return false;
142
- }
143
-
144
- /**
145
- * Service Worker Tempalte
146
- *
147
- * @return (string) Contents to be written to superpwa-sw.js
148
- *
149
- * @since 1.0
150
- * @since 1.7 added filter superpwa_sw_template
151
- * @since 1.9 added filter superpwa_sw_files_to_cache
152
- */
153
- function superpwa_sw_template() {
154
-
155
- // Get Settings
156
- $settings = superpwa_get_settings();
157
-
158
- // Start output buffer. Everything from here till ob_get_clean() is returned
159
- ob_start(); ?>
160
- 'use strict';
161
-
162
- /**
163
- * Service Worker of SuperPWA
164
- * To learn more and add one to your website, visit - https://superpwa.com
165
- */
166
-
167
- const cacheName = '<?php echo parse_url( get_bloginfo( 'url' ), PHP_URL_HOST ) . '-superpwa-' . SUPERPWA_VERSION; ?>';
168
- const startPage = '<?php echo superpwa_get_start_url(); ?>';
169
- const offlinePage = '<?php echo superpwa_get_offline_page(); ?>';
170
- const filesToCache = [<?php echo apply_filters( 'superpwa_sw_files_to_cache', 'startPage, offlinePage' ); ?>];
171
- const neverCacheUrls = [<?php echo apply_filters( 'superpwa_sw_never_cache_urls', '/\/wp-admin/,/\/wp-login/,/preview=true/' ); ?>];
172
-
173
- // Install
174
- self.addEventListener('install', function(e) {
175
- console.log('SuperPWA service worker installation');
176
- e.waitUntil(
177
- caches.open(cacheName).then(function(cache) {
178
- console.log('SuperPWA service worker caching dependencies');
179
- filesToCache.map(function(url) {
180
- return cache.add(url).catch(function (reason) {
181
- return console.log('SuperPWA: ' + String(reason) + ' ' + url);
182
- });
183
- });
184
- })
185
- );
186
- });
187
-
188
- // Activate
189
- self.addEventListener('activate', function(e) {
190
- console.log('SuperPWA service worker activation');
191
- e.waitUntil(
192
- caches.keys().then(function(keyList) {
193
- return Promise.all(keyList.map(function(key) {
194
- if ( key !== cacheName ) {
195
- console.log('SuperPWA old cache removed', key);
196
- return caches.delete(key);
197
- }
198
- }));
199
- })
200
- );
201
- return self.clients.claim();
202
- });
203
-
204
- // Fetch
205
- self.addEventListener('fetch', function(e) {
206
-
207
- // Return if the current request url is in the never cache list
208
- if ( ! neverCacheUrls.every(checkNeverCacheList, e.request.url) ) {
209
- console.log( 'SuperPWA: Current request is excluded from cache.' );
210
- return;
211
- }
212
-
213
- // Return if request url protocal isn't http or https
214
- if ( ! e.request.url.match(/^(http|https):\/\//i) )
215
- return;
216
-
217
- // Return if request url is from an external domain.
218
- if ( new URL(e.request.url).origin !== location.origin )
219
- return;
220
-
221
- // For POST requests, do not use the cache. Serve offline page if offline.
222
- if ( e.request.method !== 'GET' ) {
223
- e.respondWith(
224
- fetch(e.request).catch( function() {
225
- return caches.match(offlinePage);
226
- })
227
- );
228
- return;
229
- }
230
-
231
- // Revving strategy
232
- if ( e.request.mode === 'navigate' && navigator.onLine ) {
233
- e.respondWith(
234
- fetch(e.request).then(function(response) {
235
- return caches.open(cacheName).then(function(cache) {
236
- cache.put(e.request, response.clone());
237
- return response;
238
- });
239
- })
240
- );
241
- return;
242
- }
243
-
244
- e.respondWith(
245
- caches.match(e.request).then(function(response) {
246
- return response || fetch(e.request).then(function(response) {
247
- return caches.open(cacheName).then(function(cache) {
248
- cache.put(e.request, response.clone());
249
- return response;
250
- });
251
- });
252
- }).catch(function() {
253
- return caches.match(offlinePage);
254
- })
255
- );
256
- });
257
-
258
- // Check if current url is in the neverCacheUrls list
259
- function checkNeverCacheList(url) {
260
- if ( this.match(url) ) {
261
- return false;
262
- }
263
- return true;
264
- }
265
- <?php return apply_filters( 'superpwa_sw_template', ob_get_clean() );
266
- }
267
-
268
- /**
269
- * Register service worker
270
- *
271
- * @refer https://developers.google.com/web/fundamentals/primers/service-workers/registration#conclusion
272
- *
273
- * @since 1.0
274
- */
275
- function superpwa_register_sw() {
276
-
277
- wp_enqueue_script( 'superpwa-register-sw', SUPERPWA_PATH_SRC . 'public/js/register-sw.js', array(), null, true );
278
- wp_localize_script( 'superpwa-register-sw', 'superpwa_sw', array(
279
- 'url' => parse_url( superpwa_sw( 'src' ), PHP_URL_PATH ),
280
- )
281
- );
282
- }
283
- add_action( 'wp_enqueue_scripts', 'superpwa_register_sw' );
284
-
285
- /**
286
- * Delete Service Worker
287
- *
288
- * @return true on success, false on failure
289
- *
290
- * @author Arun Basil Lal
291
- *
292
- * @since 1.0
293
- */
294
- function superpwa_delete_sw() {
295
- return superpwa_delete( superpwa_sw( 'abs' ) );
296
- }
297
-
298
- /**
299
- * Add images from offline page to filesToCache
300
- *
301
- * If the offlinePage set by the user contains images, they need to be cached during sw install.
302
- * For most websites, other assets (css, js) would be same as that of startPage which would be cached
303
- * when user visits the startPage the first time. If not superpwa_sw_files_to_cache filter can be used.
304
- *
305
- * @param (string) $files_to_cache Comma separated list of files to cache during service worker install
306
- *
307
- * @return (string) Comma separated list with image src's appended to $files_to_cache
308
- *
309
- * @since 1.9
310
- */
311
- function superpwa_offline_page_images( $files_to_cache ) {
312
-
313
- // Get Settings
314
- $settings = superpwa_get_settings();
315
-
316
- // Retrieve the post
317
- $post = get_post( $settings['offline_page'] );
318
-
319
- // Return if the offline page is set to default
320
- if( $post === NULL ) {
321
- return $files_to_cache;
322
- }
323
-
324
- // Match all images
325
- preg_match_all( '/<img[^>]+src="([^">]+)"/', $post->post_content, $matches );
326
-
327
- // $matches[1] will be an array with all the src's
328
- if( ! empty( $matches[1] ) ) {
329
- return superpwa_httpsify( $files_to_cache . ', \'' . implode( '\', \'', $matches[1] ) . '\'' );
330
- }
331
-
332
- return $files_to_cache;
333
- }
334
- add_filter( 'superpwa_sw_files_to_cache', 'superpwa_offline_page_images' );
335
-
336
- /**
337
- * Get offline page
338
- *
339
- * @return (string) the URL of the offline page.
340
- *
341
- * @author Arun Basil Lal
342
- *
343
- * @since 2.0.1
344
- */
345
- function superpwa_get_offline_page() {
346
-
347
- // Get Settings
348
- $settings = superpwa_get_settings();
349
-
350
- return get_permalink( $settings['offline_page'] ) ? superpwa_httpsify( get_permalink( $settings['offline_page'] ) ) : superpwa_httpsify( superpwa_get_bloginfo( 'sw' ) );
351
  }
1
+ <?php
2
+ /**
3
+ * Service worker related functions of SuperPWA
4
+ *
5
+ * @since 1.0
6
+ *
7
+ * @function superpwa_sw() Service worker filename, absolute path and link
8
+ * @function superpwa_generate_sw() Generate and write service worker into sw.js
9
+ * @function superpwa_sw_template() Service worker tempalte
10
+ * @function superpwa_register_sw() Register service worker
11
+ * @function superpwa_delete_sw() Delete service worker
12
+ * @function superpwa_offline_page_images() Add images from offline page to filesToCache
13
+ */
14
+
15
+ // Exit if accessed directly
16
+ if ( ! defined( 'ABSPATH' ) ) exit;
17
+
18
+ /**
19
+ * Returns the Service worker's filename.
20
+ *
21
+ * @since 2.0
22
+ *
23
+ * @return string
24
+ */
25
+ function superpwa_get_sw_filename() {
26
+ return apply_filters( 'superpwa_sw_filename', 'superpwa-sw' . superpwa_multisite_filename_postfix() . '.js' );
27
+ }
28
+
29
+ /**
30
+ * Service worker filename, absolute path and link
31
+ *
32
+ * For Multisite compatibility. Used to be constants defined in superpwa.php
33
+ * On a multisite, each sub-site needs a different service worker.
34
+ *
35
+ * @param $arg filename for service worker filename (replaces SUPERPWA_SW_FILENAME)
36
+ * abs for absolute path to service worker (replaces SUPERPWA_SW_ABS)
37
+ * src for link to service worker (replaces SUPERPWA_SW_SRC). Default value
38
+ *
39
+ * @return (string) filename, absolute path or link to manifest.
40
+ *
41
+ * @since 1.6
42
+ * @since 1.7 src to service worker is made relative to accomodate for domain mapped multisites.
43
+ * @since 1.8 Added filter superpwa_sw_filename.
44
+ * @since 2.0 src actually returns the link and the URL_PATH is extracted in superpwa_register_sw().
45
+ * @since 2.0 src uses home_url instead of network_site_url since manifest is no longer in the root folder.
46
+ */
47
+ function superpwa_sw( $arg = 'src' ) {
48
+
49
+ $sw_filename = superpwa_get_sw_filename();
50
+
51
+ switch( $arg ) {
52
+ // TODO: Case `filename` can be deprecated in favor of @see superpwa_get_sw_filename().
53
+ // Name of service worker file
54
+ case 'filename':
55
+ return $sw_filename;
56
+ break;
57
+
58
+ /**
59
+ * Absolute path to service worker. SW must be in the root folder.
60
+ *
61
+ * @since 2.0 service worker is no longer a physical file and absolute path doesn't make sense.
62
+ * Also using home_url instead of network_site_url in "src" in 2.0 changes the apparent location of the file.
63
+ * However, absolute path is preserved at the "old" location, so that phyiscal files can be deleted when upgrading from pre-2.0 versions.
64
+ */
65
+ case 'abs':
66
+ return trailingslashit( ABSPATH ) . $sw_filename;
67
+ break;
68
+
69
+ // Link to service worker
70
+ case 'src':
71
+ default:
72
+
73
+ // Get Settings
74
+ $settings = superpwa_get_settings();
75
+
76
+ /**
77
+ * For static file, return site_url and network_site_url
78
+ *
79
+ * Static files are generated in the root directory.
80
+ * The site_url template tag retrieves the site url for the
81
+ * current site (where the WordPress core files reside).
82
+ */
83
+ if ( $settings['is_static_sw'] === 1 ) {
84
+ return trailingslashit( network_site_url() ) . $sw_filename;
85
+ }
86
+
87
+ // For dynamic files, return the home_url
88
+ return home_url( '/' ) . $sw_filename;
89
+
90
+ break;
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Generate and write service worker into superpwa-sw.js
96
+ *
97
+ * Starting with 2.0, files are only generated if dynamic files are not possible.
98
+ * Some webserver configurations does not load WordPress and attempts to server files directly
99
+ * from the server. This returns 404 when files do not exist physically.
100
+ *
101
+ * @return (boolean) true on success, false on failure.
102
+ *
103
+ * @author Arun Basil Lal
104
+ *
105
+ * @since 1.0
106
+ * @since 2.0 Deprecated since Service worker is generated on the fly {@see superpwa_generate_sw_and_manifest_on_fly()}.
107
+ * @since 2.0.1 No longer deprecated since physical files are now generated in certain cases. See funtion description.
108
+ *
109
+ */
110
+ function superpwa_generate_sw() {
111
+
112
+ // Delete service worker if it exists
113
+ superpwa_delete_sw();
114
+
115
+ // Get Settings
116
+ $settings = superpwa_get_settings();
117
+
118
+ // Return true if dynamic file returns a 200 response.
119
+ if ( superpwa_file_exists( home_url( '/' ) . superpwa_get_sw_filename() ) && defined( 'WP_CACHE' ) && ! WP_CACHE ) {
120
+
121
+ // set file status as dynamic file in database.
122
+ $settings['is_static_sw'] = 0;
123
+
124
+ // Write settings back to database.
125
+ update_option( 'superpwa_settings', $settings );
126
+
127
+ return true;
128
+ }
129
+
130
+ if ( superpwa_put_contents( superpwa_sw( 'abs' ), superpwa_sw_template() ) ) {
131
+
132
+ // set file status as satic file in database.
133
+ $settings['is_static_sw'] = 1;
134
+
135
+ // Write settings back to database.
136
+ update_option( 'superpwa_settings', $settings );
137
+
138
+ return true;
139
+ }
140
+
141
+ return false;
142
+ }
143
+
144
+ /**
145
+ * Service Worker Tempalte
146
+ *
147
+ * @return (string) Contents to be written to superpwa-sw.js
148
+ *
149
+ * @since 1.0
150
+ * @since 1.7 added filter superpwa_sw_template
151
+ * @since 1.9 added filter superpwa_sw_files_to_cache
152
+ */
153
+ function superpwa_sw_template() {
154
+
155
+ // Get Settings
156
+ $settings = superpwa_get_settings();
157
+
158
+ // Start output buffer. Everything from here till ob_get_clean() is returned
159
+ ob_start(); ?>
160
+ 'use strict';
161
+
162
+ /**
163
+ * Service Worker of SuperPWA
164
+ * To learn more and add one to your website, visit - https://superpwa.com
165
+ */
166
+
167
+ const cacheName = '<?php echo parse_url( get_bloginfo( 'url' ), PHP_URL_HOST ) . '-superpwa-' . SUPERPWA_VERSION; ?>';
168
+ const startPage = '<?php echo superpwa_get_start_url(); ?>';
169
+ const offlinePage = '<?php echo superpwa_get_offline_page(); ?>';
170
+ const filesToCache = [<?php echo apply_filters( 'superpwa_sw_files_to_cache', 'startPage, offlinePage' ); ?>];
171
+ const neverCacheUrls = [<?php echo apply_filters( 'superpwa_sw_never_cache_urls', '/\/wp-admin/,/\/wp-login/,/preview=true/' ); ?>];
172
+
173
+ // Install
174
+ self.addEventListener('install', function(e) {
175
+ console.log('SuperPWA service worker installation');
176
+ e.waitUntil(
177
+ caches.open(cacheName).then(function(cache) {
178
+ console.log('SuperPWA service worker caching dependencies');
179
+ filesToCache.map(function(url) {
180
+ return cache.add(url).catch(function (reason) {
181
+ return console.log('SuperPWA: ' + String(reason) + ' ' + url);
182
+ });
183
+ });
184
+ })
185
+ );
186
+ });
187
+
188
+ // Activate
189
+ self.addEventListener('activate', function(e) {
190
+ console.log('SuperPWA service worker activation');
191
+ e.waitUntil(
192
+ caches.keys().then(function(keyList) {
193
+ return Promise.all(keyList.map(function(key) {
194
+ if ( key !== cacheName ) {
195
+ console.log('SuperPWA old cache removed', key);
196
+ return caches.delete(key);
197
+ }
198
+ }));
199
+ })
200
+ );
201
+ return self.clients.claim();
202
+ });
203
+
204
+ // Fetch
205
+ self.addEventListener('fetch', function(e) {
206
+
207
+ // Return if the current request url is in the never cache list
208
+ if ( ! neverCacheUrls.every(checkNeverCacheList, e.request.url) ) {
209
+ console.log( 'SuperPWA: Current request is excluded from cache.' );
210
+ return;
211
+ }
212
+
213
+ // Return if request url protocal isn't http or https
214
+ if ( ! e.request.url.match(/^(http|https):\/\//i) )
215
+ return;
216
+
217
+ // Return if request url is from an external domain.
218
+ if ( new URL(e.request.url).origin !== location.origin )
219
+ return;
220
+
221
+ // For POST requests, do not use the cache. Serve offline page if offline.
222
+ if ( e.request.method !== 'GET' ) {
223
+ e.respondWith(
224
+ fetch(e.request).catch( function() {
225
+ return caches.match(offlinePage);
226
+ })
227
+ );
228
+ return;
229
+ }
230
+
231
+ // Revving strategy
232
+ if ( e.request.mode === 'navigate' && navigator.onLine ) {
233
+ e.respondWith(
234
+ fetch(e.request).then(function(response) {
235
+ return caches.open(cacheName).then(function(cache) {
236
+ cache.put(e.request, response.clone());
237
+ return response;
238
+ });
239
+ })
240
+ );
241
+ return;
242
+ }
243
+
244
+ e.respondWith(
245
+ caches.match(e.request).then(function(response) {
246
+ return response || fetch(e.request).then(function(response) {
247
+ return caches.open(cacheName).then(function(cache) {
248
+ cache.put(e.request, response.clone());
249
+ return response;
250
+ });
251
+ });
252
+ }).catch(function() {
253
+ return caches.match(offlinePage);
254
+ })
255
+ );
256
+ });
257
+
258
+ // Check if current url is in the neverCacheUrls list
259
+ function checkNeverCacheList(url) {
260
+ if ( this.match(url) ) {
261
+ return false;
262
+ }
263
+ return true;
264
+ }
265
+ <?php return apply_filters( 'superpwa_sw_template', ob_get_clean() );
266
+ }
267
+
268
+ /**
269
+ * Register service worker
270
+ *
271
+ * @refer https://developers.google.com/web/fundamentals/primers/service-workers/registration#conclusion
272
+ *
273
+ * @since 1.0
274
+ */
275
+ function superpwa_register_sw() {
276
+
277
+ wp_enqueue_script( 'superpwa-register-sw', SUPERPWA_PATH_SRC . 'public/js/register-sw.js', array(), null, true );
278
+ wp_localize_script( 'superpwa-register-sw', 'superpwa_sw', array(
279
+ 'url' => parse_url( superpwa_sw( 'src' ), PHP_URL_PATH ),
280
+ )
281
+ );
282
+ }
283
+ add_action( 'wp_enqueue_scripts', 'superpwa_register_sw' );
284
+
285
+ /**
286
+ * Delete Service Worker
287
+ *
288
+ * @return true on success, false on failure
289
+ *
290
+ * @author Arun Basil Lal
291
+ *
292
+ * @since 1.0
293
+ */
294
+ function superpwa_delete_sw() {
295
+ return superpwa_delete( superpwa_sw( 'abs' ) );
296
+ }
297
+
298
+ /**
299
+ * Add images from offline page to filesToCache
300
+ *
301
+ * If the offlinePage set by the user contains images, they need to be cached during sw install.
302
+ * For most websites, other assets (css, js) would be same as that of startPage which would be cached
303
+ * when user visits the startPage the first time. If not superpwa_sw_files_to_cache filter can be used.
304
+ *
305
+ * @param (string) $files_to_cache Comma separated list of files to cache during service worker install
306
+ *
307
+ * @return (string) Comma separated list with image src's appended to $files_to_cache
308
+ *
309
+ * @since 1.9
310
+ */
311
+ function superpwa_offline_page_images( $files_to_cache ) {
312
+
313
+ // Get Settings
314
+ $settings = superpwa_get_settings();
315
+
316
+ // Retrieve the post
317
+ $post = get_post( $settings['offline_page'] );
318
+
319
+ // Return if the offline page is set to default
320
+ if( $post === NULL ) {
321
+ return $files_to_cache;
322
+ }
323
+
324
+ // Match all images
325
+ preg_match_all( '/<img[^>]+src="([^">]+)"/', $post->post_content, $matches );
326
+
327
+ // $matches[1] will be an array with all the src's
328
+ if( ! empty( $matches[1] ) ) {
329
+ return superpwa_httpsify( $files_to_cache . ', \'' . implode( '\', \'', $matches[1] ) . '\'' );
330
+ }
331
+
332
+ return $files_to_cache;
333
+ }
334
+ add_filter( 'superpwa_sw_files_to_cache', 'superpwa_offline_page_images' );
335
+
336
+ /**
337
+ * Get offline page
338
+ *
339
+ * @return (string) the URL of the offline page.
340
+ *
341
+ * @author Arun Basil Lal
342
+ *
343
+ * @since 2.0.1
344
+ */
345
+ function superpwa_get_offline_page() {
346
+
347
+ // Get Settings
348
+ $settings = superpwa_get_settings();
349
+
350
+ return get_permalink( $settings['offline_page'] ) ? superpwa_httpsify( get_permalink( $settings['offline_page'] ) ) : superpwa_httpsify( superpwa_get_bloginfo( 'sw' ) );
351
  }
readme.txt CHANGED
@@ -1,425 +1,431 @@
1
- === Super Progressive Web Apps ===
2
- Contributors: superpwa, arunbasillal, josevarghese
3
- Donate link: http://millionclues.com/donate/
4
- Tags: pwa, progressive web apps, manifest, web manifest, android app, chrome app, add to homescreen, mobile web
5
- Requires at least: 3.6.0
6
- Tested up to: 5.4.1
7
- Requires PHP: 5.3
8
- Stable tag: trunk
9
- License: GPLv2 or later
10
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
-
12
- SuperPWA helps you convert your WordPress website into a Progressive Web App instantly.
13
-
14
- == Description ==
15
-
16
- > **Help decide on the future of SuperPWA**
17
- > We are looking for your input to decide on the future of SuperPWA. If you wish to acquire SuperPWA as a whole and continue it's development or if you are interested in a premium version of the plugin with extended features, [please fill in the form and let us know](https://superpwa.com/superpwa-2-1/?utm_source=wordpress.org&utm_medium=description-future).
18
-
19
- Progressive Web Apps (PWA) is a new technology that combines the best of mobile web and the best of mobile apps to create a superior mobile web experience. They are installed on the phone like a normal app (web app) and can be accessed from the home screen.
20
-
21
- 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!
22
-
23
- Super Progressive Web Apps makes it easy for you to convert your WordPress website into a Progressive Web App instantly!
24
-
25
- 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!
26
-
27
- 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.
28
-
29
- 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!
30
-
31
- #### Quick Demo?
32
-
33
- * Open up [SuperPWA.com](https://superpwa.com/?utm_source=wordpress.org&utm_medium=description-demo) in a supported device.
34
- * Add the website to your home screen either from the Add to Home Screen prompt (Chrome for Android) or from the browser menu.
35
- * Open the app from your home screen and you will see the splash screen.
36
- * Turn off your data and wifi to go offline and open up the app. You will still be able to see the app and browse the pages you have already visited.
37
- * Browse to a page that you haven't visited before. The offline page will be displayed.
38
-
39
- #### Thank You PWA Enthusiasts!
40
-
41
- 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!
42
-
43
- ### What's in the box
44
-
45
- Here are the current features of Super Progressive Web Apps:
46
-
47
- * Generate a manifest for your website and add it to the head of your website.
48
- * Set the application icon for your Progressive Web App.
49
- * Set the background color for the splash screen of your Progressive Web App.
50
- * Your website will show the "Add to home screen" notice when accessed in a supported browser.
51
- * Aggressive caching of pages using CacheStorage API.
52
- * Pages once cached are served even if the user is offline.
53
- * Set custom offline page: Select the page you want the user to see when a page that isn't in the cache is accessed and the user is offline.
54
- * New in version 1.2: Support for theme-color meta property. Change the color of browser address bar of Chrome, Firefox OS and Opera to match your website colors.
55
- * New in version 1.2: Now you can edit the Application Name and Application Short name.
56
- * New in version 1.2: Set the start page of your PWA.
57
- * 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.
58
- * 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.
59
- * New in version 1.3: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
60
- * New in version 1.3: Improved in-browser service worker update handling.
61
- * New in version 1.4: You can now set the default orientation of your PWA. Choose from "any" (Follow Device Orientation), "Portrait" and "Landscape".
62
- * New in version 1.4: You can now set the theme_color property in the manifest.
63
- * New in version 1.5: OneSignal integration for Push notifications.
64
- * New in version 1.6: WordPress Multisite Network compatibility.
65
- * New in version 1.7: Add-Ons for SuperPWA is here! Ships with [UTM Tracking Add-On](https://superpwa.com/addons/utm-tracking/?utm_source=wordpress.org&utm_medium=description) to track visits coming from your PWA.
66
- * New in version 1.8: Compatibility issues with OneSignal are now resolved!
67
- * New in version 1.8: New Add-On: [Apple Touch Icons](https://superpwa.com/addons/apple-touch-icons/?utm_source=wordpress.org&utm_medium=description) that sets your app icons as Apple Touch Icons.
68
- * New in version 2.0: SuperPWA is now compatible with WordPress installed in a sub-folder.
69
- * New in version 2.0: You can now set [display property](https://superpwa.com/doc/web-app-manifest-display-modes/?utm_source=wordpress.org&utm_medium=description) from SuperPWA settings.
70
-
71
- **Upcoming features:**
72
-
73
- * Offline Indicator Notice.
74
-
75
- ### Progressive Web App Minimum Requirements
76
-
77
- Progressive Web Apps require that your WordPress website is served from a secure origin i.e. your website should be HTTPS and not HTTP. If your website isn't HTTPS, please contact your host about it. You can also [ask us](https://wordpress.org/support/plugin/super-progressive-web-apps) if you need help.
78
-
79
- ### Device and Browser Support For PWA
80
-
81
- Progressive web apps need browsers that support manifests and service workers. Currently Google Chrome (version 57+), Chrome for Android (62), Mozilla Firefox (57), Firefox for Android (58) are the major browsers that support PWA.
82
-
83
- The list is fast growing and is likely to be supported in most major browsers by the end of this year.
84
-
85
- ### How To Convert Your WordPress Website Into A Progressive Web App
86
-
87
- #### WordPress Installation
88
-
89
- * Visit WordPress Admin > Plugins > Add New
90
- * Search for 'Super Progressive Web Apps'
91
- * Click "Install Now" and then "Activate" Super Progressive Web Apps
92
-
93
- To install manually:
94
-
95
- * Upload super-progressive-web-apps folder to the /wp-content/plugins/ directory on your server
96
- * Go to WordPress Admin > Plugins
97
- * Activate Super Progressive Web Apps plugin from the list.
98
-
99
- #### Customizing Your Progressive Web App
100
-
101
- Your Progressive Web App should be ready to test with the default settings on activation. You can customize it further and make it truly your own.
102
-
103
- * Go to WordPress Admin > SuperPWA
104
- * Set a Background Color for the splash screen to be shown when your PWA is opened on a mobile device.
105
- * Set the Application Icon. This will be the icon of your PWA when it is added to the homescreen in a mobile device. The icon must be a PNG image and exactly 192 x 192 pixels in size.
106
- * Set the Offline Page. This page will be displayed if the user is offline and the page he requested is not cached already. Ideally you should create a dedicated WordPress page and set it here. Within the page you create, you could add a note that reads, "It looks like you are offline and the page you requested is not available right now. Please check back again once you are online.".
107
- * Click "Save Settings".
108
-
109
- #### Testing Your Progressive Web App
110
-
111
- * Open a supported browser in a supported device (for eg: Chrome for Android (62 or higher) in an Android Phone)
112
- * Enter your website and wait till it fully loads
113
- * You should see a pop-up that has your Application Icon and a button that reads "ADD TO HOME SCREEN".
114
- * Click on it and your PWA will be added to your home screen. Wait for the install to complete.
115
- * Go to your home screen and open your PWA. Browse into a few pages if you like. Close the App.
116
- * Disconnect from the internet and now open your PWA again. You should be able to see all the pages that you previously browsed.
117
- * Try visiting a page that you did not visit before. You should see the page you set as your "Offline Page" in the settings of SuperPWA.
118
-
119
- #### Troubleshooting Your Progressive Web App
120
-
121
- Uh, oh. Your PWA did not work as expected? You do not see the "Add to Home Screen" notice?
122
-
123
- * Make sure your website has a SSL certificate installed. i.e. your website should be https instead of http (as in https://your-domain.com).
124
- * Make sure you are using a supported device and a supported browser. Refer to the "Device and Browser Support For PWA" list above.
125
- * Make sure your Application Icon and Splash Screen Icon's are of PNG format and 192px X 192px and 512px X 512px in size respectively.
126
- * Clear the browser cache and try again. In Chrome for Android, go to Settings > Privacy > "Clear browsing data".
127
- * If the application icon does not update after first install, delete the PWA from your phone, clear browser cache and install again. (We are working on making it better.)
128
- * Create a [new support ticket](https://wordpress.org/support/plugin/super-progressive-web-apps) and share a link to your website. We will take a look and figure it out for you.
129
-
130
- ### Feature Requests, Issues, Pull Requests
131
-
132
- Here is our repository on [GitHub](https://github.com/SuperPWA/Super-Progressive-Web-Apps). Send us your pull requests, feature requests or issues, if any.
133
-
134
- ### About us
135
-
136
- We are a duo who got excited about the idea. Our mission is simple: Help you build an awesome PWA that your users would want to have on their home screen.
137
-
138
- When we first heard about PWA we wanted to learn everything about it. We have spent countless hours learning and wants to share it with the world.
139
-
140
- Please give us your constructive feedback and support.
141
-
142
- == Installation ==
143
-
144
- To install this plugin:
145
-
146
- 1. Install the plugin through the WordPress admin interface, or upload the plugin folder to /wp-content/plugins/ using FTP.
147
- 2. Activate the plugin through the 'Plugins' screen in WordPress.
148
- 3. Go to WordPress Admin > SuperPWA
149
-
150
- == Frequently Asked Questions ==
151
-
152
- If you have any questions, please ask it on the [support forum](https://wordpress.org/support/plugin/super-progressive-web-apps).
153
-
154
- = Will Progressive Web Apps work on iOS devices? =
155
-
156
- Starting with Safari for iOS 11.3, Apple devices offer partial support for PWA's. However, there is no native Add To Home Screen prompt just yet. You can add your app by tapping "Add to Home Screen" button in the share menu of the browser ( look for the square icon with an up arrow in the foreground ).
157
-
158
- Just like you, we are eagerly awaiting the upcoming releases and we hope to see better compatibility in the coming months.
159
-
160
- = How To Customize Splash Screen =
161
-
162
- You can easily change the icon and the background color in SuperPWA > Settings.
163
-
164
- Further customizations are not available right now, not because of any limitation of SuperPWA, but because they are not available in the PWA technology. When more options come up in the future, we will add them to SuperPWA then.
165
-
166
- = How To Track Visits Originating From Your Progressive Web App =
167
-
168
- You can track visits from your PWA in your analytics software (for e.g. Google Analytics) using the UTM Tracking add-on of SuperPWA. Go to SuperPWA > Add-Ons and activate UTM Tracking. Then in SuperPWA > UTM Tracking, you can set the UTM parameters as needed. Please [refer the documentation](https://superpwa.com/addons/utm-tracking/?utm_source=wordpress.org&utm_medium=description-faq) for further information.
169
-
170
- = GDPR Compliance =
171
-
172
- SuperPWA does not collect or store user data, nor does it set cookies or store tracking data. Content visited by users from your PWA is stored in the user's own device, in the cache of the browser. This is very similar to how modern browsers caches content offline for faster browsing.
173
-
174
- With the UTM Tracking Add-On, you will be able to differentiate the visits originating from your PWA in your analytics software. You may have to include this in your privacy policy. Please note that SuperPWA does not track the visits, we just help you add the UTM parameters to the URL of the Start Page of your app so that third party analytics tools can differentiate the visits.
175
-
176
- Feel free to get in touch if you have any questions.
177
-
178
- == Screenshots ==
179
-
180
- 1. Settings page in WordPress Admin > SuperPWA > Settings
181
-
182
- == Changelog ==
183
-
184
- = 2.1 =
185
- * Date: [29.May.2020](https://superpwa.com/superpwa-2-1/?utm_source=wordpress.org&utm_medium=changelog)
186
- * Tested with WordPress 5.4.1.
187
- * Enhancement: Removed the WordPress admin notice suggesting to add SuperPWA manifest to OneSignal. [#114] (https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues/114)
188
- * Enhancement: Updated fallback value in superpwa_get_display() to match the default value in superpwa_get_settings().
189
- * Enhancement: UTM Tracking Add-on: Added default values for Campaign Medium and Campaign Name.
190
- * Bug Fix: Fixed a rare PHP Notice: Array to string conversion in basic-setup.php on line 415. [#92](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues/92)
191
- * Bug Fix: Added a check to see if WP_Plugins_List_Table class is available before using it. [#93](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues/93)
192
-
193
- = 2.0.2 =
194
- * Date: 16.January.2019
195
- * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
196
-
197
- = 2.0.1 =
198
- * Date: [15.January.2019](https://superpwa.com/superpwa-2-0/?utm_source=wordpress.org&utm_medium=changelog#2.0.1)
199
- * Enhancement: Added compatibility for setups where dynamic files are not supported.
200
-
201
- = 2.0 =
202
- * Date: [28.December.2018](https://superpwa.com/superpwa-2-0/?utm_source=wordpress.org&utm_medium=changelog)
203
- * Tested with WordPress 5.0.2.
204
- * Enhancement: Dynamic service worker and manifest.
205
- * Enhancement: SuperPWA is now compatible with WordPress in a sub-folder.
206
- * Enhancement: Added UI to set [Display property](https://superpwa.com/doc/web-app-manifest-display-modes/?utm_source=wordpress.org&utm_medium=changelog) in the web app manifest.
207
- * Enhancement: Limit short_name to 12 characters to meet Lighthouse recommendation.
208
- * Enhancement: Added PHP CodeSniffer to stick to "WordPress-Extra" coding standards. Thanks Daniel for the work.
209
- * Enhancement: SuperPWA is available in 12 languages now, thanks to the awesome translators! Translators are credited in the [release note](https://superpwa.com/superpwa-2-0/).
210
-
211
- = 1.9 =
212
- * Date: [25.July.2018](https://superpwa.com/superpwa-1-9-chrome-mini-infobar-ready/?utm_source=wordpress.org&utm_medium=changelog)
213
- * Tested with WordPress 4.9.7.
214
- * Enhancement: Added compatibility with Google Chrome 68 Mini Info-Bar.
215
- * Enhancement: Added support for tagDiv AMP Plugin which ships with Newspaper theme and Newsmag theme. If you use this theme, you can now use AMP version of the start page.
216
- * Enhancement: Added support for images in offline page. Images added to offline page are now cached during service worker activation.
217
- * Enhancement: Improved the service worker installation routine to handle invalid entities in the service worker dependencies.
218
- * Enhancement: SuperPWA is now translated to French, thanks to [@romainvincent](https://profiles.wordpress.org/romainvincent) and Spanish, thanks to [@arkangel](https://profiles.wordpress.org/arkangel/).
219
- * Bug Fix: Fixed issue where translation files in /languages/ folder was not being loaded.
220
-
221
- = 1.8.1 =
222
- * Date: [05.June.2018](https://superpwa.com/push-notifications-are-here-again/?utm_source=wordpress.org&utm_medium=changelog#1.8.1)
223
- * Enhancement: Added an admin notice with [instructions for OneSignal integration](https://superpwa.com/doc/setup-onesignal-with-superpwa/?utm_source=wordpress.org&utm_medium=changelog).
224
- * Enhancement: Updated console log message for URLs excluded from cache for better clarity.
225
-
226
- = 1.8 =
227
- * Date: [31.May.2018](https://superpwa.com/push-notifications-are-here-again/?utm_source=wordpress.org&utm_medium=changelog)
228
- * Tested with WordPress 4.9.6.
229
- * New Add-On: Apple Touch Icons. Set the Application Icon and Splash Screen Icon as Apple Touch Icons for compatibility with iOS devices.
230
- * Enhancement: Added support for Add to Home Screen prompt for Chrome 68 and beyond.
231
- * Enhancement: Better add-on activation and deactivation by hooking onto admin_post action.
232
- * Enhancement: Attempt to generate manifest and service worker automatically on visiting the SuperPWA settings page after adjusting root folder permissions.
233
- * Enhancement: Generated a .pot file with all strings for translation. You can also translate SuperPWA to your language by visiting [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/super-progressive-web-apps)
234
- * Bug Fix: Compatibility issues with OneSignal are resolved for single installs.
235
- * Bug Fix: Updated plugin action links and admin notices with the correct admin menu link.
236
-
237
- = 1.7.1 =
238
- * Date: 05.May.2018
239
- * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
240
-
241
- = 1.7 =
242
- * Date: [03.May.2018](https://superpwa.com/introducing-add-ons-for-superpwa/?utm_source=wordpress.org&utm_medium=changelog)
243
- * Minimum required WordPress version is now 3.6.0 (previously 3.5.0).
244
- * New Feature: Add-Ons for SuperPWA is here!
245
- * New Feature: SuperPWA is now a top-level menu to accommodate for the Add-Ons sub-menu page.
246
- * New Feature: Add UTM Tracking parameters to the Start URL with the [UTM Tracking Add-On](https://superpwa.com/addons/utm-tracking/?utm_source=wordpress.org&utm_medium=changelog).
247
- * Enhancement: Service worker URLs are now relative to accommodate for domain mapped Multisites.
248
- * Bug Fix: Incorrect start_url when WordPress is installed in a folder, or when inner pages are used as start_url.
249
- * Bug Fix: Incorrect manifest and service worker URLs when WordPress is installed in a folder.
250
-
251
- = 1.6 =
252
- * Date: [23.April.2018](https://superpwa.com/1-6-released-multisite-network-support/?utm_source=wordpress.org&utm_medium=changelog)
253
- * New Feature: WordPress Multisite Network Compatibility. One of the most requested features for SuperPWA is now here! Thanks [@juslintek](https://wordpress.org/support/topic/add-manifest-json-support-for-multisite/#post-9998629) for doing a major share of the heavy lifting.
254
- * New Feature: Added description to the manifest. You can now include a brief description of what your app is about.
255
- * Enhancement: Moved manifest to the very top of wp_head for better compatibility with some browsers.
256
- * Enhancement: Improved the file and folder naming, organization, and inline documentation for better readability.
257
- * Enhancement: Force https:// on all assets and dependencies solving the problem of http:// URLs in manifest and service worker once and for all.
258
- * Enhancement: Relative URL for manifest for out of the box compatibility with CDN's.
259
- * Enhancement: Removed forcing of trailing slash on manifest and service worker URLs for better compatibility.
260
-
261
- = 1.5 =
262
- * Date: 18.March.2018
263
- * New Feature: OneSignal integration for Push notifications.
264
- * Enhancement: Moved manifest to the top of wp_head for easier detection by browsers.
265
- * Enhancement: Added support for custom AMP endpoints for AMP for WordPress and AMP for WP.
266
- * Enhancement: Added UI notice when using AMP for WordPress to warn user not to use the AMP version of start page if the start page is the homepage, the blog index, or the archives page.
267
-
268
- = 1.4 =
269
- * Date: [21.February.2018](https://wordpress.org/support/topic/you-asked-and-we-listened-superpwa-1-4-ships-with-two-user-feature-requests/)
270
- * 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/).
271
- * 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/).
272
- * Enhancement: Improved compatibility with all major Accelerated Mobile Pages (AMP) plugins.
273
- * Enhancement: Improved handling of external resources.
274
-
275
- = 1.3.1 =
276
- * Date: 15.February.2018
277
- * Enhancement: Improved how Start Page url is handled in the service worker to be compatible with plugins that force SSL.
278
- * Enhancement: Improved how start_url is handled in the manifest.
279
- * Enhancement: Better handling of external resources.
280
-
281
- = 1.3 =
282
- * Date: 10.February.2018
283
- * New Feature: Added support for high-quality splash screen. You can now set the 512x512 icon for the splash screen of your Progressive Web App.
284
- * Enhancement: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
285
- * Enhancement: Improved in-browser service worker update handling.
286
- * Enhancement: Added automatic upgrade of manifest and service worker on plugin upgrade.
287
- * Bug Fix: Only GET requests are served from the cache now. Fixes [this](https://wordpress.org/support/topic/errors-in-firefox-and-chrome/).
288
-
289
- = 1.2 =
290
- * Date: 06.February.2018
291
- * New Feature: Support for theme-color.
292
- * New Feature: Now you can edit the Application Name and Application Short name.
293
- * New Feature: Set the start page of your PWA.
294
- * New Feature: Set AMP version of the start page. Supported plugins: AMP for WordPress, AMP for WP, Better AMP, AMP Supremacy, WP AMP.
295
- * UI Improvement: Better organization of plugin settings. More intuitive with inline help.
296
- * UI Improvement: Added admin notice with a link to settings page on plugin activation.
297
- * UI Improvement: Added checks for manifest, service worker and HTTPS and display the status neatly in the UI.
298
- * Bug Fix: Fix a parse error that showed up only on PHP 5.3.
299
-
300
- = 1.1.1 =
301
- * Date: 30.January.2018
302
- * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context". PHP manual says "Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error."
303
-
304
- = 1.1 =
305
- * Date: 28.January.2018
306
- * New Feature: Aggressive caching of pages using CacheStorage API.
307
- * New Feature: Pages once cached are served even if the user is offline.
308
- * New Feature: Set custom offline page. Select the page you want the user to see when a page that isn't in the cache is accessed and the user is offline.
309
-
310
- = 1.0 =
311
- * Date: 22.January.2018
312
- * First release of the plugin.
313
-
314
- == Upgrade Notice ==
315
-
316
- = 2.1 =
317
- * Tested with WordPress 5.4.1.
318
- * Enhancement: Removed the WordPress admin notice suggesting to add SuperPWA manifest to OneSignal.
319
- * Enhancement: Updated fallback value in superpwa_get_display() to match the default value in superpwa_get_settings().
320
- * Enhancement: UTM Tracking Add-on: Added default values for Campaign Medium and Campaign Name.
321
- * Bug Fix: Fixed a rare PHP Notice: Array to string conversion in basic-setup.php on line 415.
322
- * Bug Fix: Added a check to see if WP_Plugins_List_Table class is available before using it.
323
-
324
- = 2.0.2 =
325
- * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
326
-
327
- = 2.0.1 =
328
- * Enhancement: Added compatibility for setups where dynamic files are not supported.
329
-
330
- = 2.0 =
331
- * Tested with WordPress 5.0.2.
332
- * Enhancement: Dynamic service worker and manifest.
333
- * Enhancement: SuperPWA is now compatible with WordPress in a sub-folder.
334
- * Enhancement: Added UI to set Display property in the web app manifest.
335
- * Enhancement: Limit short_name to 12 characters to meet Lighthouse recommendation.
336
- * Enhancement: Added PHP CodeSniffer to stick to "WordPress-Extra" coding standards. Thanks Daniel for the work.
337
- * Enhancement: SuperPWA is available in 12 languages now, thanks to the awesome translators! Translators are credited in the release note.
338
-
339
- = 1.9 =
340
- * Tested with WordPress 4.9.7.
341
- * Enhancement: Added compatibility with Google Chrome 68 Mini Info-Bar.
342
- * Enhancement: Added support for tagDiv AMP Plugin which ships with Newspaper theme and Newsmag theme. If you use this theme, you can now use AMP version of the start page.
343
- * Enhancement: Added support for images in offline page. Images added to offline page are now cached during service worker activation.
344
- * Enhancement: Improved the service worker installation routine to handle invalid entities in the service worker dependencies.
345
- * Enhancement: SuperPWA is now translated to French, thanks to @romainvincent and Spanish, thanks to @arkangel.
346
- * Bug Fix: Fixed issue where translation files in /languages/ folder was not being loaded.
347
-
348
- = 1.8.1 =
349
- * Enhancement: Added an admin notice with instructions for OneSignal integration.
350
- * Enhancement: Updated console log message for URLs excluded from cache for better clarity.
351
-
352
- = 1.8 =
353
- * Tested with WordPress 4.9.6.
354
- * New Add-On: Apple Touch Icons. Set the Application Icon and Splash Screen Icon as Apple Touch Icons for compatibility with iOS devices.
355
- * Enhancement: Added support for Add to Home Screen prompt for Chrome 68 and beyond.
356
- * Enhancement: Better add-on activation and deactivation by hooking onto admin_post action.
357
- * Enhancement: Attempt to generate manifest and service worker automatically on visiting the SuperPWA settings page after adjusting root folder permissions.
358
- * Enhancement: Generated a .pot file with all strings for translation. You can also translate SuperPWA to your language by visiting translate.wordpress.org/projects/wp-plugins/super-progressive-web-apps
359
- * Bug Fix: Compatibility issues with OneSignal are resolved for single installs.
360
- * Bug Fix: Updated plugin action links and admin notices with the correct admin menu link.
361
-
362
- = 1.7.1 =
363
- * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
364
-
365
- = 1.7 =
366
- * Minimum required WordPress version is now 3.6.0 (previously 3.5.0).
367
- * New Feature: Add-Ons for SuperPWA is here!
368
- * New Feature: SuperPWA is now a top-level menu to accommodate for the Add-Ons sub-menu page.
369
- * New Feature: Add UTM Tracking parameters to the Start URL with the [UTM Tracking Add-On](https://superpwa.com/addons/utm-tracking/?utm_source=wordpress.org&utm_medium=upgrade-notice).
370
- * Enhancement: Service worker URLs are now relative to accommodate for domain mapped Multisites.
371
- * Bug Fix: Incorrect start_url when WordPress is installed in a folder, or when inner pages are used as start_url.
372
- * Bug Fix: Incorrect manifest and service worker URLs when WordPress is installed in a folder.
373
-
374
- = 1.6 =
375
- * New Feature: WordPress Multisite Network Compatibility. One of the most requested features for SuperPWA is now here! Thanks [@juslintek](https://wordpress.org/support/topic/add-manifest-json-support-for-multisite/#post-9998629) for doing a major share of the heavy lifting.
376
- * New Feature: Added description to the manifest. You can now include a brief description of what your app is about.
377
- * Enhancement: Moved manifest to the very top of wp_head for better compatibility with some browsers.
378
- * Enhancement: Improved the file and folder naming, organization, and inline documentation for better readability.
379
- * Enhancement: Force https:// on all assets and dependencies solving the problem of http:// URLs in manifest and service worker once and for all.
380
- * Enhancement: Relative URL for manifest for out of the box compatibility with CDN's.
381
- * Enhancement: Removed forcing of trailing slash on manifest and service worker URLs for better compatibility.
382
-
383
- = 1.5 =
384
- * New Feature: OneSignal integration for Push notifications.
385
- * Enhancement: Moved manifest to the top of wp_head for easier detection by browsers.
386
- * Enhancement: Added support for custom AMP endpoints for AMP for WordPress and AMP for WP.
387
- * Enhancement: Added UI notice when using AMP for WordPress to warn user not to use the AMP version of start page if the start page is the homepage, the blog index, or the archives page.
388
-
389
- = 1.4 =
390
- * New Feature: Added UI for default orientation of your PWA. Orientation can now be set as "any", "portrait" or "landscape".
391
- * New Feature: Added UI for theme_color property in manifest.
392
- * Enhancement: Improved compatibility with all major Accelerated Mobile Pages (AMP) plugins.
393
- * Enhancement: Improved handling of external resources.
394
-
395
- = 1.3.1 =
396
- * Enhancement: Improved how Start Page url is handled in the service worker to be compatible with plugins that force SSL.
397
- * Enhancement: Improved how start_url is handled in the manifest.
398
- * Enhancement: Better handling of external resources.
399
-
400
- = 1.3 =
401
- * New Feature: Added support for high-quality splash screen. You can now set the 512x512 icon for the splash screen of your Progressive Web App.
402
- * Enhancement: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
403
- * Enhancement: Improved in-browser service worker update handling.
404
- * Enhancement: Added automatic upgrade of manifest and service worker on plugin upgrade.
405
-
406
- = 1.2 =
407
- * New Feature: Support for theme-color.
408
- * New Feature: Now you can edit the Application Name and Application Short name.
409
- * New Feature: Set the start page of your PWA.
410
- * New Feature: Set AMP version of the start page. Supported plugins: AMP for WordPress, AMP for WP, Better AMP, AMP Supremacy, WP AMP.
411
- * UI Improvement: Better organization of plugin settings. More intuitive with inline help.
412
- * UI Improvement: Added admin notice with a link to settings page on plugin activation.
413
- * UI Improvement: Added checks for manifest, service worker and HTTPS and display the status neatly in the UI.
414
- * Bug Fix: Fix a parse error that showed up only on PHP 5.3.
415
-
416
- = 1.1.1 =
417
- * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context". PHP manual says "Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error."
418
-
419
- = 1.1 =
420
- * New Feature: Aggressive caching of pages using CacheStorage API.
421
- * New Feature: Pages once cached are served even if the user is offline.
422
- * New Feature: Set custom offline page: Select the page you want the user to see when a page that isn't in the cache is accessed and the user is offline.
423
-
424
- = 1.0 =
425
- * First release of the plugin.
 
 
 
 
 
 
1
+ === Super Progressive Web Apps ===
2
+ Contributors: superpwa, arunbasillal, josevarghese
3
+ Donate link: http://millionclues.com/donate/
4
+ Tags: pwa, progressive web apps, manifest, web manifest, android app, chrome app, add to homescreen, mobile web
5
+ Requires at least: 3.6.0
6
+ Tested up to: 5.4.2
7
+ Requires PHP: 5.3
8
+ Stable tag: trunk
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ SuperPWA helps you convert your WordPress website into a Progressive Web App instantly.
13
+
14
+ == Description ==
15
+
16
+ > **Help decide on the future of SuperPWA**
17
+ > We are looking for your input to decide on the future of SuperPWA. If you wish to acquire SuperPWA as a whole and continue it's development or if you are interested in a premium version of the plugin with extended features, [please fill in the form and let us know](https://superpwa.com/superpwa-2-1/?utm_source=wordpress.org&utm_medium=description-future).
18
+
19
+ Progressive Web Apps (PWA) is a new technology that combines the best of mobile web and the best of mobile apps to create a superior mobile web experience. They are installed on the phone like a normal app (web app) and can be accessed from the home screen.
20
+
21
+ 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!
22
+
23
+ Super Progressive Web Apps makes it easy for you to convert your WordPress website into a Progressive Web App instantly!
24
+
25
+ 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!
26
+
27
+ 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.
28
+
29
+ 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!
30
+
31
+ #### Quick Demo?
32
+
33
+ * Open up [SuperPWA.com](https://superpwa.com/?utm_source=wordpress.org&utm_medium=description-demo) in a supported device.
34
+ * Add the website to your home screen either from the Add to Home Screen prompt (Chrome for Android) or from the browser menu.
35
+ * Open the app from your home screen and you will see the splash screen.
36
+ * Turn off your data and wifi to go offline and open up the app. You will still be able to see the app and browse the pages you have already visited.
37
+ * Browse to a page that you haven't visited before. The offline page will be displayed.
38
+
39
+ #### Thank You PWA Enthusiasts!
40
+
41
+ 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!
42
+
43
+ ### What's in the box
44
+
45
+ Here are the current features of Super Progressive Web Apps:
46
+
47
+ * Generate a manifest for your website and add it to the head of your website.
48
+ * Set the application icon for your Progressive Web App.
49
+ * Set the background color for the splash screen of your Progressive Web App.
50
+ * Your website will show the "Add to home screen" notice when accessed in a supported browser.
51
+ * Aggressive caching of pages using CacheStorage API.
52
+ * Pages once cached are served even if the user is offline.
53
+ * Set custom offline page: Select the page you want the user to see when a page that isn't in the cache is accessed and the user is offline.
54
+ * New in version 1.2: Support for theme-color meta property. Change the color of browser address bar of Chrome, Firefox OS and Opera to match your website colors.
55
+ * New in version 1.2: Now you can edit the Application Name and Application Short name.
56
+ * New in version 1.2: Set the start page of your PWA.
57
+ * 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.
58
+ * 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.
59
+ * New in version 1.3: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
60
+ * New in version 1.3: Improved in-browser service worker update handling.
61
+ * New in version 1.4: You can now set the default orientation of your PWA. Choose from "any" (Follow Device Orientation), "Portrait" and "Landscape".
62
+ * New in version 1.4: You can now set the theme_color property in the manifest.
63
+ * New in version 1.5: OneSignal integration for Push notifications.
64
+ * New in version 1.6: WordPress Multisite Network compatibility.
65
+ * New in version 1.7: Add-Ons for SuperPWA is here! Ships with [UTM Tracking Add-On](https://superpwa.com/addons/utm-tracking/?utm_source=wordpress.org&utm_medium=description) to track visits coming from your PWA.
66
+ * New in version 1.8: Compatibility issues with OneSignal are now resolved!
67
+ * New in version 1.8: New Add-On: [Apple Touch Icons](https://superpwa.com/addons/apple-touch-icons/?utm_source=wordpress.org&utm_medium=description) that sets your app icons as Apple Touch Icons.
68
+ * New in version 2.0: SuperPWA is now compatible with WordPress installed in a sub-folder.
69
+ * New in version 2.0: You can now set [display property](https://superpwa.com/doc/web-app-manifest-display-modes/?utm_source=wordpress.org&utm_medium=description) from SuperPWA settings.
70
+ * New in version 2.1.1: SuperPWA now supports Maskable Icons.
71
+
72
+ **Upcoming features:**
73
+
74
+ * Offline Indicator Notice.
75
+
76
+ ### Progressive Web App Minimum Requirements
77
+
78
+ Progressive Web Apps require that your WordPress website is served from a secure origin i.e. your website should be HTTPS and not HTTP. If your website isn't HTTPS, please contact your host about it. You can also [ask us](https://wordpress.org/support/plugin/super-progressive-web-apps) if you need help.
79
+
80
+ ### Device and Browser Support For PWA
81
+
82
+ Progressive web apps need browsers that support manifests and service workers. Currently Google Chrome (version 57+), Chrome for Android (62), Mozilla Firefox (57), Firefox for Android (58) are the major browsers that support PWA.
83
+
84
+ The list is fast growing and is likely to be supported in most major browsers by the end of this year.
85
+
86
+ ### How To Convert Your WordPress Website Into A Progressive Web App
87
+
88
+ #### WordPress Installation
89
+
90
+ * Visit WordPress Admin > Plugins > Add New
91
+ * Search for 'Super Progressive Web Apps'
92
+ * Click "Install Now" and then "Activate" Super Progressive Web Apps
93
+
94
+ To install manually:
95
+
96
+ * Upload super-progressive-web-apps folder to the /wp-content/plugins/ directory on your server
97
+ * Go to WordPress Admin > Plugins
98
+ * Activate Super Progressive Web Apps plugin from the list.
99
+
100
+ #### Customizing Your Progressive Web App
101
+
102
+ Your Progressive Web App should be ready to test with the default settings on activation. You can customize it further and make it truly your own.
103
+
104
+ * Go to WordPress Admin > SuperPWA
105
+ * Set a Background Color for the splash screen to be shown when your PWA is opened on a mobile device.
106
+ * Set the Application Icon. This will be the icon of your PWA when it is added to the homescreen in a mobile device. The icon must be a PNG image and exactly 192 x 192 pixels in size.
107
+ * Set the Offline Page. This page will be displayed if the user is offline and the page he requested is not cached already. Ideally you should create a dedicated WordPress page and set it here. Within the page you create, you could add a note that reads, "It looks like you are offline and the page you requested is not available right now. Please check back again once you are online.".
108
+ * Click "Save Settings".
109
+
110
+ #### Testing Your Progressive Web App
111
+
112
+ * Open a supported browser in a supported device (for eg: Chrome for Android (62 or higher) in an Android Phone)
113
+ * Enter your website and wait till it fully loads
114
+ * You should see a pop-up that has your Application Icon and a button that reads "ADD TO HOME SCREEN".
115
+ * Click on it and your PWA will be added to your home screen. Wait for the install to complete.
116
+ * Go to your home screen and open your PWA. Browse into a few pages if you like. Close the App.
117
+ * Disconnect from the internet and now open your PWA again. You should be able to see all the pages that you previously browsed.
118
+ * Try visiting a page that you did not visit before. You should see the page you set as your "Offline Page" in the settings of SuperPWA.
119
+
120
+ #### Troubleshooting Your Progressive Web App
121
+
122
+ Uh, oh. Your PWA did not work as expected? You do not see the "Add to Home Screen" notice?
123
+
124
+ * Make sure your website has a SSL certificate installed. i.e. your website should be https instead of http (as in https://your-domain.com).
125
+ * Make sure you are using a supported device and a supported browser. Refer to the "Device and Browser Support For PWA" list above.
126
+ * Make sure your Application Icon and Splash Screen Icon's are of PNG format and 192px X 192px and 512px X 512px in size respectively.
127
+ * Clear the browser cache and try again. In Chrome for Android, go to Settings > Privacy > "Clear browsing data".
128
+ * If the application icon does not update after first install, delete the PWA from your phone, clear browser cache and install again. (We are working on making it better.)
129
+ * Create a [new support ticket](https://wordpress.org/support/plugin/super-progressive-web-apps) and share a link to your website. We will take a look and figure it out for you.
130
+
131
+ ### Feature Requests, Issues, Pull Requests
132
+
133
+ Here is our repository on [GitHub](https://github.com/SuperPWA/Super-Progressive-Web-Apps). Send us your pull requests, feature requests or issues, if any.
134
+
135
+ ### About us
136
+
137
+ We are a duo who got excited about the idea. Our mission is simple: Help you build an awesome PWA that your users would want to have on their home screen.
138
+
139
+ When we first heard about PWA we wanted to learn everything about it. We have spent countless hours learning and wants to share it with the world.
140
+
141
+ Please give us your constructive feedback and support.
142
+
143
+ == Installation ==
144
+
145
+ To install this plugin:
146
+
147
+ 1. Install the plugin through the WordPress admin interface, or upload the plugin folder to /wp-content/plugins/ using FTP.
148
+ 2. Activate the plugin through the 'Plugins' screen in WordPress.
149
+ 3. Go to WordPress Admin > SuperPWA
150
+
151
+ == Frequently Asked Questions ==
152
+
153
+ If you have any questions, please ask it on the [support forum](https://wordpress.org/support/plugin/super-progressive-web-apps).
154
+
155
+ = Will Progressive Web Apps work on iOS devices? =
156
+
157
+ Starting with Safari for iOS 11.3, Apple devices offer partial support for PWA's. However, there is no native Add To Home Screen prompt just yet. You can add your app by tapping "Add to Home Screen" button in the share menu of the browser ( look for the square icon with an up arrow in the foreground ).
158
+
159
+ Just like you, we are eagerly awaiting the upcoming releases and we hope to see better compatibility in the coming months.
160
+
161
+ = How To Customize Splash Screen =
162
+
163
+ You can easily change the icon and the background color in SuperPWA > Settings.
164
+
165
+ Further customizations are not available right now, not because of any limitation of SuperPWA, but because they are not available in the PWA technology. When more options come up in the future, we will add them to SuperPWA then.
166
+
167
+ = How To Track Visits Originating From Your Progressive Web App =
168
+
169
+ You can track visits from your PWA in your analytics software (for e.g. Google Analytics) using the UTM Tracking add-on of SuperPWA. Go to SuperPWA > Add-Ons and activate UTM Tracking. Then in SuperPWA > UTM Tracking, you can set the UTM parameters as needed. Please [refer the documentation](https://superpwa.com/addons/utm-tracking/?utm_source=wordpress.org&utm_medium=description-faq) for further information.
170
+
171
+ = GDPR Compliance =
172
+
173
+ SuperPWA does not collect or store user data, nor does it set cookies or store tracking data. Content visited by users from your PWA is stored in the user's own device, in the cache of the browser. This is very similar to how modern browsers caches content offline for faster browsing.
174
+
175
+ With the UTM Tracking Add-On, you will be able to differentiate the visits originating from your PWA in your analytics software. You may have to include this in your privacy policy. Please note that SuperPWA does not track the visits, we just help you add the UTM parameters to the URL of the Start Page of your app so that third party analytics tools can differentiate the visits.
176
+
177
+ Feel free to get in touch if you have any questions.
178
+
179
+ == Screenshots ==
180
+
181
+ 1. Settings page in WordPress Admin > SuperPWA > Settings
182
+
183
+ == Changelog ==
184
+
185
+ = 2.1.1 =
186
+ * Date: [4.July.2020](https://superpwa.com/superpwa-2-1/?utm_source=wordpress.org&utm_medium=changelog)
187
+ * Tested with WordPress 5.4.2.
188
+ * Enhancement: Added support for Maskable Icons [#127](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues/127)
189
+
190
+ = 2.1 =
191
+ * Date: [29.May.2020](https://superpwa.com/superpwa-2-1/?utm_source=wordpress.org&utm_medium=changelog)
192
+ * Tested with WordPress 5.4.1.
193
+ * Enhancement: Removed the WordPress admin notice suggesting to add SuperPWA manifest to OneSignal. [#114] (https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues/114)
194
+ * Enhancement: Updated fallback value in superpwa_get_display() to match the default value in superpwa_get_settings().
195
+ * Enhancement: UTM Tracking Add-on: Added default values for Campaign Medium and Campaign Name.
196
+ * Bug Fix: Fixed a rare PHP Notice: Array to string conversion in basic-setup.php on line 415. [#92](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues/92)
197
+ * Bug Fix: Added a check to see if WP_Plugins_List_Table class is available before using it. [#93](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues/93)
198
+
199
+ = 2.0.2 =
200
+ * Date: 16.January.2019
201
+ * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
202
+
203
+ = 2.0.1 =
204
+ * Date: [15.January.2019](https://superpwa.com/superpwa-2-0/?utm_source=wordpress.org&utm_medium=changelog#2.0.1)
205
+ * Enhancement: Added compatibility for setups where dynamic files are not supported.
206
+
207
+ = 2.0 =
208
+ * Date: [28.December.2018](https://superpwa.com/superpwa-2-0/?utm_source=wordpress.org&utm_medium=changelog)
209
+ * Tested with WordPress 5.0.2.
210
+ * Enhancement: Dynamic service worker and manifest.
211
+ * Enhancement: SuperPWA is now compatible with WordPress in a sub-folder.
212
+ * Enhancement: Added UI to set [Display property](https://superpwa.com/doc/web-app-manifest-display-modes/?utm_source=wordpress.org&utm_medium=changelog) in the web app manifest.
213
+ * Enhancement: Limit short_name to 12 characters to meet Lighthouse recommendation.
214
+ * Enhancement: Added PHP CodeSniffer to stick to "WordPress-Extra" coding standards. Thanks Daniel for the work.
215
+ * Enhancement: SuperPWA is available in 12 languages now, thanks to the awesome translators! Translators are credited in the [release note](https://superpwa.com/superpwa-2-0/).
216
+
217
+ = 1.9 =
218
+ * Date: [25.July.2018](https://superpwa.com/superpwa-1-9-chrome-mini-infobar-ready/?utm_source=wordpress.org&utm_medium=changelog)
219
+ * Tested with WordPress 4.9.7.
220
+ * Enhancement: Added compatibility with Google Chrome 68 Mini Info-Bar.
221
+ * Enhancement: Added support for tagDiv AMP Plugin which ships with Newspaper theme and Newsmag theme. If you use this theme, you can now use AMP version of the start page.
222
+ * Enhancement: Added support for images in offline page. Images added to offline page are now cached during service worker activation.
223
+ * Enhancement: Improved the service worker installation routine to handle invalid entities in the service worker dependencies.
224
+ * Enhancement: SuperPWA is now translated to French, thanks to [@romainvincent](https://profiles.wordpress.org/romainvincent) and Spanish, thanks to [@arkangel](https://profiles.wordpress.org/arkangel/).
225
+ * Bug Fix: Fixed issue where translation files in /languages/ folder was not being loaded.
226
+
227
+ = 1.8.1 =
228
+ * Date: [05.June.2018](https://superpwa.com/push-notifications-are-here-again/?utm_source=wordpress.org&utm_medium=changelog#1.8.1)
229
+ * Enhancement: Added an admin notice with [instructions for OneSignal integration](https://superpwa.com/doc/setup-onesignal-with-superpwa/?utm_source=wordpress.org&utm_medium=changelog).
230
+ * Enhancement: Updated console log message for URLs excluded from cache for better clarity.
231
+
232
+ = 1.8 =
233
+ * Date: [31.May.2018](https://superpwa.com/push-notifications-are-here-again/?utm_source=wordpress.org&utm_medium=changelog)
234
+ * Tested with WordPress 4.9.6.
235
+ * New Add-On: Apple Touch Icons. Set the Application Icon and Splash Screen Icon as Apple Touch Icons for compatibility with iOS devices.
236
+ * Enhancement: Added support for Add to Home Screen prompt for Chrome 68 and beyond.
237
+ * Enhancement: Better add-on activation and deactivation by hooking onto admin_post action.
238
+ * Enhancement: Attempt to generate manifest and service worker automatically on visiting the SuperPWA settings page after adjusting root folder permissions.
239
+ * Enhancement: Generated a .pot file with all strings for translation. You can also translate SuperPWA to your language by visiting [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/super-progressive-web-apps)
240
+ * Bug Fix: Compatibility issues with OneSignal are resolved for single installs.
241
+ * Bug Fix: Updated plugin action links and admin notices with the correct admin menu link.
242
+
243
+ = 1.7.1 =
244
+ * Date: 05.May.2018
245
+ * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
246
+
247
+ = 1.7 =
248
+ * Date: [03.May.2018](https://superpwa.com/introducing-add-ons-for-superpwa/?utm_source=wordpress.org&utm_medium=changelog)
249
+ * Minimum required WordPress version is now 3.6.0 (previously 3.5.0).
250
+ * New Feature: Add-Ons for SuperPWA is here!
251
+ * New Feature: SuperPWA is now a top-level menu to accommodate for the Add-Ons sub-menu page.
252
+ * New Feature: Add UTM Tracking parameters to the Start URL with the [UTM Tracking Add-On](https://superpwa.com/addons/utm-tracking/?utm_source=wordpress.org&utm_medium=changelog).
253
+ * Enhancement: Service worker URLs are now relative to accommodate for domain mapped Multisites.
254
+ * Bug Fix: Incorrect start_url when WordPress is installed in a folder, or when inner pages are used as start_url.
255
+ * Bug Fix: Incorrect manifest and service worker URLs when WordPress is installed in a folder.
256
+
257
+ = 1.6 =
258
+ * Date: [23.April.2018](https://superpwa.com/1-6-released-multisite-network-support/?utm_source=wordpress.org&utm_medium=changelog)
259
+ * New Feature: WordPress Multisite Network Compatibility. One of the most requested features for SuperPWA is now here! Thanks [@juslintek](https://wordpress.org/support/topic/add-manifest-json-support-for-multisite/#post-9998629) for doing a major share of the heavy lifting.
260
+ * New Feature: Added description to the manifest. You can now include a brief description of what your app is about.
261
+ * Enhancement: Moved manifest to the very top of wp_head for better compatibility with some browsers.
262
+ * Enhancement: Improved the file and folder naming, organization, and inline documentation for better readability.
263
+ * Enhancement: Force https:// on all assets and dependencies solving the problem of http:// URLs in manifest and service worker once and for all.
264
+ * Enhancement: Relative URL for manifest for out of the box compatibility with CDN's.
265
+ * Enhancement: Removed forcing of trailing slash on manifest and service worker URLs for better compatibility.
266
+
267
+ = 1.5 =
268
+ * Date: 18.March.2018
269
+ * New Feature: OneSignal integration for Push notifications.
270
+ * Enhancement: Moved manifest to the top of wp_head for easier detection by browsers.
271
+ * Enhancement: Added support for custom AMP endpoints for AMP for WordPress and AMP for WP.
272
+ * Enhancement: Added UI notice when using AMP for WordPress to warn user not to use the AMP version of start page if the start page is the homepage, the blog index, or the archives page.
273
+
274
+ = 1.4 =
275
+ * Date: [21.February.2018](https://wordpress.org/support/topic/you-asked-and-we-listened-superpwa-1-4-ships-with-two-user-feature-requests/)
276
+ * 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/).
277
+ * 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/).
278
+ * Enhancement: Improved compatibility with all major Accelerated Mobile Pages (AMP) plugins.
279
+ * Enhancement: Improved handling of external resources.
280
+
281
+ = 1.3.1 =
282
+ * Date: 15.February.2018
283
+ * Enhancement: Improved how Start Page url is handled in the service worker to be compatible with plugins that force SSL.
284
+ * Enhancement: Improved how start_url is handled in the manifest.
285
+ * Enhancement: Better handling of external resources.
286
+
287
+ = 1.3 =
288
+ * Date: 10.February.2018
289
+ * New Feature: Added support for high-quality splash screen. You can now set the 512x512 icon for the splash screen of your Progressive Web App.
290
+ * Enhancement: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
291
+ * Enhancement: Improved in-browser service worker update handling.
292
+ * Enhancement: Added automatic upgrade of manifest and service worker on plugin upgrade.
293
+ * Bug Fix: Only GET requests are served from the cache now. Fixes [this](https://wordpress.org/support/topic/errors-in-firefox-and-chrome/).
294
+
295
+ = 1.2 =
296
+ * Date: 06.February.2018
297
+ * New Feature: Support for theme-color.
298
+ * New Feature: Now you can edit the Application Name and Application Short name.
299
+ * New Feature: Set the start page of your PWA.
300
+ * New Feature: Set AMP version of the start page. Supported plugins: AMP for WordPress, AMP for WP, Better AMP, AMP Supremacy, WP AMP.
301
+ * UI Improvement: Better organization of plugin settings. More intuitive with inline help.
302
+ * UI Improvement: Added admin notice with a link to settings page on plugin activation.
303
+ * UI Improvement: Added checks for manifest, service worker and HTTPS and display the status neatly in the UI.
304
+ * Bug Fix: Fix a parse error that showed up only on PHP 5.3.
305
+
306
+ = 1.1.1 =
307
+ * Date: 30.January.2018
308
+ * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context". PHP manual says "Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error."
309
+
310
+ = 1.1 =
311
+ * Date: 28.January.2018
312
+ * New Feature: Aggressive caching of pages using CacheStorage API.
313
+ * New Feature: Pages once cached are served even if the user is offline.
314
+ * New Feature: Set custom offline page. Select the page you want the user to see when a page that isn't in the cache is accessed and the user is offline.
315
+
316
+ = 1.0 =
317
+ * Date: 22.January.2018
318
+ * First release of the plugin.
319
+
320
+ == Upgrade Notice ==
321
+
322
+ = 2.1 =
323
+ * Tested with WordPress 5.4.1.
324
+ * Enhancement: Removed the WordPress admin notice suggesting to add SuperPWA manifest to OneSignal.
325
+ * Enhancement: Updated fallback value in superpwa_get_display() to match the default value in superpwa_get_settings().
326
+ * Enhancement: UTM Tracking Add-on: Added default values for Campaign Medium and Campaign Name.
327
+ * Bug Fix: Fixed a rare PHP Notice: Array to string conversion in basic-setup.php on line 415.
328
+ * Bug Fix: Added a check to see if WP_Plugins_List_Table class is available before using it.
329
+
330
+ = 2.0.2 =
331
+ * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
332
+
333
+ = 2.0.1 =
334
+ * Enhancement: Added compatibility for setups where dynamic files are not supported.
335
+
336
+ = 2.0 =
337
+ * Tested with WordPress 5.0.2.
338
+ * Enhancement: Dynamic service worker and manifest.
339
+ * Enhancement: SuperPWA is now compatible with WordPress in a sub-folder.
340
+ * Enhancement: Added UI to set Display property in the web app manifest.
341
+ * Enhancement: Limit short_name to 12 characters to meet Lighthouse recommendation.
342
+ * Enhancement: Added PHP CodeSniffer to stick to "WordPress-Extra" coding standards. Thanks Daniel for the work.
343
+ * Enhancement: SuperPWA is available in 12 languages now, thanks to the awesome translators! Translators are credited in the release note.
344
+
345
+ = 1.9 =
346
+ * Tested with WordPress 4.9.7.
347
+ * Enhancement: Added compatibility with Google Chrome 68 Mini Info-Bar.
348
+ * Enhancement: Added support for tagDiv AMP Plugin which ships with Newspaper theme and Newsmag theme. If you use this theme, you can now use AMP version of the start page.
349
+ * Enhancement: Added support for images in offline page. Images added to offline page are now cached during service worker activation.
350
+ * Enhancement: Improved the service worker installation routine to handle invalid entities in the service worker dependencies.
351
+ * Enhancement: SuperPWA is now translated to French, thanks to @romainvincent and Spanish, thanks to @arkangel.
352
+ * Bug Fix: Fixed issue where translation files in /languages/ folder was not being loaded.
353
+
354
+ = 1.8.1 =
355
+ * Enhancement: Added an admin notice with instructions for OneSignal integration.
356
+ * Enhancement: Updated console log message for URLs excluded from cache for better clarity.
357
+
358
+ = 1.8 =
359
+ * Tested with WordPress 4.9.6.
360
+ * New Add-On: Apple Touch Icons. Set the Application Icon and Splash Screen Icon as Apple Touch Icons for compatibility with iOS devices.
361
+ * Enhancement: Added support for Add to Home Screen prompt for Chrome 68 and beyond.
362
+ * Enhancement: Better add-on activation and deactivation by hooking onto admin_post action.
363
+ * Enhancement: Attempt to generate manifest and service worker automatically on visiting the SuperPWA settings page after adjusting root folder permissions.
364
+ * Enhancement: Generated a .pot file with all strings for translation. You can also translate SuperPWA to your language by visiting translate.wordpress.org/projects/wp-plugins/super-progressive-web-apps
365
+ * Bug Fix: Compatibility issues with OneSignal are resolved for single installs.
366
+ * Bug Fix: Updated plugin action links and admin notices with the correct admin menu link.
367
+
368
+ = 1.7.1 =
369
+ * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
370
+
371
+ = 1.7 =
372
+ * Minimum required WordPress version is now 3.6.0 (previously 3.5.0).
373
+ * New Feature: Add-Ons for SuperPWA is here!
374
+ * New Feature: SuperPWA is now a top-level menu to accommodate for the Add-Ons sub-menu page.
375
+ * New Feature: Add UTM Tracking parameters to the Start URL with the [UTM Tracking Add-On](https://superpwa.com/addons/utm-tracking/?utm_source=wordpress.org&utm_medium=upgrade-notice).
376
+ * Enhancement: Service worker URLs are now relative to accommodate for domain mapped Multisites.
377
+ * Bug Fix: Incorrect start_url when WordPress is installed in a folder, or when inner pages are used as start_url.
378
+ * Bug Fix: Incorrect manifest and service worker URLs when WordPress is installed in a folder.
379
+
380
+ = 1.6 =
381
+ * New Feature: WordPress Multisite Network Compatibility. One of the most requested features for SuperPWA is now here! Thanks [@juslintek](https://wordpress.org/support/topic/add-manifest-json-support-for-multisite/#post-9998629) for doing a major share of the heavy lifting.
382
+ * New Feature: Added description to the manifest. You can now include a brief description of what your app is about.
383
+ * Enhancement: Moved manifest to the very top of wp_head for better compatibility with some browsers.
384
+ * Enhancement: Improved the file and folder naming, organization, and inline documentation for better readability.
385
+ * Enhancement: Force https:// on all assets and dependencies solving the problem of http:// URLs in manifest and service worker once and for all.
386
+ * Enhancement: Relative URL for manifest for out of the box compatibility with CDN's.
387
+ * Enhancement: Removed forcing of trailing slash on manifest and service worker URLs for better compatibility.
388
+
389
+ = 1.5 =
390
+ * New Feature: OneSignal integration for Push notifications.
391
+ * Enhancement: Moved manifest to the top of wp_head for easier detection by browsers.
392
+ * Enhancement: Added support for custom AMP endpoints for AMP for WordPress and AMP for WP.
393
+ * Enhancement: Added UI notice when using AMP for WordPress to warn user not to use the AMP version of start page if the start page is the homepage, the blog index, or the archives page.
394
+
395
+ = 1.4 =
396
+ * New Feature: Added UI for default orientation of your PWA. Orientation can now be set as "any", "portrait" or "landscape".
397
+ * New Feature: Added UI for theme_color property in manifest.
398
+ * Enhancement: Improved compatibility with all major Accelerated Mobile Pages (AMP) plugins.
399
+ * Enhancement: Improved handling of external resources.
400
+
401
+ = 1.3.1 =
402
+ * Enhancement: Improved how Start Page url is handled in the service worker to be compatible with plugins that force SSL.
403
+ * Enhancement: Improved how start_url is handled in the manifest.
404
+ * Enhancement: Better handling of external resources.
405
+
406
+ = 1.3 =
407
+ * New Feature: Added support for high-quality splash screen. You can now set the 512x512 icon for the splash screen of your Progressive Web App.
408
+ * Enhancement: Super Progressive Web Apps now accounts for content updates and will update the cache as you update the website.
409
+ * Enhancement: Improved in-browser service worker update handling.
410
+ * Enhancement: Added automatic upgrade of manifest and service worker on plugin upgrade.
411
+
412
+ = 1.2 =
413
+ * New Feature: Support for theme-color.
414
+ * New Feature: Now you can edit the Application Name and Application Short name.
415
+ * New Feature: Set the start page of your PWA.
416
+ * New Feature: Set AMP version of the start page. Supported plugins: AMP for WordPress, AMP for WP, Better AMP, AMP Supremacy, WP AMP.
417
+ * UI Improvement: Better organization of plugin settings. More intuitive with inline help.
418
+ * UI Improvement: Added admin notice with a link to settings page on plugin activation.
419
+ * UI Improvement: Added checks for manifest, service worker and HTTPS and display the status neatly in the UI.
420
+ * Bug Fix: Fix a parse error that showed up only on PHP 5.3.
421
+
422
+ = 1.1.1 =
423
+ * Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context". PHP manual says "Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error."
424
+
425
+ = 1.1 =
426
+ * New Feature: Aggressive caching of pages using CacheStorage API.
427
+ * New Feature: Pages once cached are served even if the user is offline.
428
+ * New Feature: Set custom offline page: Select the page you want the user to see when a page that isn't in the cache is accessed and the user is offline.
429
+
430
+ = 1.0 =
431
+ * First release of the plugin.
superpwa.php CHANGED
@@ -1,80 +1,80 @@
1
- <?php
2
- /**
3
- * Plugin Name: Super Progressive Web Apps
4
- * Plugin URI: https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=plugin-uri
5
- * Description: Convert your WordPress website into a Progressive Web App
6
- * Author: SuperPWA
7
- * Author URI: https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=author-uri
8
- * Contributors: Arun Basil Lal, Jose Varghese
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
13
- */
14
-
15
- /**
16
- * ~ Directory Structure ~
17
- *
18
- * Based on the WordPress starter plugin template
19
- * @link https://github.com/arunbasillal/WordPress-Starter-Plugin
20
- *
21
- * /3rd-party/ - Functions for compatibility with 3rd party plugins and hosts.
22
- * /addons/ - Bundled add-ons
23
- * /admin/ - Plugin backend.
24
- * /functions/ - Functions and utilites.
25
- * /includes/ - External third party classes and libraries.
26
- * /languages/ - Translation files go here.
27
- * /public/ - Front end files go here.
28
- * index.php - Dummy file.
29
- * license.txt - GPL v2
30
- * loader.php - Loads everything.
31
- * superpwa.php - Main plugin file.
32
- * README.MD - Readme for GitHub.
33
- * readme.txt - Readme for WordPress plugin repository.
34
- * uninstall.php - Fired when the plugin is uninstalled.
35
- */
36
-
37
- // Exit if accessed directly
38
- if ( ! defined('ABSPATH') ) exit;
39
-
40
- /**
41
- * SuperPWA current version
42
- *
43
- * @since 1.0
44
- */
45
- if ( ! defined( 'SUPERPWA_VERSION' ) ) {
46
- define( 'SUPERPWA_VERSION' , '2.1' );
47
- }
48
-
49
- /**
50
- * Absolute path to the plugin directory.
51
- * eg - /var/www/html/wp-content/plugins/super-progressive-web-apps/
52
- *
53
- * @since 1.0
54
- */
55
- if ( ! defined( 'SUPERPWA_PATH_ABS' ) ) {
56
- define( 'SUPERPWA_PATH_ABS' , plugin_dir_path( __FILE__ ) );
57
- }
58
-
59
- /**
60
- * Link to the plugin folder.
61
- * eg - https://example.com/wp-content/plugins/super-progressive-web-apps/
62
- *
63
- * @since 1.0
64
- */
65
- if ( ! defined( 'SUPERPWA_PATH_SRC' ) ) {
66
- define( 'SUPERPWA_PATH_SRC' , plugin_dir_url( __FILE__ ) );
67
- }
68
-
69
- /**
70
- * Full path to the plugin file.
71
- * eg - /var/www/html/wp-content/plugins/Super-Progressive-Web-Apps/superpwa.php
72
- *
73
- * @since 2.0
74
- */
75
- if ( ! defined( 'SUPERPWA_PLUGIN_FILE' ) ) {
76
- define( 'SUPERPWA_PLUGIN_FILE', __FILE__ );
77
- }
78
-
79
- // Load everything
80
- require_once( SUPERPWA_PATH_ABS . 'loader.php' );
1
+ <?php
2
+ /**
3
+ * Plugin Name: Super Progressive Web Apps
4
+ * Plugin URI: https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=plugin-uri
5
+ * Description: Convert your WordPress website into a Progressive Web App
6
+ * Author: SuperPWA
7
+ * Author URI: https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=author-uri
8
+ * Contributors: Arun Basil Lal, Jose Varghese
9
+ * Version: 2.1.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
13
+ */
14
+
15
+ /**
16
+ * ~ Directory Structure ~
17
+ *
18
+ * Based on the WordPress starter plugin template
19
+ * @link https://github.com/arunbasillal/WordPress-Starter-Plugin
20
+ *
21
+ * /3rd-party/ - Functions for compatibility with 3rd party plugins and hosts.
22
+ * /addons/ - Bundled add-ons
23
+ * /admin/ - Plugin backend.
24
+ * /functions/ - Functions and utilites.
25
+ * /includes/ - External third party classes and libraries.
26
+ * /languages/ - Translation files go here.
27
+ * /public/ - Front end files go here.
28
+ * index.php - Dummy file.
29
+ * license.txt - GPL v2
30
+ * loader.php - Loads everything.
31
+ * superpwa.php - Main plugin file.
32
+ * README.MD - Readme for GitHub.
33
+ * readme.txt - Readme for WordPress plugin repository.
34
+ * uninstall.php - Fired when the plugin is uninstalled.
35
+ */
36
+
37
+ // Exit if accessed directly
38
+ if ( ! defined('ABSPATH') ) exit;
39
+
40
+ /**
41
+ * SuperPWA current version
42
+ *
43
+ * @since 1.0
44
+ */
45
+ if ( ! defined( 'SUPERPWA_VERSION' ) ) {
46
+ define( 'SUPERPWA_VERSION' , '2.1.1' );
47
+ }
48
+
49
+ /**
50
+ * Absolute path to the plugin directory.
51
+ * eg - /var/www/html/wp-content/plugins/super-progressive-web-apps/
52
+ *
53
+ * @since 1.0
54
+ */
55
+ if ( ! defined( 'SUPERPWA_PATH_ABS' ) ) {
56
+ define( 'SUPERPWA_PATH_ABS' , plugin_dir_path( __FILE__ ) );
57
+ }
58
+
59
+ /**
60
+ * Link to the plugin folder.
61
+ * eg - https://example.com/wp-content/plugins/super-progressive-web-apps/
62
+ *
63
+ * @since 1.0
64
+ */
65
+ if ( ! defined( 'SUPERPWA_PATH_SRC' ) ) {
66
+ define( 'SUPERPWA_PATH_SRC' , plugin_dir_url( __FILE__ ) );
67
+ }
68
+
69
+ /**
70
+ * Full path to the plugin file.
71
+ * eg - /var/www/html/wp-content/plugins/Super-Progressive-Web-Apps/superpwa.php
72
+ *
73
+ * @since 2.0
74
+ */
75
+ if ( ! defined( 'SUPERPWA_PLUGIN_FILE' ) ) {
76
+ define( 'SUPERPWA_PLUGIN_FILE', __FILE__ );
77
+ }
78
+
79
+ // Load everything
80
+ require_once( SUPERPWA_PATH_ABS . 'loader.php' );
uninstall.php CHANGED
@@ -1,56 +1,56 @@
1
- <?php
2
- /**
3
- * Fired when the plugin is uninstalled.
4
- *
5
- * Everything in uninstall.php will be executed when user decides to delete the plugin.
6
- *
7
- * @since 1.0
8
- */
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) ) exit;
12
-
13
- // If uninstall not called from WordPress, then die.
14
- if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) die;
15
-
16
- /**
17
- * Delete database settings
18
- *
19
- * @since 1.0
20
- * @since 1.7 Added clean-up for superpwa_active_addons and superpwa_utm_tracking_settings
21
- */
22
- delete_option( 'superpwa_settings' );
23
- delete_option( 'superpwa_active_addons' );
24
- delete_option( 'superpwa_utm_tracking_settings' );
25
- delete_option( 'superpwa_version' );
26
-
27
- /**
28
- * Clean up for Multisites
29
- *
30
- * @since 1.6
31
- * @since 1.7 Added clean-up for superpwa_active_addons and superpwa_utm_tracking_settings
32
- */
33
- if ( is_multisite() ) {
34
-
35
- // Retrieve the list of blog ids where SuperPWA is active. (saved with blog_id as $key and activation_status as $value)
36
- $superpwa_sites = get_site_option( 'superpwa_active_sites' );
37
-
38
- // Loop through each active site.
39
- foreach( $superpwa_sites as $blog_id => $actviation_status ) {
40
-
41
- // Switch to each blog
42
- switch_to_blog( $blog_id );
43
-
44
- // Delete database settings for each site.
45
- delete_option( 'superpwa_settings' );
46
- delete_option( 'superpwa_active_addons' );
47
- delete_option( 'superpwa_utm_tracking_settings' );
48
- delete_option( 'superpwa_version' );
49
-
50
- // Return to main site
51
- restore_current_blog();
52
- }
53
-
54
- // Delete the list of websites where SuperPWA was activated.
55
- delete_site_option( 'superpwa_active_sites' );
56
  }
1
+ <?php
2
+ /**
3
+ * Fired when the plugin is uninstalled.
4
+ *
5
+ * Everything in uninstall.php will be executed when user decides to delete the plugin.
6
+ *
7
+ * @since 1.0
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ // If uninstall not called from WordPress, then die.
14
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) die;
15
+
16
+ /**
17
+ * Delete database settings
18
+ *
19
+ * @since 1.0
20
+ * @since 1.7 Added clean-up for superpwa_active_addons and superpwa_utm_tracking_settings
21
+ */
22
+ delete_option( 'superpwa_settings' );
23
+ delete_option( 'superpwa_active_addons' );
24
+ delete_option( 'superpwa_utm_tracking_settings' );
25
+ delete_option( 'superpwa_version' );
26
+
27
+ /**
28
+ * Clean up for Multisites
29
+ *
30
+ * @since 1.6
31
+ * @since 1.7 Added clean-up for superpwa_active_addons and superpwa_utm_tracking_settings
32
+ */
33
+ if ( is_multisite() ) {
34
+
35
+ // Retrieve the list of blog ids where SuperPWA is active. (saved with blog_id as $key and activation_status as $value)
36
+ $superpwa_sites = get_site_option( 'superpwa_active_sites' );
37
+
38
+ // Loop through each active site.
39
+ foreach( $superpwa_sites as $blog_id => $actviation_status ) {
40
+
41
+ // Switch to each blog
42
+ switch_to_blog( $blog_id );
43
+
44
+ // Delete database settings for each site.
45
+ delete_option( 'superpwa_settings' );
46
+ delete_option( 'superpwa_active_addons' );
47
+ delete_option( 'superpwa_utm_tracking_settings' );
48
+ delete_option( 'superpwa_version' );
49
+
50
+ // Return to main site
51
+ restore_current_blog();
52
+ }
53
+
54
+ // Delete the list of websites where SuperPWA was activated.
55
+ delete_site_option( 'superpwa_active_sites' );
56
  }