Version Description
- Date: 03.May.2018
- Minimum required WordPress version is now 3.6.0 (previously 3.5.0).
- New Feature: Add-Ons for SuperPWA is here!
- New Feature: SuperPWA is now a top-level menu to accommodate for the Add-Ons sub-menu page.
- New Feature: Add UTM Tracking parameters to the Start URL with the UTM Tracking Add-On.
- Enhancement: Service worker URLs are now relative to accommodate for domain mapped Multisites.
- Bug Fix: Incorrect start_url when WordPress is installed in a folder, or when inner pages are used as start_url.
- Bug Fix: Incorrect manifest and service worker URLs when WordPress is installed in a folder.
Download this release
Release Info
Developer | arunbasillal |
Plugin | Super Progressive Web Apps |
Version | 1.7 |
Comparing to | |
See all releases |
Code changes from version 1.6 to 1.7
- README.MD +62 -27
- addons/index.php +2 -0
- addons/utm-tracking.php +387 -0
- admin/admin-setup.php +12 -4
- admin/admin-ui-render-addons.php +466 -0
- admin/{admin-ui-render.php → admin-ui-render-settings.php} +13 -13
- admin/img/email.png +0 -0
- admin/img/superpwa-128x128.png +0 -0
- admin/img/superpwa-menu-icon.png +0 -0
- functions/common.php +25 -17
- loader.php +8 -2
- public/manifest.php +10 -6
- public/sw.php +20 -12
- readme.txt +25 -5
- superpwa.php +2 -2
- uninstall.php +7 -0
README.MD
CHANGED
@@ -9,7 +9,35 @@
|
|
9 |
|
10 |
|
11 |
</p>
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
<a href="https://superpwa.com">
|
14 |
<img src="https://lighthouse-badge.appspot.com?score=100" alt="LightHouse Score">
|
15 |
</a>
|
@@ -28,9 +56,8 @@
|
|
28 |
</p>
|
29 |
|
30 |
## Welcome to the Super PWA GitHub repository
|
31 |
-
> <a href="https://superpwa.com">SuperPWA</a> helps you convert your WordPress website into a Progressive Web App.
|
32 |
|
33 |
-
|
34 |
|
35 |
## What is Progressive Web Apps
|
36 |
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.
|
@@ -39,15 +66,15 @@ Users can come back to your website by launching the app from their home screen
|
|
39 |
|
40 |
<a href="https://superpwa.com">Super Progressive Web Apps</a> makes it easy for you to convert your WordPress website into a Progressive Web App easily!
|
41 |
|
42 |
-
## Installation
|
43 |
-
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!
|
44 |
|
45 |
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.
|
46 |
|
47 |
-
### Progressive Web App Minimum Requirments
|
48 |
- [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.
|
49 |
|
50 |
-
#### What's in the box
|
51 |
|
52 |
Here are the current features of Super Progressive Web Apps:
|
53 |
|
@@ -70,14 +97,14 @@ Here are the current features of Super Progressive Web Apps:
|
|
70 |
* New in version 1.5: OneSignal integration for Push notifications.
|
71 |
* New in version 1.6: WordPress Multisite Network compatibility.
|
72 |
|
73 |
-
#### Upcoming features:
|
74 |
* Offline Indicator Notice.
|
75 |
|
76 |
### Device and Browser Support For PWA
|
77 |
-
| <img src="https://user-images.githubusercontent.com/1215767/34348387-a2e64588-ea4d-11e7-8267-a43365103afe.png" alt="Chrome" width="16px" height="16px" /> Chrome | <img src="https://user-images.githubusercontent.com/1215767/34348383-9e7ed492-ea4d-11e7-910c-03b39d52f496.png" alt="Firefox" width="16px" height="16px" /> Firefox | <img src="https://user-images.githubusercontent.com/1215767/34348394-a981f892-ea4d-11e7-9156-d128d58386b9.png" alt="Safari" width="16px" height="16px" /> Safari | <img src="https://user-images.githubusercontent.com/1215767/34348380-93e77ae8-ea4d-11e7-8696-9a989ddbbbf5.png" alt="Edge" width="16px" height="16px" /> Edge | Opera Mini | Samsung Internet | Brave |
|
78 |
-
| :---------: | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: |
|
79 |
-
| Yes | Yes | Partially | Beta | No | Yes | Yes |
|
80 |
-
| 57+ | 57+ | 11.3+ | 17 ships | - | 6.2+ | 1.0.44+
|
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 |
|
@@ -88,13 +115,13 @@ The list is fast growing and is likely to be supported in most major browsers by
|
|
88 |
|
89 |
### How To Convert Your WordPress Website Into A Progressive Web App
|
90 |
|
91 |
-
#### WordPress Installation
|
92 |
|
93 |
* Visit WordPress Admin > **Plugins** > **Add New**
|
94 |
* Search for **Super Progressive Web Apps**
|
95 |
* Click "**Install Now**" and then "**Activate**" Super Progressive Web Apps
|
96 |
|
97 |
-
#### To install manually:
|
98 |
|
99 |
* Upload super-progressive-web-apps folder to the /wp-content/plugins/ directory on your server
|
100 |
* Go to WordPress Admin > **Plugins**
|
@@ -121,32 +148,40 @@ Your Progressive Web App should be ready to test with the default settings upon
|
|
121 |
* 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.
|
122 |
|
123 |
|
124 |
-
### About us
|
125 |
> 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.
|
126 |
|
127 |
-
## Support
|
128 |
This is a developer's portal for Super Progressive Web Apps and should not be used for support. Please visit the
|
129 |
[Support Forums](https://wordpress.org/support/plugin/super-progressive-web-apps).
|
130 |
|
131 |
-
## Reporting bugs
|
132 |
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!
|
133 |
|
134 |
-
## Contributions
|
135 |
Anyone is welcome to contribute to Super PWA to make it SUPER.
|
136 |
|
137 |
There are various ways you can contribute:
|
138 |
|
139 |
* [Raise an issue](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues) on GitHub.
|
140 |
-
* Engage with us on Social Media
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
143 |
* Send us a Pull Request with your bug fixes and/or new features.
|
144 |
* 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).
|
145 |
-
* ##### Share via Social Media's
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
150 |
|
151 |
**[⬆ back to top](#super-progressive-web-apps)**
|
152 |
-
<img src="https://ga-beacon.appspot.com/UA-115873914-2/GitHub_Readme?pixel"/>
|
9 |
|
10 |
|
11 |
</p>
|
12 |
+
|
13 |
+
<p align="center">
|
14 |
+
<a href="https://superpwa.com">
|
15 |
+
<img src="https://pbs.twimg.com/profile_images/975224418543681536/X9-CESOD_400x400.jpg" alt="" width=150 height=150>
|
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"><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">
|
42 |
<img src="https://lighthouse-badge.appspot.com?score=100" alt="LightHouse Score">
|
43 |
</a>
|
56 |
</p>
|
57 |
|
58 |
## Welcome to the Super PWA GitHub repository
|
|
|
59 |
|
60 |
+
⚡️ Demo : <a href="https://superpwa.com/?utm=GitHub">superpwa.com</a>
|
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.
|
66 |
|
67 |
<a href="https://superpwa.com">Super Progressive Web Apps</a> makes it easy for you to convert your WordPress website into a Progressive Web App easily!
|
68 |
|
69 |
+
## 🏗 Installation
|
70 |
+
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!
|
71 |
|
72 |
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.
|
73 |
|
74 |
+
### 💡 Progressive Web App Minimum Requirments
|
75 |
- [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.
|
76 |
|
77 |
+
#### 📦 What's in the box
|
78 |
|
79 |
Here are the current features of Super Progressive Web Apps:
|
80 |
|
97 |
* New in version 1.5: OneSignal integration for Push notifications.
|
98 |
* New in version 1.6: WordPress Multisite Network compatibility.
|
99 |
|
100 |
+
#### 🔮 Upcoming features:
|
101 |
* Offline Indicator Notice.
|
102 |
|
103 |
### Device and Browser Support For PWA
|
104 |
+
| <img src="https://user-images.githubusercontent.com/1215767/34348387-a2e64588-ea4d-11e7-8267-a43365103afe.png" alt="Chrome" width="16px" height="16px" /> Chrome | <img src="https://user-images.githubusercontent.com/1215767/34348383-9e7ed492-ea4d-11e7-910c-03b39d52f496.png" alt="Firefox" width="16px" height="16px" /> Firefox | <img src="https://user-images.githubusercontent.com/1215767/34348394-a981f892-ea4d-11e7-9156-d128d58386b9.png" alt="Safari" width="16px" height="16px" /> Safari | <img src="https://user-images.githubusercontent.com/1215767/34348380-93e77ae8-ea4d-11e7-8696-9a989ddbbbf5.png" alt="Edge" width="16px" height="16px" /> Edge | <img src="https://user-images.githubusercontent.com/1215767/34348380-93e77ae8-ea4d-11e7-8696-9a989ddbbbf5.png" alt="Edge" width="16px" height="16px" /> Edge (Mobile) | Opera Mini | Samsung Internet | Brave |
|
105 |
+
| :---------: | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: | :---------: |
|
106 |
+
| Yes | Yes | Partially | Beta | Yes | No | Yes | Yes |
|
107 |
+
| 57+ | 57+ | 11.3+ | 17 ships | 1.0.0.1921 | - | 6.2+ | 1.0.44+
|
108 |
|
109 |
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.
|
110 |
|
115 |
|
116 |
### How To Convert Your WordPress Website Into A Progressive Web App
|
117 |
|
118 |
+
#### ⚙️ WordPress Installation
|
119 |
|
120 |
* Visit WordPress Admin > **Plugins** > **Add New**
|
121 |
* Search for **Super Progressive Web Apps**
|
122 |
* Click "**Install Now**" and then "**Activate**" Super Progressive Web Apps
|
123 |
|
124 |
+
#### ⚙️ To install manually:
|
125 |
|
126 |
* Upload super-progressive-web-apps folder to the /wp-content/plugins/ directory on your server
|
127 |
* Go to WordPress Admin > **Plugins**
|
148 |
* 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.
|
149 |
|
150 |
|
151 |
+
### 🤝 About us
|
152 |
> 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.
|
153 |
|
154 |
+
## ⛷️ Support
|
155 |
This is a developer's portal for Super Progressive Web Apps and should not be used for support. Please visit the
|
156 |
[Support Forums](https://wordpress.org/support/plugin/super-progressive-web-apps).
|
157 |
|
158 |
+
## 🐛 Reporting bugs
|
159 |
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!
|
160 |
|
161 |
+
## 🎍 Contributions
|
162 |
Anyone is welcome to contribute to Super PWA to make it SUPER.
|
163 |
|
164 |
There are various ways you can contribute:
|
165 |
|
166 |
* [Raise an issue](https://github.com/SuperPWA/Super-Progressive-Web-Apps/issues) on GitHub.
|
167 |
+
* Follow and Engage with us on Social Media
|
168 |
+
|
169 |
+
<a href="https://twitter.com/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>
|
170 |
+
<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>
|
171 |
+
<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>
|
172 |
+
<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>
|
173 |
+
<a href="https://plus.google.com/+SuperPWA" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174851.svg" title="Follow on Google+" width=35 height=35></a>
|
174 |
+
|
175 |
* Send us a Pull Request with your bug fixes and/or new features.
|
176 |
* 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).
|
177 |
+
* ##### Share via Social Media's and spread SuperPWA
|
178 |
+
|
179 |
+
<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>
|
180 |
+
<p> <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> </p>
|
181 |
+
<p> <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> </p>
|
182 |
+
<p> <a href="https://plus.google.com/share?url=https%3A//github.com/SuperPWA/Super-Progressive-Web-Apps/" target="_blank" style="width:100%"><img src="https://image.flaticon.com/icons/svg/174/174851.svg" title="Share on Google+" width=20 height=20> Share on Google+ </a> </p>
|
183 |
+
|
184 |
+
Emoji Credits : [Emojipedia](emojipedia.org)
|
185 |
+
Social Media Icon Credits : [Flaticon](flaticon.com)
|
186 |
|
187 |
**[⬆ back to top](#super-progressive-web-apps)**
|
|
addons/index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden
|
addons/utm-tracking.php
ADDED
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
);
|
49 |
+
|
50 |
+
return get_option( 'superpwa_utm_tracking_settings', $defaults );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Add UTM Tracking to the start_url
|
55 |
+
*
|
56 |
+
* Hooks onto the superpwa_manifest_start_url filter to add the
|
57 |
+
* UTM tracking parameters to the start_url
|
58 |
+
*
|
59 |
+
* Example: https://superpwa.com/?utm_source=superpwa&utm_medium=medium&utm_campaign=name&utm_term=terms&utm_content=content
|
60 |
+
*
|
61 |
+
* @param $start_url (string) the start_url for manifest from superpwa_get_start_url()
|
62 |
+
* @return (string) Filtered start_url with UTM tracking added
|
63 |
+
*
|
64 |
+
* @since 1.7
|
65 |
+
*/
|
66 |
+
function superpwa_utm_tracking_for_start_url( $start_url ) {
|
67 |
+
|
68 |
+
// Get UTM Tracking settings
|
69 |
+
$utm_params = superpwa_utm_tracking_get_settings();
|
70 |
+
|
71 |
+
// Add the initial '/?'
|
72 |
+
$start_url = trailingslashit( $start_url ) . '?';
|
73 |
+
|
74 |
+
// Build the URL
|
75 |
+
foreach ( $utm_params as $param => $value ) {
|
76 |
+
|
77 |
+
if ( ! empty( $value ) ) {
|
78 |
+
$start_url = $start_url . $param . '=' . rawurlencode( $value ) . '&';
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
// Remove trailing '&'
|
83 |
+
return rtrim( $start_url, '&' );
|
84 |
+
}
|
85 |
+
add_filter( 'superpwa_manifest_start_url', 'superpwa_utm_tracking_for_start_url' );
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Todo list after saving UTM Tracking settings
|
89 |
+
*
|
90 |
+
* Regenerate manifest when settings are saved.
|
91 |
+
* Also used when add-on is activated and deactivated.
|
92 |
+
*
|
93 |
+
* @since 1.7
|
94 |
+
*/
|
95 |
+
function superpwa_utm_tracking_save_settings_todo() {
|
96 |
+
|
97 |
+
// Regenerate manifest
|
98 |
+
superpwa_generate_manifest();
|
99 |
+
}
|
100 |
+
add_action( 'add_option_superpwa_utm_tracking_settings', 'superpwa_utm_tracking_save_settings_todo' );
|
101 |
+
add_action( 'update_option_superpwa_utm_tracking_settings', 'superpwa_utm_tracking_save_settings_todo' );
|
102 |
+
add_action( 'superpwa_addon_activated_utm_tracking', 'superpwa_utm_tracking_save_settings_todo' );
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Deactivation Todo
|
106 |
+
*
|
107 |
+
* Unhook the filter and regenerate manifest
|
108 |
+
*
|
109 |
+
* @since 1.7
|
110 |
+
*/
|
111 |
+
function superpwa_utm_tracking_deactivate_todo() {
|
112 |
+
|
113 |
+
// Unhook the UTM tracking params filter
|
114 |
+
remove_filter( 'superpwa_manifest_start_url', 'superpwa_utm_tracking_for_start_url' );
|
115 |
+
|
116 |
+
// Regenerate manifest
|
117 |
+
superpwa_generate_manifest();
|
118 |
+
}
|
119 |
+
add_action( 'superpwa_addon_deactivated_utm_tracking', 'superpwa_utm_tracking_deactivate_todo' );
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Register UTM Tracking settings
|
123 |
+
*
|
124 |
+
* @since 1.7
|
125 |
+
*/
|
126 |
+
function superpwa_utm_tracking_register_settings() {
|
127 |
+
|
128 |
+
// Register Setting
|
129 |
+
register_setting(
|
130 |
+
'superpwa_utm_tracking_settings_group', // Group name
|
131 |
+
'superpwa_utm_tracking_settings', // Setting name = html form <input> name on settings form
|
132 |
+
'superpwa_utm_tracking_validater_sanitizer' // Input validator and sanitizer
|
133 |
+
);
|
134 |
+
|
135 |
+
// UTM Tracking
|
136 |
+
add_settings_section(
|
137 |
+
'superpwa_utm_tracking_section', // ID
|
138 |
+
__return_false(), // Title
|
139 |
+
'superpwa_utm_tracking_section_cb', // Callback Function
|
140 |
+
'superpwa_utm_tracking_section' // Page slug
|
141 |
+
);
|
142 |
+
|
143 |
+
// Current Start URL
|
144 |
+
add_settings_field(
|
145 |
+
'superpwa_utm_tracking_start_url', // ID
|
146 |
+
__('Current Start URL', 'super-progressive-web-apps'), // Title
|
147 |
+
'superpwa_utm_tracking_start_url_cb', // CB
|
148 |
+
'superpwa_utm_tracking_section', // Page slug
|
149 |
+
'superpwa_utm_tracking_section' // Settings Section ID
|
150 |
+
);
|
151 |
+
|
152 |
+
// Campaign Source
|
153 |
+
add_settings_field(
|
154 |
+
'superpwa_utm_tracking_source', // ID
|
155 |
+
__('Campaign Source', 'super-progressive-web-apps'), // Title
|
156 |
+
'superpwa_utm_tracking_source_cb', // CB
|
157 |
+
'superpwa_utm_tracking_section', // Page slug
|
158 |
+
'superpwa_utm_tracking_section' // Settings Section ID
|
159 |
+
);
|
160 |
+
|
161 |
+
// Campaign Medium
|
162 |
+
add_settings_field(
|
163 |
+
'superpwa_utm_tracking_medium', // ID
|
164 |
+
__('Campaign Medium', 'super-progressive-web-apps'), // Title
|
165 |
+
'superpwa_utm_tracking_medium_cb', // CB
|
166 |
+
'superpwa_utm_tracking_section', // Page slug
|
167 |
+
'superpwa_utm_tracking_section' // Settings Section ID
|
168 |
+
);
|
169 |
+
|
170 |
+
// Campaign Name
|
171 |
+
add_settings_field(
|
172 |
+
'superpwa_utm_tracking_name', // ID
|
173 |
+
__('Campaign Name', 'super-progressive-web-apps'), // Title
|
174 |
+
'superpwa_utm_tracking_name_cb', // CB
|
175 |
+
'superpwa_utm_tracking_section', // Page slug
|
176 |
+
'superpwa_utm_tracking_section' // Settings Section ID
|
177 |
+
);
|
178 |
+
|
179 |
+
// Campaign Term
|
180 |
+
add_settings_field(
|
181 |
+
'superpwa_utm_tracking_term', // ID
|
182 |
+
__('Campaign Term', 'super-progressive-web-apps'), // Title
|
183 |
+
'superpwa_utm_tracking_term_cb', // CB
|
184 |
+
'superpwa_utm_tracking_section', // Page slug
|
185 |
+
'superpwa_utm_tracking_section' // Settings Section ID
|
186 |
+
);
|
187 |
+
|
188 |
+
// Campaign Content
|
189 |
+
add_settings_field(
|
190 |
+
'superpwa_utm_tracking_content', // ID
|
191 |
+
__('Campaign Content', 'super-progressive-web-apps'), // Title
|
192 |
+
'superpwa_utm_tracking_content_cb', // CB
|
193 |
+
'superpwa_utm_tracking_section', // Page slug
|
194 |
+
'superpwa_utm_tracking_section' // Settings Section ID
|
195 |
+
);
|
196 |
+
}
|
197 |
+
add_action( 'admin_init', 'superpwa_utm_tracking_register_settings' );
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Validate and sanitize user input
|
201 |
+
*
|
202 |
+
* @since 1.7
|
203 |
+
*/
|
204 |
+
function superpwa_utm_tracking_validater_sanitizer( $settings ) {
|
205 |
+
|
206 |
+
// Sanitize and validate campaign source. Campaign source cannot be empty.
|
207 |
+
$settings['utm_source'] = sanitize_text_field( $settings['utm_source'] ) == '' ? 'superpwa' : sanitize_text_field( $settings['utm_source'] );
|
208 |
+
|
209 |
+
// Sanitize campaign medium
|
210 |
+
$settings['utm_medium'] = sanitize_text_field( $settings['utm_medium'] );
|
211 |
+
|
212 |
+
// Sanitize campaign name
|
213 |
+
$settings['utm_campaign'] = sanitize_text_field( $settings['utm_campaign'] );
|
214 |
+
|
215 |
+
// Sanitize campaign term
|
216 |
+
$settings['utm_term'] = sanitize_text_field( $settings['utm_term'] );
|
217 |
+
|
218 |
+
// Sanitize campaign medium
|
219 |
+
$settings['utm_content'] = sanitize_text_field( $settings['utm_content'] );
|
220 |
+
|
221 |
+
return $settings;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Callback function for UTM Tracking section
|
226 |
+
*
|
227 |
+
* @since 1.7
|
228 |
+
*/
|
229 |
+
function superpwa_utm_tracking_section_cb() {
|
230 |
+
|
231 |
+
// Get add-on info
|
232 |
+
$addon_utm_tracking = superpwa_get_addons( 'utm_tracking' );
|
233 |
+
|
234 |
+
printf( '<p>' . __( 'Add 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' );
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Current Start URL
|
239 |
+
*
|
240 |
+
* @since 1.7
|
241 |
+
*/
|
242 |
+
function superpwa_utm_tracking_start_url_cb() {
|
243 |
+
|
244 |
+
echo '<code>' . superpwa_get_start_url( true ) . '</code>';
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Campaign Source
|
249 |
+
*
|
250 |
+
* @since 1.7
|
251 |
+
*/
|
252 |
+
function superpwa_utm_tracking_source_cb() {
|
253 |
+
|
254 |
+
// Get Settings
|
255 |
+
$settings = superpwa_utm_tracking_get_settings(); ?>
|
256 |
+
|
257 |
+
<fieldset>
|
258 |
+
|
259 |
+
<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'] ); ?>"/>
|
260 |
+
|
261 |
+
</fieldset>
|
262 |
+
|
263 |
+
<p class="description" id="tagline-description">
|
264 |
+
<?php _e( 'Source is mandatory and defaults to <code>superpwa</code>', 'super-progressive-web-apps' ); ?>
|
265 |
+
</p>
|
266 |
+
|
267 |
+
<?php
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Campaign Medium
|
272 |
+
*
|
273 |
+
* @since 1.7
|
274 |
+
*/
|
275 |
+
function superpwa_utm_tracking_medium_cb() {
|
276 |
+
|
277 |
+
// Get Settings
|
278 |
+
$settings = superpwa_utm_tracking_get_settings(); ?>
|
279 |
+
|
280 |
+
<fieldset>
|
281 |
+
|
282 |
+
<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'] ); ?>"/>
|
283 |
+
|
284 |
+
</fieldset>
|
285 |
+
|
286 |
+
<?php
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Campaign Name
|
291 |
+
*
|
292 |
+
* @since 1.7
|
293 |
+
*/
|
294 |
+
function superpwa_utm_tracking_name_cb() {
|
295 |
+
|
296 |
+
// Get Settings
|
297 |
+
$settings = superpwa_utm_tracking_get_settings(); ?>
|
298 |
+
|
299 |
+
<fieldset>
|
300 |
+
|
301 |
+
<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'] ); ?>"/>
|
302 |
+
|
303 |
+
</fieldset>
|
304 |
+
|
305 |
+
<?php
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Campaign Term
|
310 |
+
*
|
311 |
+
* @since 1.7
|
312 |
+
*/
|
313 |
+
function superpwa_utm_tracking_term_cb() {
|
314 |
+
|
315 |
+
// Get Settings
|
316 |
+
$settings = superpwa_utm_tracking_get_settings(); ?>
|
317 |
+
|
318 |
+
<fieldset>
|
319 |
+
|
320 |
+
<input type="text" name="superpwa_utm_tracking_settings[utm_term]" class="regular-text" value="<?php if ( isset( $settings['utm_term'] ) && ( ! empty($settings['utm_term']) ) ) echo esc_attr( $settings['utm_term'] ); ?>"/>
|
321 |
+
|
322 |
+
</fieldset>
|
323 |
+
|
324 |
+
<?php
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Campaign Content
|
329 |
+
*
|
330 |
+
* @since 1.7
|
331 |
+
*/
|
332 |
+
function superpwa_utm_tracking_content_cb() {
|
333 |
+
|
334 |
+
// Get Settings
|
335 |
+
$settings = superpwa_utm_tracking_get_settings(); ?>
|
336 |
+
|
337 |
+
<fieldset>
|
338 |
+
|
339 |
+
<input type="text" name="superpwa_utm_tracking_settings[utm_content]" class="regular-text" value="<?php if ( isset( $settings['utm_content'] ) && ( ! empty($settings['utm_content']) ) ) echo esc_attr( $settings['utm_content'] ); ?>"/>
|
340 |
+
|
341 |
+
</fieldset>
|
342 |
+
|
343 |
+
<?php
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
* UTM Tracking UI renderer
|
348 |
+
*
|
349 |
+
* @since 1.7
|
350 |
+
*/
|
351 |
+
function superpwa_utm_tracking_interface_render() {
|
352 |
+
|
353 |
+
// Authentication
|
354 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
355 |
+
return;
|
356 |
+
}
|
357 |
+
|
358 |
+
// Handing save settings
|
359 |
+
if ( isset( $_GET['settings-updated'] ) ) {
|
360 |
+
|
361 |
+
// Add settings saved message with the class of "updated"
|
362 |
+
add_settings_error( 'superpwa_settings_group', 'superpwa_utm_tracking_settings_saved_message', __( 'Settings saved.', 'super-progressive-web-apps' ), 'updated' );
|
363 |
+
|
364 |
+
// Show Settings Saved Message
|
365 |
+
settings_errors( 'superpwa_settings_group' );
|
366 |
+
}
|
367 |
+
|
368 |
+
?>
|
369 |
+
|
370 |
+
<div class="wrap">
|
371 |
+
<h1><?php _e( 'UTM Tracking for', 'super-progressive-web-apps' ); ?> SuperPWA <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
|
372 |
+
|
373 |
+
<form action="options.php" method="post" enctype="multipart/form-data">
|
374 |
+
<?php
|
375 |
+
// Output nonce, action, and option_page fields for a settings page.
|
376 |
+
settings_fields( 'superpwa_utm_tracking_settings_group' );
|
377 |
+
|
378 |
+
// Status
|
379 |
+
do_settings_sections( 'superpwa_utm_tracking_section' ); // Page slug
|
380 |
+
|
381 |
+
// Output save settings button
|
382 |
+
submit_button( __('Save Settings', 'super-progressive-web-apps') );
|
383 |
+
?>
|
384 |
+
</form>
|
385 |
+
</div>
|
386 |
+
<?php
|
387 |
+
}
|
admin/admin-setup.php
CHANGED
@@ -22,7 +22,15 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
|
22 |
* @refer https://developer.wordpress.org/plugins/administration-menus/
|
23 |
*/
|
24 |
function superpwa_add_menu_links() {
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
add_action( 'admin_menu', 'superpwa_add_menu_links' );
|
28 |
|
@@ -243,7 +251,7 @@ function superpwa_get_settings() {
|
|
243 |
function superpwa_enqueue_css_js( $hook ) {
|
244 |
|
245 |
// Load only on SuperPWA plugin pages
|
246 |
-
if ( $hook
|
247 |
return;
|
248 |
}
|
249 |
|
@@ -289,7 +297,7 @@ function superpwa_footer_text( $default ) {
|
|
289 |
|
290 |
// Retun default on non-plugin pages
|
291 |
$screen = get_current_screen();
|
292 |
-
if ( $screen->id
|
293 |
return $default;
|
294 |
}
|
295 |
|
@@ -311,7 +319,7 @@ function superpwa_footer_version( $default ) {
|
|
311 |
|
312 |
// Retun default on non-plugin pages
|
313 |
$screen = get_current_screen();
|
314 |
-
if ( $screen->id
|
315 |
return $default;
|
316 |
}
|
317 |
|
22 |
* @refer https://developer.wordpress.org/plugins/administration-menus/
|
23 |
*/
|
24 |
function superpwa_add_menu_links() {
|
25 |
+
|
26 |
+
// Main menu page
|
27 |
+
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 );
|
28 |
+
|
29 |
+
// Settings page - Same as main menu page
|
30 |
+
add_submenu_page( 'superpwa', __( 'Super Progressive Web Apps', 'super-progressive-web-apps' ), __( 'Settings', 'super-progressive-web-apps' ), 'manage_options', 'superpwa', 'superpwa_admin_interface_render' );
|
31 |
+
|
32 |
+
// Add-Ons page
|
33 |
+
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' );
|
34 |
}
|
35 |
add_action( 'admin_menu', 'superpwa_add_menu_links' );
|
36 |
|
251 |
function superpwa_enqueue_css_js( $hook ) {
|
252 |
|
253 |
// Load only on SuperPWA plugin pages
|
254 |
+
if ( strpos( $hook, 'superpwa' ) === false ) {
|
255 |
return;
|
256 |
}
|
257 |
|
297 |
|
298 |
// Retun default on non-plugin pages
|
299 |
$screen = get_current_screen();
|
300 |
+
if ( strpos( $screen->id, 'superpwa' ) === false ) {
|
301 |
return $default;
|
302 |
}
|
303 |
|
319 |
|
320 |
// Retun default on non-plugin pages
|
321 |
$screen = get_current_screen();
|
322 |
+
if ( strpos( $screen->id, 'superpwa' ) === false ) {
|
323 |
return $default;
|
324 |
}
|
325 |
|
admin/admin-ui-render-addons.php
ADDED
@@ -0,0 +1,466 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_activator() Do bundled add-on activation and deactivation
|
13 |
+
* @function superpwa_addons_handle_activation() Handle add-on activation and 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 |
+
* 'type' => 'bundled | addon',
|
27 |
+
* 'description' => 'Add-On description',
|
28 |
+
* 'icon' => 'icon-for-addon-128x128.png',
|
29 |
+
* 'link' => 'https://superpwa.com/addons/details-page-of-addon',
|
30 |
+
* 'superpwa_min_version' => '1.7' // min version of SuperPWA required to use the add-on.
|
31 |
+
* )
|
32 |
+
* );
|
33 |
+
*
|
34 |
+
* @param (string) addon-slug to retrieve the details about a specific add-on. False by default and then returns all add-ons.
|
35 |
+
*
|
36 |
+
* @return (array) an associative array containing all the info about SuperPWA add-ons.
|
37 |
+
*
|
38 |
+
* @since 1.7
|
39 |
+
*/
|
40 |
+
function superpwa_get_addons( $slug = false ) {
|
41 |
+
|
42 |
+
// Add-Ons array
|
43 |
+
$addons = array(
|
44 |
+
'utm_tracking' => array(
|
45 |
+
'name' => __( 'UTM Tracking', 'super-progressive-web-apps' ),
|
46 |
+
'type' => 'bundled',
|
47 |
+
'description' => __( 'Track visits from your app by adding UTM tracking parameters to the Start Page URL.', 'super-progressive-web-apps' ),
|
48 |
+
'icon' => 'superpwa-128x128.png',
|
49 |
+
'link' => 'https://superpwa.com/addons/utm-tracking/',
|
50 |
+
'superpwa_min_version' => '1.7',
|
51 |
+
),
|
52 |
+
);
|
53 |
+
|
54 |
+
if ( ( $slug === false ) || ( ! isset( $addons[$slug] ) ) ) {
|
55 |
+
return $addons;
|
56 |
+
}
|
57 |
+
|
58 |
+
return $addons[$slug];
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Add-Ons UI renderer
|
63 |
+
*
|
64 |
+
* @since 1.7
|
65 |
+
*/
|
66 |
+
function superpwa_addons_interface_render() {
|
67 |
+
|
68 |
+
// Authentication
|
69 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
// Add-on activation notice
|
74 |
+
if ( isset( $_GET['activated'] ) && isset( $_GET['addon'] ) ) {
|
75 |
+
|
76 |
+
// Add-on activation action. Functions defined in the add-on file are loaded by now.
|
77 |
+
do_action( 'superpwa_addon_activated_' . $_GET['addon'] );
|
78 |
+
|
79 |
+
// Add settings saved message with the class of "updated"
|
80 |
+
add_settings_error( 'superpwa_settings_group', 'superpwa_addon_activated_message', __( 'Add-On activated.', 'super-progressive-web-apps' ), 'updated' );
|
81 |
+
|
82 |
+
// Show Settings Saved Message
|
83 |
+
settings_errors( 'superpwa_settings_group' );
|
84 |
+
}
|
85 |
+
|
86 |
+
// Add-on de-activation notice
|
87 |
+
if ( isset( $_GET['deactivated'] ) ) {
|
88 |
+
|
89 |
+
// Add settings saved message with the class of "updated"
|
90 |
+
add_settings_error( 'superpwa_settings_group', 'superpwa_addon_deactivated_message', __( 'Add-On deactivated.', 'super-progressive-web-apps' ), 'updated' );
|
91 |
+
|
92 |
+
// Show Settings Saved Message
|
93 |
+
settings_errors( 'superpwa_settings_group' );
|
94 |
+
}
|
95 |
+
|
96 |
+
// Get add-ons array
|
97 |
+
$addons = superpwa_get_addons();
|
98 |
+
|
99 |
+
?>
|
100 |
+
|
101 |
+
<div class="wrap">
|
102 |
+
<h1><?php _e( 'Add-Ons for', 'super-progressive-web-apps' ); ?> SuperPWA <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
|
103 |
+
|
104 |
+
<p><?php _e( 'Add-Ons extend the functionality of SuperPWA.', 'super-progressive-web-apps' ); ?></p>
|
105 |
+
|
106 |
+
<!-- Add-Ons UI -->
|
107 |
+
<div class="wp-list-table widefat addon-install">
|
108 |
+
|
109 |
+
<div id="the-list">
|
110 |
+
|
111 |
+
<?php
|
112 |
+
// Newsletter marker. Set this to false once newsletter subscription is displayed.
|
113 |
+
$superpwa_newsletter = true;
|
114 |
+
|
115 |
+
// Looping over each add-on
|
116 |
+
foreach( $addons as $slug => $addon ) { ?>
|
117 |
+
|
118 |
+
<div class="plugin-card plugin-card-<?php echo $slug; ?>">
|
119 |
+
|
120 |
+
<div class="plugin-card-top">
|
121 |
+
|
122 |
+
<div class="name column-name">
|
123 |
+
<h3>
|
124 |
+
<a href="<?php echo $addon['link'] . '?utm_source=superpwa-plugin&utm_medium=addon-card'; ?>">
|
125 |
+
<?php echo $addon['name']; ?>
|
126 |
+
<img src="<?php echo SUPERPWA_PATH_SRC . 'admin/img/' . $addon['icon']; ?>" class="plugin-icon" alt="">
|
127 |
+
</a>
|
128 |
+
</h3>
|
129 |
+
</div>
|
130 |
+
|
131 |
+
<div class="action-links">
|
132 |
+
<ul class="plugin-action-buttons">
|
133 |
+
<li>
|
134 |
+
<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']; ?>">
|
135 |
+
<?php echo superpwa_addons_button_text( $slug ); ?>
|
136 |
+
</a>
|
137 |
+
</li>
|
138 |
+
<li>
|
139 |
+
<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>
|
140 |
+
</li>
|
141 |
+
</ul>
|
142 |
+
</div>
|
143 |
+
|
144 |
+
<div class="desc column-description">
|
145 |
+
<p><?php echo $addon['description']; ?></p>
|
146 |
+
</div>
|
147 |
+
|
148 |
+
</div>
|
149 |
+
|
150 |
+
<div class="plugin-card-bottom">
|
151 |
+
<div class="column-compatibility">
|
152 |
+
<?php if ( version_compare( SUPERPWA_VERSION, $addon['superpwa_min_version'], '>=' ) ) { ?>
|
153 |
+
<span class="compatibility-compatible"><?php _e( '<strong>Compatible</strong> with your version of SuperPWA', 'super-progressive-web-apps' ); ?></span>
|
154 |
+
<?php } else { ?>
|
155 |
+
<span class="compatibility-incompatible"><?php _e( '<strong>Please upgrade</strong> to the latest version of SuperPWA', 'super-progressive-web-apps' ); ?></span>
|
156 |
+
<?php } ?>
|
157 |
+
</div>
|
158 |
+
</div>
|
159 |
+
|
160 |
+
</div>
|
161 |
+
|
162 |
+
<?php if ( $superpwa_newsletter === true ) { ?>
|
163 |
+
|
164 |
+
<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;">
|
165 |
+
|
166 |
+
<div class="plugin-card-top" style="min-height: 178px;">
|
167 |
+
|
168 |
+
<div class="name column-name" style="margin: 0px 10px;">
|
169 |
+
<h3><?php _e( 'SuperPWA Newsletter', 'super-progressive-web-apps' ); ?></h3>
|
170 |
+
</div>
|
171 |
+
|
172 |
+
<div class="desc column-description" style="margin: 0px 10px;">
|
173 |
+
<p><?php _e( 'Learn more about Progressive Web Apps<br>and get latest updates about SuperPWA', 'super-progressive-web-apps' ); ?></p>
|
174 |
+
</div>
|
175 |
+
|
176 |
+
<div class="superpwa-newsletter-form" style="margin: 18px 10px 0px;">
|
177 |
+
|
178 |
+
<form method="post" action="https://superpwa.com/newsletter/" target="_blank">
|
179 |
+
<fieldset>
|
180 |
+
|
181 |
+
<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">
|
182 |
+
<input name="source" value="superpwa-plugin" type="hidden">
|
183 |
+
<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;">
|
184 |
+
|
185 |
+
<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>
|
186 |
+
|
187 |
+
</fieldset>
|
188 |
+
</form>
|
189 |
+
|
190 |
+
</div>
|
191 |
+
|
192 |
+
</div>
|
193 |
+
|
194 |
+
</div>
|
195 |
+
|
196 |
+
<?php
|
197 |
+
|
198 |
+
// Set newsletter marker to false
|
199 |
+
$superpwa_newsletter = false;
|
200 |
+
}
|
201 |
+
} ?>
|
202 |
+
|
203 |
+
</div>
|
204 |
+
</div>
|
205 |
+
|
206 |
+
</div>
|
207 |
+
<?php
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Find add-on status
|
212 |
+
*
|
213 |
+
* Returns one of these statuses:
|
214 |
+
* active when the add-on is installed and active.
|
215 |
+
* inactive when the add-on is installed but not activated.
|
216 |
+
* uninstalled when the add-on is not installed and not available.
|
217 |
+
*
|
218 |
+
* @param $slug this is the $key used in the $addons array in superpwa_get_addons().
|
219 |
+
* For add-ons installed as a separate plugin, this will be plugin-directory/main-plugin-file.php
|
220 |
+
*
|
221 |
+
* @return (string) one of the statuses as described above. False if $slug is not a valid add-on.
|
222 |
+
*
|
223 |
+
* @since 1.7
|
224 |
+
*/
|
225 |
+
function superpwa_addons_status( $slug ) {
|
226 |
+
|
227 |
+
// Get add-ons array
|
228 |
+
$addons = superpwa_get_addons();
|
229 |
+
|
230 |
+
// A security check to make sure that the add-on under consideration exist.
|
231 |
+
if ( ! isset( $addons[$slug] ) ) {
|
232 |
+
return false;
|
233 |
+
}
|
234 |
+
|
235 |
+
// Get active add-ons
|
236 |
+
$active_addons = get_option( 'superpwa_active_addons', array() );
|
237 |
+
|
238 |
+
switch( $addons[$slug]['type'] ) {
|
239 |
+
|
240 |
+
// Bundled add-ons ships with SuperPWA and need not be installed separately.
|
241 |
+
case 'bundled':
|
242 |
+
|
243 |
+
// True means, add-on is installed and active
|
244 |
+
if ( in_array( $slug, $active_addons ) ) {
|
245 |
+
return 'active';
|
246 |
+
}
|
247 |
+
|
248 |
+
// add-on is installed, but inactive
|
249 |
+
return 'inactive';
|
250 |
+
|
251 |
+
break;
|
252 |
+
|
253 |
+
// Add-ons installed as a separate plugin
|
254 |
+
case 'addon':
|
255 |
+
|
256 |
+
// True means, add-on is installed and active
|
257 |
+
if ( is_plugin_active( $slug ) ) {
|
258 |
+
return 'active';
|
259 |
+
}
|
260 |
+
|
261 |
+
// Add-on is inactive, check if add-on is installed
|
262 |
+
if ( file_exists( WP_PLUGIN_DIR . '/' . $slug ) ) {
|
263 |
+
return 'inactive';
|
264 |
+
}
|
265 |
+
|
266 |
+
// If we are here, add-on is not installed and not active
|
267 |
+
return 'uninstalled';
|
268 |
+
|
269 |
+
break;
|
270 |
+
|
271 |
+
default:
|
272 |
+
return false;
|
273 |
+
break;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Button text based on add-on status
|
279 |
+
*
|
280 |
+
* @param $slug this is the $key used in the $addons array in superpwa_get_addons().
|
281 |
+
* For add-ons installed as a separate plugin, this will be plugin-directory/main-plugin-file.php
|
282 |
+
*
|
283 |
+
* @return (string) 'Activate', if plugin status is 'inactive'
|
284 |
+
* 'Deactivate', if plugin status is 'active'
|
285 |
+
* 'Install', if plugin status is 'uninstalled'
|
286 |
+
*
|
287 |
+
* @since 1.7
|
288 |
+
*/
|
289 |
+
function superpwa_addons_button_text( $slug ) {
|
290 |
+
|
291 |
+
// Get the add-on status
|
292 |
+
$addon_status = superpwa_addons_status( $slug );
|
293 |
+
|
294 |
+
switch( $addon_status ) {
|
295 |
+
|
296 |
+
case 'inactive':
|
297 |
+
return __( 'Activate', 'super-progressive-web-apps' );
|
298 |
+
break;
|
299 |
+
|
300 |
+
case 'active':
|
301 |
+
return __( 'Deactivate', 'super-progressive-web-apps' );
|
302 |
+
break;
|
303 |
+
|
304 |
+
case 'uninstalled':
|
305 |
+
default: // Safety net for edge cases if any.
|
306 |
+
return __( 'Install', 'super-progressive-web-apps' );
|
307 |
+
break;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Action URL based on add-on status
|
313 |
+
*
|
314 |
+
* @param $slug this is the $key used in the $addons array in superpwa_get_addons().
|
315 |
+
* For add-ons installed as a separate plugin, this will be plugin-directory/main-plugin-file.php
|
316 |
+
*
|
317 |
+
* @return (string) activation / deactivation / install url with nonce as necessary
|
318 |
+
*
|
319 |
+
* @since 1.7
|
320 |
+
*/
|
321 |
+
function superpwa_addons_button_link( $slug ) {
|
322 |
+
|
323 |
+
// Get the add-on status
|
324 |
+
$addon_status = superpwa_addons_status( $slug );
|
325 |
+
|
326 |
+
// Get add-ons array
|
327 |
+
$addons = superpwa_get_addons();
|
328 |
+
|
329 |
+
switch( $addon_status ) {
|
330 |
+
|
331 |
+
// Add-on inactive, send activation link.
|
332 |
+
case 'inactive':
|
333 |
+
|
334 |
+
// Plugin activation link for add-on plugins that are installed separately.
|
335 |
+
if ( $addons[$slug]['type'] == 'addon' ) {
|
336 |
+
wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $slug ), 'activate-plugin_' . $slug );
|
337 |
+
}
|
338 |
+
|
339 |
+
// Activation link for bundled add-ons.
|
340 |
+
return wp_nonce_url( admin_url( 'admin.php?page=superpwa-addons&addon=' . $slug ), 'activate', 'superpwa_addon_activate_nonce' );
|
341 |
+
|
342 |
+
break;
|
343 |
+
|
344 |
+
// Add-on active, send deactivation link.
|
345 |
+
case 'active':
|
346 |
+
|
347 |
+
// Plugin deactivation link for add-on plugins that are installed separately.
|
348 |
+
if ( $addons[$slug]['type'] == 'addon' ) {
|
349 |
+
wp_nonce_url( admin_url( 'plugins.php?action=deactivate&plugin=' . $slug ), 'deactivate-plugin_' . $slug );
|
350 |
+
}
|
351 |
+
|
352 |
+
// Deactivation link for bundled add-ons.
|
353 |
+
return wp_nonce_url( admin_url( 'admin.php?page=superpwa-addons&addon=' . $slug ), 'deactivate', 'superpwa_addon_deactivate_nonce' );
|
354 |
+
|
355 |
+
break;
|
356 |
+
|
357 |
+
// If add-on is not installed and for edge cases where $addon_status is false, we use the add-on link.
|
358 |
+
case 'uninstalled':
|
359 |
+
default:
|
360 |
+
return $addons[$slug]['link'];
|
361 |
+
break;
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Do add-on activation and deactivation
|
367 |
+
*
|
368 |
+
* Adds/removes the Add-On slug from the $settings['active_addons'] in SuperPWA settings.
|
369 |
+
*
|
370 |
+
* @param $slug (string) this is the $key used in the $addons array in superpwa_get_addons().
|
371 |
+
* @param $status (boolean) True to activate, False to deactivate.
|
372 |
+
*
|
373 |
+
* @return (boolean) True on success, false otherwise.
|
374 |
+
* Success = intended action, i.e. if deactivation is the intend, then success means successful deactivation.
|
375 |
+
*
|
376 |
+
* @since 1.7
|
377 |
+
*/
|
378 |
+
function superpwa_addons_activator( $slug, $status ) {
|
379 |
+
|
380 |
+
// Get the add-on status
|
381 |
+
$addon_status = superpwa_addons_status( $slug );
|
382 |
+
|
383 |
+
// Check if its a valid add-on
|
384 |
+
if ( ! $addon_status ) {
|
385 |
+
return false;
|
386 |
+
}
|
387 |
+
|
388 |
+
// Get active add-ons
|
389 |
+
$active_addons = get_option( 'superpwa_active_addons', array() );
|
390 |
+
|
391 |
+
// Activate add-on
|
392 |
+
if ( ( $status === true ) && ( $addon_status == 'inactive' ) ) {
|
393 |
+
|
394 |
+
// Add the add-on to the list of active add-ons
|
395 |
+
$active_addons[] = $slug;
|
396 |
+
|
397 |
+
// Write settings back to database
|
398 |
+
update_option( 'superpwa_active_addons', $active_addons );
|
399 |
+
|
400 |
+
return true;
|
401 |
+
}
|
402 |
+
|
403 |
+
// De-activate add-on
|
404 |
+
if ( ( $status === false ) && ( $addon_status == 'active' ) ) {
|
405 |
+
|
406 |
+
// Delete the add-on from the active_addons array in SuperPWA settings.
|
407 |
+
$active_addons = array_flip( $active_addons );
|
408 |
+
unset( $active_addons[$slug] );
|
409 |
+
$active_addons = array_flip( $active_addons );
|
410 |
+
|
411 |
+
// Write settings back to database
|
412 |
+
update_option( 'superpwa_active_addons', $active_addons );
|
413 |
+
|
414 |
+
// Add-on deactivation action. Functions defined in the add-on file are still availalbe at this point.
|
415 |
+
do_action( 'superpwa_addon_deactivated_' . $slug );
|
416 |
+
|
417 |
+
return true;
|
418 |
+
}
|
419 |
+
|
420 |
+
return false;
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Handle add-on activation and deactivation
|
425 |
+
*
|
426 |
+
* Verifies that the activation / deactivation request is valid and calls superpwa_addons_activator()
|
427 |
+
* then redirects the page back to the add-ons page.
|
428 |
+
*
|
429 |
+
* Hooked onto load-superpwa_page_superpwa-addons action hook and is called every time the add-ons page is loaded
|
430 |
+
*
|
431 |
+
* @param void
|
432 |
+
* @return void
|
433 |
+
*
|
434 |
+
* @since 1.7
|
435 |
+
*/
|
436 |
+
function superpwa_addons_handle_activation() {
|
437 |
+
|
438 |
+
// Authentication
|
439 |
+
if ( ! isset( $_GET['addon'] ) || ! current_user_can( 'manage_options' ) ) {
|
440 |
+
return;
|
441 |
+
}
|
442 |
+
|
443 |
+
// Handing add-on activation
|
444 |
+
if ( isset( $_GET['superpwa_addon_activate_nonce'] ) && isset( $_GET['addon'] ) && wp_verify_nonce( $_GET['superpwa_addon_activate_nonce'], 'activate' ) ) {
|
445 |
+
|
446 |
+
// Handling activation
|
447 |
+
if ( superpwa_addons_activator( $_GET['addon'], true ) === true ) {
|
448 |
+
|
449 |
+
// Redirect to add-ons sub-menu
|
450 |
+
wp_redirect( admin_url( 'admin.php?page=superpwa-addons&activated=1&addon=' . $_GET['addon'] ) );
|
451 |
+
exit;
|
452 |
+
}
|
453 |
+
}
|
454 |
+
|
455 |
+
// Handing add-on de-activation
|
456 |
+
if ( isset( $_GET['superpwa_addon_deactivate_nonce'] ) && isset( $_GET['addon'] ) && wp_verify_nonce( $_GET['superpwa_addon_deactivate_nonce'], 'deactivate' ) ) {
|
457 |
+
|
458 |
+
// Handling deactivation
|
459 |
+
if ( superpwa_addons_activator( $_GET['addon'], false ) === true ) {
|
460 |
+
|
461 |
+
wp_redirect( admin_url( 'admin.php?page=superpwa-addons&deactivated=1&addon=' . $_GET['addon'] ) );
|
462 |
+
exit;
|
463 |
+
}
|
464 |
+
}
|
465 |
+
}
|
466 |
+
add_action( 'load-superpwa_page_superpwa-addons', 'superpwa_addons_handle_activation' );
|
admin/{admin-ui-render.php → admin-ui-render-settings.php}
RENAMED
@@ -3,6 +3,7 @@
|
|
3 |
* Admin UI setup and render
|
4 |
*
|
5 |
* @since 1.0
|
|
|
6 |
* @function superpwa_app_name_cb() Application Name
|
7 |
* @function superpwa_app_short_name_cb() Application Short Name
|
8 |
* @function superpwa_description_cb() Description
|
@@ -20,7 +21,7 @@
|
|
20 |
*/
|
21 |
|
22 |
// Exit if accessed directly
|
23 |
-
if ( ! defined('ABSPATH') ) exit;
|
24 |
|
25 |
/**
|
26 |
* Application Name
|
@@ -334,25 +335,24 @@ function superpwa_https_status_cb() {
|
|
334 |
* Admin interface renderer
|
335 |
*
|
336 |
* @since 1.0
|
|
|
337 |
*/
|
338 |
-
function superpwa_admin_interface_render
|
339 |
|
|
|
340 |
if ( ! current_user_can( 'manage_options' ) ) {
|
341 |
return;
|
342 |
}
|
343 |
-
|
344 |
-
|
345 |
-
* If settings are inside WP-Admin > Settings, then WordPress will automatically display Settings Saved. If not used this block
|
346 |
-
* @refer https://core.trac.wordpress.org/ticket/31000
|
347 |
-
* If the user have submitted the settings, WordPress will add the "settings-updated" $_GET parameter to the url
|
348 |
-
*
|
349 |
if ( isset( $_GET['settings-updated'] ) ) {
|
|
|
350 |
// Add settings saved message with the class of "updated"
|
351 |
-
add_settings_error( '
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
|
357 |
// Display the notice to use SuperPWA manifest as OneSignal custom manifest.
|
358 |
if ( superpwa_onesignal_manifest_notice_check() ) {
|
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
|
21 |
*/
|
22 |
|
23 |
// Exit if accessed directly
|
24 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
25 |
|
26 |
/**
|
27 |
* Application Name
|
335 |
* Admin interface renderer
|
336 |
*
|
337 |
* @since 1.0
|
338 |
+
* @since 1.7 Handling of settings saved messages since UI is its own menu item in the admin menu.
|
339 |
*/
|
340 |
+
function superpwa_admin_interface_render() {
|
341 |
|
342 |
+
// Authentication
|
343 |
if ( ! current_user_can( 'manage_options' ) ) {
|
344 |
return;
|
345 |
}
|
346 |
+
|
347 |
+
// Handing save settings
|
|
|
|
|
|
|
|
|
348 |
if ( isset( $_GET['settings-updated'] ) ) {
|
349 |
+
|
350 |
// Add settings saved message with the class of "updated"
|
351 |
+
add_settings_error( 'superpwa_settings_group', 'superpwa_settings_saved_message', __( 'Settings saved.', 'super-progressive-web-apps' ), 'updated' );
|
352 |
+
|
353 |
+
// Show Settings Saved Message
|
354 |
+
settings_errors( 'superpwa_settings_group' );
|
355 |
+
}
|
356 |
|
357 |
// Display the notice to use SuperPWA manifest as OneSignal custom manifest.
|
358 |
if ( superpwa_onesignal_manifest_notice_check() ) {
|
admin/img/email.png
ADDED
Binary file
|
admin/img/superpwa-128x128.png
ADDED
Binary file
|
admin/img/superpwa-menu-icon.png
ADDED
Binary file
|
functions/common.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
* Operations and common functions of SuperPWA
|
4 |
*
|
5 |
* @since 1.0
|
|
|
6 |
* @function superpwa_is_amp() Check if any AMP plugin is installed
|
7 |
* @function superpwa_get_start_url() Return Start Page URL
|
8 |
* @function superpwa_httpsify() Convert http URL to https
|
@@ -14,8 +15,9 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
|
14 |
/**
|
15 |
* Check if any AMP plugin is installed
|
16 |
*
|
17 |
-
* @return
|
18 |
-
*
|
|
|
19 |
*/
|
20 |
function superpwa_is_amp() {
|
21 |
|
@@ -50,13 +52,15 @@ function superpwa_is_amp() {
|
|
50 |
/**
|
51 |
* Return Start Page URL
|
52 |
*
|
53 |
-
* @param
|
54 |
-
*
|
|
|
55 |
*
|
56 |
-
* @since
|
57 |
-
* @since
|
58 |
-
* @since
|
59 |
-
* @since
|
|
|
60 |
*/
|
61 |
function superpwa_get_start_url( $rel = false ) {
|
62 |
|
@@ -69,27 +73,31 @@ function superpwa_get_start_url( $rel = false ) {
|
|
69 |
// Force HTTPS
|
70 |
$start_url = superpwa_httpsify( $start_url );
|
71 |
|
72 |
-
if ( $rel === true ) {
|
73 |
-
|
74 |
-
// Make start_url relative for manifest
|
75 |
-
$start_url = '.' . parse_url( $start_url, PHP_URL_PATH );
|
76 |
-
}
|
77 |
-
|
78 |
// AMP URL
|
79 |
if ( superpwa_is_amp() !== false && isset( $settings['start_url_amp'] ) && $settings['start_url_amp'] == 1 ) {
|
80 |
$start_url = trailingslashit( $start_url ) . superpwa_is_amp();
|
81 |
}
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
return $start_url;
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
* Convert http URL to https
|
88 |
*
|
89 |
-
* @param
|
90 |
-
*
|
|
|
91 |
*
|
92 |
-
* @since
|
93 |
*/
|
94 |
function superpwa_httpsify( $url ) {
|
95 |
return str_replace( 'http://', 'https://', $url );
|
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
|
15 |
/**
|
16 |
* Check if any AMP plugin is installed
|
17 |
*
|
18 |
+
* @return (string|bool) AMP page url on success, false otherwise
|
19 |
+
*
|
20 |
+
* @since 1.2
|
21 |
*/
|
22 |
function superpwa_is_amp() {
|
23 |
|
52 |
/**
|
53 |
* Return Start Page URL
|
54 |
*
|
55 |
+
* @param $rel (boolean) False by default. Set to true to return a relative URL (for use in manifest)
|
56 |
+
*
|
57 |
+
* @return (string) URL to be set as the start_url in manifest and startPage in service worker
|
58 |
*
|
59 |
+
* @since 1.2
|
60 |
+
* @since 1.3.1 Force HTTPS by replacing http:// with https://
|
61 |
+
* @since 1.6 Use superpwa_httpsify() to force HTTPS.
|
62 |
+
* @since 1.6 Removed forcing of trailing slash and added dot (.) to the beginning.
|
63 |
+
* @since 1.7 Added filter superpwa_manifest_start_url when $rel = true, for use with manifest. First ever filter in SuperPWA.
|
64 |
*/
|
65 |
function superpwa_get_start_url( $rel = false ) {
|
66 |
|
73 |
// Force HTTPS
|
74 |
$start_url = superpwa_httpsify( $start_url );
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
// AMP URL
|
77 |
if ( superpwa_is_amp() !== false && isset( $settings['start_url_amp'] ) && $settings['start_url_amp'] == 1 ) {
|
78 |
$start_url = trailingslashit( $start_url ) . superpwa_is_amp();
|
79 |
}
|
80 |
|
81 |
+
// Relative URL for manifest
|
82 |
+
if ( $rel === true ) {
|
83 |
+
|
84 |
+
// Make start_url relative for manifest
|
85 |
+
$start_url = empty( parse_url( $start_url, PHP_URL_PATH ) ) ? '.' : parse_url( $start_url, PHP_URL_PATH );
|
86 |
+
|
87 |
+
return apply_filters( 'superpwa_manifest_start_url', $start_url );
|
88 |
+
}
|
89 |
+
|
90 |
return $start_url;
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
* Convert http URL to https
|
95 |
*
|
96 |
+
* @param $url (string) The URL to convert to https
|
97 |
+
*
|
98 |
+
* @return (string) Returns the converted URL
|
99 |
*
|
100 |
+
* @since 1.6
|
101 |
*/
|
102 |
function superpwa_httpsify( $url ) {
|
103 |
return str_replace( 'http://', 'https://', $url );
|
loader.php
CHANGED
@@ -11,7 +11,8 @@ if ( ! defined('ABSPATH') ) exit;
|
|
11 |
// Load admin
|
12 |
require_once( SUPERPWA_PATH_ABS . 'admin/basic-setup.php' );
|
13 |
require_once( SUPERPWA_PATH_ABS . 'admin/admin-setup.php' );
|
14 |
-
require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render.php' );
|
|
|
15 |
|
16 |
// 3rd party compatibility
|
17 |
require_once( SUPERPWA_PATH_ABS . '3rd-party/onesignal.php' );
|
@@ -23,4 +24,9 @@ require_once( SUPERPWA_PATH_ABS . 'functions/multisite.php' );
|
|
23 |
|
24 |
// Public folder
|
25 |
require_once( SUPERPWA_PATH_ABS . 'public/manifest.php' );
|
26 |
-
require_once( SUPERPWA_PATH_ABS . 'public/sw.php' );
|
|
|
|
|
|
|
|
|
|
11 |
// Load admin
|
12 |
require_once( SUPERPWA_PATH_ABS . 'admin/basic-setup.php' );
|
13 |
require_once( SUPERPWA_PATH_ABS . 'admin/admin-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' );
|
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' ) {
|
31 |
+
require_once( SUPERPWA_PATH_ABS . 'addons/utm-tracking.php' );
|
32 |
+
}
|
public/manifest.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
* Manifest related functions of SuperPWA
|
4 |
*
|
5 |
* @since 1.0
|
|
|
6 |
* @function superpwa_manifest() Manifest filename, absolute path and link
|
7 |
* @function superpwa_generate_manifest() Generate and write manifest
|
8 |
* @function superpwa_add_manifest_to_wp_head() Add manifest to header (wp_head)
|
@@ -26,7 +27,8 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
|
26 |
* abs for absolute path to manifest (replaces SUPERPWA_MANIFEST_ABS)
|
27 |
* src for link to manifest (replaces SUPERPWA_MANIFEST_SRC). Default value
|
28 |
*
|
29 |
-
* @return String filename, absolute path or link to manifest.
|
|
|
30 |
* @since 1.6
|
31 |
*/
|
32 |
function superpwa_manifest( $arg = 'src' ) {
|
@@ -48,7 +50,7 @@ function superpwa_manifest( $arg = 'src' ) {
|
|
48 |
// Link to manifest
|
49 |
case 'src':
|
50 |
default:
|
51 |
-
return trailingslashit(
|
52 |
break;
|
53 |
}
|
54 |
}
|
@@ -56,7 +58,8 @@ function superpwa_manifest( $arg = 'src' ) {
|
|
56 |
/**
|
57 |
* Generate and write manifest into WordPress root folder
|
58 |
*
|
59 |
-
* @return true on success, false on failure.
|
|
|
60 |
* @since 1.0
|
61 |
* @since 1.3 Added support for 512x512 icon.
|
62 |
* @since 1.4 Added orientation and scope.
|
@@ -103,7 +106,7 @@ function superpwa_generate_manifest() {
|
|
103 |
/**
|
104 |
* Add manifest to header (wp_head)
|
105 |
*
|
106 |
-
* @since
|
107 |
*/
|
108 |
function superpwa_add_manifest_to_wp_head() {
|
109 |
|
@@ -118,8 +121,9 @@ add_action( 'wp_head', 'superpwa_add_manifest_to_wp_head', 0 );
|
|
118 |
/**
|
119 |
* Delete manifest
|
120 |
*
|
121 |
-
* @return true on success, false on failure
|
122 |
-
*
|
|
|
123 |
*/
|
124 |
function superpwa_delete_manifest() {
|
125 |
return superpwa_delete( superpwa_manifest( 'abs' ) );
|
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)
|
27 |
* abs for absolute path to manifest (replaces SUPERPWA_MANIFEST_ABS)
|
28 |
* src for link to manifest (replaces SUPERPWA_MANIFEST_SRC). Default value
|
29 |
*
|
30 |
+
* @return String filename, absolute path or link to manifest.
|
31 |
+
*
|
32 |
* @since 1.6
|
33 |
*/
|
34 |
function superpwa_manifest( $arg = 'src' ) {
|
50 |
// Link to manifest
|
51 |
case 'src':
|
52 |
default:
|
53 |
+
return trailingslashit( network_site_url() ) . $manifest_filename;
|
54 |
break;
|
55 |
}
|
56 |
}
|
58 |
/**
|
59 |
* Generate and write manifest into WordPress root folder
|
60 |
*
|
61 |
+
* @return (boolean) true on success, false on failure.
|
62 |
+
*
|
63 |
* @since 1.0
|
64 |
* @since 1.3 Added support for 512x512 icon.
|
65 |
* @since 1.4 Added orientation and scope.
|
106 |
/**
|
107 |
* Add manifest to header (wp_head)
|
108 |
*
|
109 |
+
* @since 1.0
|
110 |
*/
|
111 |
function superpwa_add_manifest_to_wp_head() {
|
112 |
|
121 |
/**
|
122 |
* Delete manifest
|
123 |
*
|
124 |
+
* @return (boolean) true on success, false on failure
|
125 |
+
*
|
126 |
+
* @since 1.0
|
127 |
*/
|
128 |
function superpwa_delete_manifest() {
|
129 |
return superpwa_delete( superpwa_manifest( 'abs' ) );
|
public/sw.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
* Service worker related functions of SuperPWA
|
4 |
*
|
5 |
* @since 1.0
|
|
|
6 |
* @function superpwa_sw() Service worker filename, absolute path and link
|
7 |
* @function superpwa_generate_sw() Generate and write service worker into sw.js
|
8 |
* @function superpwa_sw_template() Service worker tempalte
|
@@ -21,10 +22,12 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
|
21 |
*
|
22 |
* @param $arg filename for service worker filename (replaces SUPERPWA_SW_FILENAME)
|
23 |
* abs for absolute path to service worker (replaces SUPERPWA_SW_ABS)
|
24 |
-
* src for link to service worker (replaces SUPERPWA_SW_SRC). Default value
|
25 |
*
|
26 |
-
* @return
|
|
|
27 |
* @since 1.6
|
|
|
28 |
*/
|
29 |
function superpwa_sw( $arg = 'src' ) {
|
30 |
|
@@ -33,7 +36,7 @@ function superpwa_sw( $arg = 'src' ) {
|
|
33 |
switch( $arg ) {
|
34 |
|
35 |
// Name of service worker file
|
36 |
-
case 'filename':
|
37 |
return $sw_filename;
|
38 |
break;
|
39 |
|
@@ -45,7 +48,7 @@ function superpwa_sw( $arg = 'src' ) {
|
|
45 |
// Link to service worker
|
46 |
case 'src':
|
47 |
default:
|
48 |
-
return trailingslashit(
|
49 |
break;
|
50 |
}
|
51 |
}
|
@@ -53,8 +56,9 @@ function superpwa_sw( $arg = 'src' ) {
|
|
53 |
/**
|
54 |
* Generate and write service worker into superpwa-sw.js
|
55 |
*
|
56 |
-
* @return true on success, false on failure.
|
57 |
-
*
|
|
|
58 |
*/
|
59 |
function superpwa_generate_sw() {
|
60 |
|
@@ -77,8 +81,10 @@ function superpwa_generate_sw() {
|
|
77 |
/**
|
78 |
* Service Worker Tempalte
|
79 |
*
|
80 |
-
* @return
|
81 |
-
*
|
|
|
|
|
82 |
*/
|
83 |
function superpwa_sw_template() {
|
84 |
|
@@ -189,14 +195,15 @@ function checkNeverCacheList(url) {
|
|
189 |
}
|
190 |
return true;
|
191 |
}
|
192 |
-
<?php return ob_get_clean();
|
193 |
}
|
194 |
|
195 |
/**
|
196 |
* Register service worker
|
197 |
*
|
198 |
-
* @
|
199 |
-
*
|
|
|
200 |
*/
|
201 |
function superpwa_register_sw() {
|
202 |
|
@@ -212,7 +219,8 @@ add_action( 'wp_enqueue_scripts', 'superpwa_register_sw' );
|
|
212 |
* Delete Service Worker
|
213 |
*
|
214 |
* @return true on success, false on failure
|
215 |
-
*
|
|
|
216 |
*/
|
217 |
function superpwa_delete_sw() {
|
218 |
return superpwa_delete( superpwa_sw( 'abs' ) );
|
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
|
22 |
*
|
23 |
* @param $arg filename for service worker filename (replaces SUPERPWA_SW_FILENAME)
|
24 |
* abs for absolute path to service worker (replaces SUPERPWA_SW_ABS)
|
25 |
+
* src for relative link to service worker (replaces SUPERPWA_SW_SRC). Default value
|
26 |
*
|
27 |
+
* @return (string) filename, absolute path or link to manifest.
|
28 |
+
*
|
29 |
* @since 1.6
|
30 |
+
* @since 1.7 src to service worker is made relative to accomodate for domain mapped multisites.
|
31 |
*/
|
32 |
function superpwa_sw( $arg = 'src' ) {
|
33 |
|
36 |
switch( $arg ) {
|
37 |
|
38 |
// Name of service worker file
|
39 |
+
case 'filename':
|
40 |
return $sw_filename;
|
41 |
break;
|
42 |
|
48 |
// Link to service worker
|
49 |
case 'src':
|
50 |
default:
|
51 |
+
return parse_url( trailingslashit( network_site_url() ) . $sw_filename, PHP_URL_PATH );
|
52 |
break;
|
53 |
}
|
54 |
}
|
56 |
/**
|
57 |
* Generate and write service worker into superpwa-sw.js
|
58 |
*
|
59 |
+
* @return (boolean) true on success, false on failure.
|
60 |
+
*
|
61 |
+
* @since 1.0
|
62 |
*/
|
63 |
function superpwa_generate_sw() {
|
64 |
|
81 |
/**
|
82 |
* Service Worker Tempalte
|
83 |
*
|
84 |
+
* @return (string) Contents to be written to superpwa-sw.js
|
85 |
+
*
|
86 |
+
* @since 1.0
|
87 |
+
* @since 1.7 added filter superpwa_sw_template
|
88 |
*/
|
89 |
function superpwa_sw_template() {
|
90 |
|
195 |
}
|
196 |
return true;
|
197 |
}
|
198 |
+
<?php return apply_filters( 'superpwa_sw_template', ob_get_clean() );
|
199 |
}
|
200 |
|
201 |
/**
|
202 |
* Register service worker
|
203 |
*
|
204 |
+
* @refer https://developers.google.com/web/fundamentals/primers/service-workers/registration#conclusion
|
205 |
+
*
|
206 |
+
* @since 1.0
|
207 |
*/
|
208 |
function superpwa_register_sw() {
|
209 |
|
219 |
* Delete Service Worker
|
220 |
*
|
221 |
* @return true on success, false on failure
|
222 |
+
*
|
223 |
+
* @since 1.0
|
224 |
*/
|
225 |
function superpwa_delete_sw() {
|
226 |
return superpwa_delete( superpwa_sw( 'abs' ) );
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: arunbasillal, josevarghese, superpwa
|
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 |
Tested up to: 4.9.5
|
7 |
Requires PHP: 5.3
|
8 |
Stable tag: trunk
|
@@ -51,6 +51,7 @@ Here are the current features of Super Progressive Web Apps:
|
|
51 |
* New in version 1.4: You can now set the theme_color property in the manifest.
|
52 |
* New in version 1.5: OneSignal integration for Push notifications.
|
53 |
* New in version 1.6: WordPress Multisite Network compatibility.
|
|
|
54 |
|
55 |
**Upcoming features:**
|
56 |
|
@@ -82,9 +83,9 @@ To install manually:
|
|
82 |
|
83 |
#### Customizing Your Progressive Web App
|
84 |
|
85 |
-
Your Progressive Web App should be ready to test with the default settings
|
86 |
|
87 |
-
* Go to WordPress Admin >
|
88 |
* Set a Background Color for the splash screen to be shown when your PWA is opened on a mobile device.
|
89 |
* 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.
|
90 |
* 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.".
|
@@ -129,7 +130,7 @@ To install this plugin:
|
|
129 |
|
130 |
1. Install the plugin through the WordPress admin interface, or upload the plugin folder to /wp-content/plugins/ using FTP.
|
131 |
2. Activate the plugin through the 'Plugins' screen in WordPress.
|
132 |
-
3. Go to WordPress Admin >
|
133 |
|
134 |
== Frequently Asked Questions ==
|
135 |
|
@@ -141,10 +142,20 @@ PWA's require browsers with support for service workers and for iOS devices, sup
|
|
141 |
|
142 |
== Screenshots ==
|
143 |
|
144 |
-
1. Settings page in WordPress Admin >
|
145 |
|
146 |
== Changelog ==
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
= 1.6 =
|
149 |
* Date: 23.April.2018
|
150 |
* 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.
|
@@ -210,6 +221,15 @@ PWA's require browsers with support for service workers and for iOS devices, sup
|
|
210 |
|
211 |
== Upgrade Notice ==
|
212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
= 1.6 =
|
214 |
* 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.
|
215 |
* New Feature: Added description to the manifest. You can now include a brief description of what your app is about.
|
2 |
Contributors: arunbasillal, josevarghese, superpwa
|
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: 4.9.5
|
7 |
Requires PHP: 5.3
|
8 |
Stable tag: trunk
|
51 |
* New in version 1.4: You can now set the theme_color property in the manifest.
|
52 |
* New in version 1.5: OneSignal integration for Push notifications.
|
53 |
* New in version 1.6: WordPress Multisite Network compatibility.
|
54 |
+
* 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.
|
55 |
|
56 |
**Upcoming features:**
|
57 |
|
83 |
|
84 |
#### Customizing Your Progressive Web App
|
85 |
|
86 |
+
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.
|
87 |
|
88 |
+
* Go to WordPress Admin > SuperPWA
|
89 |
* Set a Background Color for the splash screen to be shown when your PWA is opened on a mobile device.
|
90 |
* 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.
|
91 |
* 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.".
|
130 |
|
131 |
1. Install the plugin through the WordPress admin interface, or upload the plugin folder to /wp-content/plugins/ using FTP.
|
132 |
2. Activate the plugin through the 'Plugins' screen in WordPress.
|
133 |
+
3. Go to WordPress Admin > SuperPWA
|
134 |
|
135 |
== Frequently Asked Questions ==
|
136 |
|
142 |
|
143 |
== Screenshots ==
|
144 |
|
145 |
+
1. Settings page in WordPress Admin > SuperPWA > Settings
|
146 |
|
147 |
== Changelog ==
|
148 |
|
149 |
+
= 1.7 =
|
150 |
+
* Date: 03.May.2018
|
151 |
+
* Minimum required WordPress version is now 3.6.0 (previously 3.5.0).
|
152 |
+
* New Feature: Add-Ons for SuperPWA is here!
|
153 |
+
* New Feature: SuperPWA is now a top-level menu to accommodate for the Add-Ons sub-menu page.
|
154 |
+
* 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).
|
155 |
+
* Enhancement: Service worker URLs are now relative to accommodate for domain mapped Multisites.
|
156 |
+
* Bug Fix: Incorrect start_url when WordPress is installed in a folder, or when inner pages are used as start_url.
|
157 |
+
* Bug Fix: Incorrect manifest and service worker URLs when WordPress is installed in a folder.
|
158 |
+
|
159 |
= 1.6 =
|
160 |
* Date: 23.April.2018
|
161 |
* 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.
|
221 |
|
222 |
== Upgrade Notice ==
|
223 |
|
224 |
+
= 1.7 =
|
225 |
+
* Minimum required WordPress version is now 3.6.0 (previously 3.5.0).
|
226 |
+
* New Feature: Add-Ons for SuperPWA is here!
|
227 |
+
* New Feature: SuperPWA is now a top-level menu to accommodate for the Add-Ons sub-menu page.
|
228 |
+
* 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).
|
229 |
+
* Enhancement: Service worker URLs are now relative to accommodate for domain mapped Multisites.
|
230 |
+
* Bug Fix: Incorrect start_url when WordPress is installed in a folder, or when inner pages are used as start_url.
|
231 |
+
* Bug Fix: Incorrect manifest and service worker URLs when WordPress is installed in a folder.
|
232 |
+
|
233 |
= 1.6 =
|
234 |
* 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.
|
235 |
* New Feature: Added description to the manifest. You can now include a brief description of what your app is about.
|
superpwa.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Author: SuperPWA
|
7 |
* Author URI: https://superpwa.com
|
8 |
* Contributors: Arun Basil Lal, Jose Varghese
|
9 |
-
* Version: 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
|
@@ -50,7 +50,7 @@ if ( ! defined('ABSPATH') ) exit;
|
|
50 |
* @since 1.6 Depreciated constants for multisite compatibility: SUPERPWA_MANIFEST_FILENAME, SUPERPWA_MANIFEST_ABS, SUPERPWA_MANIFEST_SRC
|
51 |
* @since 1.6 Depreciated constants for multisite compatibility: SUPERPWA_SW_FILENAME, SUPERPWA_SW_ABS, SUPERPWA_SW_SRC
|
52 |
*/
|
53 |
-
if ( ! defined( 'SUPERPWA_VERSION' ) ) define( 'SUPERPWA_VERSION' , '1.
|
54 |
if ( ! defined( 'SUPERPWA_PATH_ABS' ) ) define( 'SUPERPWA_PATH_ABS' , plugin_dir_path( __FILE__ ) ); // Absolute path to the plugin directory. eg - /var/www/html/wp-content/plugins/super-progressive-web-apps/
|
55 |
if ( ! defined( 'SUPERPWA_PATH_SRC' ) ) define( 'SUPERPWA_PATH_SRC' , plugin_dir_url( __FILE__ ) ); // Link to the plugin folder. eg - http://example.com/wp/wp-content/plugins/super-progressive-web-apps/
|
56 |
|
6 |
* Author: SuperPWA
|
7 |
* Author URI: https://superpwa.com
|
8 |
* Contributors: Arun Basil Lal, Jose Varghese
|
9 |
+
* Version: 1.7
|
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
|
50 |
* @since 1.6 Depreciated constants for multisite compatibility: SUPERPWA_MANIFEST_FILENAME, SUPERPWA_MANIFEST_ABS, SUPERPWA_MANIFEST_SRC
|
51 |
* @since 1.6 Depreciated constants for multisite compatibility: SUPERPWA_SW_FILENAME, SUPERPWA_SW_ABS, SUPERPWA_SW_SRC
|
52 |
*/
|
53 |
+
if ( ! defined( 'SUPERPWA_VERSION' ) ) define( 'SUPERPWA_VERSION' , '1.7' ); // SuperPWA current version
|
54 |
if ( ! defined( 'SUPERPWA_PATH_ABS' ) ) define( 'SUPERPWA_PATH_ABS' , plugin_dir_path( __FILE__ ) ); // Absolute path to the plugin directory. eg - /var/www/html/wp-content/plugins/super-progressive-web-apps/
|
55 |
if ( ! defined( 'SUPERPWA_PATH_SRC' ) ) define( 'SUPERPWA_PATH_SRC' , plugin_dir_url( __FILE__ ) ); // Link to the plugin folder. eg - http://example.com/wp/wp-content/plugins/super-progressive-web-apps/
|
56 |
|
uninstall.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
* Fired when the plugin is uninstalled.
|
4 |
*
|
5 |
* Everything in uninstall.php will be executed when user decides to delete the plugin.
|
|
|
6 |
* @since 1.0
|
7 |
*/
|
8 |
|
@@ -16,14 +17,18 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) die;
|
|
16 |
* Delete database settings
|
17 |
*
|
18 |
* @since 1.0
|
|
|
19 |
*/
|
20 |
delete_option( 'superpwa_settings' );
|
|
|
|
|
21 |
delete_option( 'superpwa_version' );
|
22 |
|
23 |
/**
|
24 |
* Clean up for Multisites
|
25 |
*
|
26 |
* @since 1.6
|
|
|
27 |
*/
|
28 |
if ( is_multisite() ) {
|
29 |
|
@@ -38,6 +43,8 @@ if ( is_multisite() ) {
|
|
38 |
|
39 |
// Delete database settings for each site.
|
40 |
delete_option( 'superpwa_settings' );
|
|
|
|
|
41 |
delete_option( 'superpwa_version' );
|
42 |
|
43 |
// Return to main site
|
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 |
|
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 |
|
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
|