Version Description
- Date: 22.January.2018
- First release of the plugin.
=
Download this release
Release Info
Developer | arunbasillal |
Plugin | Super Progressive Web Apps |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- admin/admin-setup.php +143 -0
- admin/admin-ui-render.php +134 -0
- admin/basic-setup.php +131 -0
- admin/do.php +29 -0
- admin/filesystem.php +99 -0
- admin/index.php +2 -0
- admin/js/main.js +18 -0
- admin/loader.php +30 -0
- includes/index.php +2 -0
- index.php +2 -0
- languages/super-progressive-web-apps.pot +0 -0
- license.txt +281 -0
- public/images/logo.png +0 -0
- public/index.php +2 -0
- public/js/register-sw.js +6 -0
- public/manifest.php +72 -0
- public/sw.php +123 -0
- readme.txt +76 -0
- superpwa.php +73 -0
- uninstall.php +23 -0
admin/admin-setup.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined('ABSPATH') ) exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Add admin menu pages
|
17 |
+
*
|
18 |
+
* @since 1.0
|
19 |
+
* @refer https://developer.wordpress.org/plugins/administration-menus/
|
20 |
+
*/
|
21 |
+
function superpwa_add_menu_links() {
|
22 |
+
|
23 |
+
add_options_page( __('Super Progressive Web Apps','super-progressive-web-apps'), __('SuperPWA','super-progressive-web-apps'), 'manage_options', 'superpwa','superpwa_admin_interface_render' );
|
24 |
+
}
|
25 |
+
add_action( 'admin_menu', 'superpwa_add_menu_links' );
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Register Settings
|
29 |
+
*
|
30 |
+
* @since 1.0
|
31 |
+
*/
|
32 |
+
function superpwa_register_settings() {
|
33 |
+
|
34 |
+
// Register Setting
|
35 |
+
register_setting(
|
36 |
+
'superpwa_settings_group', // Group name
|
37 |
+
'superpwa_settings', // Setting name = html form <input> name on settings form
|
38 |
+
'superpwa_validater_and_sanitizer' // Input sanitizer
|
39 |
+
);
|
40 |
+
|
41 |
+
// Manifest
|
42 |
+
add_settings_section(
|
43 |
+
'superpwa_manifest_section', // ID
|
44 |
+
__('Manifest', 'super-progressive-web-apps'), // Title
|
45 |
+
'superpwa_manifest_cb', // Callback Function
|
46 |
+
'superpwa_manifest_section' // Page slug
|
47 |
+
);
|
48 |
+
|
49 |
+
// Manifest status
|
50 |
+
add_settings_field(
|
51 |
+
'superpwa_manifest_status', // ID
|
52 |
+
__('Manifest Status', 'super-progressive-web-apps'), // Title
|
53 |
+
'superpwa_manifest_status_cb', // Callback function
|
54 |
+
'superpwa_manifest_section', // Page slug
|
55 |
+
'superpwa_manifest_section' // Settings Section ID
|
56 |
+
);
|
57 |
+
|
58 |
+
// Splash Screen Settings
|
59 |
+
add_settings_section(
|
60 |
+
'superpwa_splash_screen_section', // ID
|
61 |
+
__('Splash Screen', 'super-progressive-web-apps'), // Title
|
62 |
+
'superpwa_splash_screen_cb', // Callback Function
|
63 |
+
'superpwa_splash_screen_section' // Page slug
|
64 |
+
);
|
65 |
+
|
66 |
+
// Background Color
|
67 |
+
add_settings_field(
|
68 |
+
'superpwa_background_color', // ID
|
69 |
+
__('Background Color', 'super-progressive-web-apps'), // Title
|
70 |
+
'superpwa_background_color_cb', // Callback function
|
71 |
+
'superpwa_splash_screen_section', // Page slug
|
72 |
+
'superpwa_splash_screen_section' // Settings Section ID
|
73 |
+
);
|
74 |
+
|
75 |
+
// Icons
|
76 |
+
add_settings_field(
|
77 |
+
'superpwa_icons', // ID
|
78 |
+
__('Application Icon', 'super-progressive-web-apps'), // Title
|
79 |
+
'superpwa_icons_cb', // Callback function
|
80 |
+
'superpwa_splash_screen_section', // Page slug
|
81 |
+
'superpwa_splash_screen_section' // Settings Section ID
|
82 |
+
);
|
83 |
+
|
84 |
+
}
|
85 |
+
add_action( 'admin_init', 'superpwa_register_settings' );
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Validate and sanitize user input before its saved to database
|
89 |
+
*
|
90 |
+
* @since 1.0
|
91 |
+
*/
|
92 |
+
function superpwa_validater_and_sanitizer( $settings ) {
|
93 |
+
|
94 |
+
// Sanitize hex color input
|
95 |
+
$settings['background_color'] = preg_match( '/#([a-f0-9]{3}){1,2}\b/i', $settings['background_color'] ) ? sanitize_text_field( $settings['background_color'] ) : '#D5E0EB';
|
96 |
+
|
97 |
+
// Sanitize application icon
|
98 |
+
$settings['icon'] = empty( sanitize_text_field($settings['icon']) ) ? SUPERPWA_PATH_SRC . 'public/images/logo.png' : sanitize_text_field($settings['icon']);
|
99 |
+
|
100 |
+
return $settings;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Get settings from database
|
105 |
+
*
|
106 |
+
* @since 1.0
|
107 |
+
* @return Array A merged array of default and settings saved in database.
|
108 |
+
*/
|
109 |
+
function superpwa_get_settings() {
|
110 |
+
|
111 |
+
$defaults = array(
|
112 |
+
'background_color' => '#D5E0EB',
|
113 |
+
'icon' => SUPERPWA_PATH_SRC . 'public/images/logo.png',
|
114 |
+
);
|
115 |
+
|
116 |
+
$settings = get_option('superpwa_settings', $defaults);
|
117 |
+
|
118 |
+
return $settings;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Enqueue CSS and JS
|
123 |
+
*
|
124 |
+
* @since 1.0
|
125 |
+
*/
|
126 |
+
function superpwa_enqueue_css_js( $hook ) {
|
127 |
+
|
128 |
+
// Load only on SuperPWA plugin pages
|
129 |
+
if ( $hook != "settings_page_superpwa" ) {
|
130 |
+
return;
|
131 |
+
}
|
132 |
+
|
133 |
+
// Color picker CSS
|
134 |
+
// @refer https://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/
|
135 |
+
wp_enqueue_style( 'wp-color-picker' );
|
136 |
+
|
137 |
+
// Everything needed for media upload
|
138 |
+
wp_enqueue_media();
|
139 |
+
|
140 |
+
// Main JS
|
141 |
+
wp_enqueue_script( 'superpwa-main-js', SUPERPWA_PATH_SRC . 'admin/js/main.js', array( 'wp-color-picker' ), false, true );
|
142 |
+
}
|
143 |
+
add_action( 'admin_enqueue_scripts', 'superpwa_enqueue_css_js' );
|
admin/admin-ui-render.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin UI setup and render
|
4 |
+
*
|
5 |
+
* @since 1.0
|
6 |
+
* @function superpwa_manifest_cb() Manifest Callback
|
7 |
+
* @function superpwa_manifest_status_cb Manifest Status
|
8 |
+
* @function superpwa_splash_screen_cb() Splash Screen Callback
|
9 |
+
* @function superpwa_background_color_cb() Background Color
|
10 |
+
* @function superpwa_icons_cb() Application Icons
|
11 |
+
* @function superpwa_admin_interface_render() Admin interface renderer
|
12 |
+
*/
|
13 |
+
|
14 |
+
// Exit if accessed directly
|
15 |
+
if ( ! defined('ABSPATH') ) exit;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Manifest Callback
|
19 |
+
*
|
20 |
+
* @since 1.0
|
21 |
+
*/
|
22 |
+
function superpwa_manifest_cb() {
|
23 |
+
|
24 |
+
echo '<p>' . __('The manifest includes all the information about your Progressive Web App. SuperPWA generates the manifest automatically.') . '</p>';
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Manifest Status
|
29 |
+
*
|
30 |
+
* @since 1.0
|
31 |
+
*/
|
32 |
+
function superpwa_manifest_status_cb() {
|
33 |
+
|
34 |
+
if ( superpwa_get_contents( ABSPATH . SUPERPWA_MANIFEST_FILENAME ) ) {
|
35 |
+
|
36 |
+
printf( __( 'Manifest was generated successfully. You can <a href="%s" target="_blank">see it here</a>.', 'super-progressive-web-apps' ), SUPERPWA_MANIFEST_SRC );
|
37 |
+
} else {
|
38 |
+
|
39 |
+
echo '<p>' . __('Manifest generation failed. Check if WordPress can write to your root folder (the same folder with wp-config.php).', 'super-progressive-web-apps') . '</p>';
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Splash Screen Callback
|
46 |
+
*
|
47 |
+
* @since 1.0
|
48 |
+
*/
|
49 |
+
function superpwa_splash_screen_cb() {
|
50 |
+
|
51 |
+
echo '<p>' . __('The values you set here will be used for the splash screen that supported browsers choose to display.', 'super-progressive-web-apps') . '</p>';
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Background Color
|
56 |
+
*
|
57 |
+
* @since 1.0
|
58 |
+
*/
|
59 |
+
function superpwa_background_color_cb() {
|
60 |
+
|
61 |
+
// Get Settings
|
62 |
+
$settings = superpwa_get_settings(); ?>
|
63 |
+
|
64 |
+
<!-- Background Color -->
|
65 |
+
<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">
|
66 |
+
|
67 |
+
<?php
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Application Icons
|
72 |
+
*
|
73 |
+
* @since 1.0
|
74 |
+
*/
|
75 |
+
function superpwa_icons_cb() {
|
76 |
+
|
77 |
+
// Get Settings
|
78 |
+
$settings = superpwa_get_settings(); ?>
|
79 |
+
|
80 |
+
<!-- Application Icon -->
|
81 |
+
<p style="margin-bottom: 8px;"><?php _e('This will be the icon of your PWA when installed on the phone. Must be a <code>PNG</code> image exactly <code>192x192</code> in size.', 'super-progressive-web-apps'); ?></p>
|
82 |
+
<input type="text" name="superpwa_settings[icon]" id="superpwa_settings[icon]" class="superpwa-icon" size="50" value="<?php echo isset( $settings['icon'] ) ? esc_attr( $settings['icon']) : ''; ?>">
|
83 |
+
<button type="button" class="button superpwa-icon-upload" data-editor="content">
|
84 |
+
<span class="dashicons dashicons-format-image" style="margin-top: 4px;"></span> Choose Icon
|
85 |
+
</button>
|
86 |
+
|
87 |
+
<?php
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Admin interface renderer
|
92 |
+
*
|
93 |
+
* @since 1.0
|
94 |
+
*/
|
95 |
+
function superpwa_admin_interface_render () {
|
96 |
+
|
97 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* If settings are inside WP-Admin > Settings, then WordPress will automatically display Settings Saved. If not used this block
|
103 |
+
* @refer https://core.trac.wordpress.org/ticket/31000
|
104 |
+
* If the user have submitted the settings, WordPress will add the "settings-updated" $_GET parameter to the url
|
105 |
+
*
|
106 |
+
if ( isset( $_GET['settings-updated'] ) ) {
|
107 |
+
// Add settings saved message with the class of "updated"
|
108 |
+
add_settings_error( 'superpwa_settings_saved_message', 'superpwa_settings_saved_message', __( 'Settings are Saved', 'super-progressive-web-apps' ), 'updated' );
|
109 |
+
}
|
110 |
+
|
111 |
+
// Show Settings Saved Message
|
112 |
+
settings_errors( 'superpwa_settings_saved_message' ); */?>
|
113 |
+
|
114 |
+
<div class="wrap">
|
115 |
+
<h1>Super Progressive Web Apps <sup><?php echo SUPERPWA_VERSION; ?></sup></h1>
|
116 |
+
|
117 |
+
<form action="options.php" method="post" enctype="multipart/form-data">
|
118 |
+
<?php
|
119 |
+
// Output nonce, action, and option_page fields for a settings page.
|
120 |
+
settings_fields( 'superpwa_settings_group' );
|
121 |
+
|
122 |
+
// Manifest
|
123 |
+
do_settings_sections( 'superpwa_manifest_section' ); // Page slug
|
124 |
+
|
125 |
+
// Splash Screen
|
126 |
+
do_settings_sections( 'superpwa_splash_screen_section' ); // Page slug
|
127 |
+
|
128 |
+
// Output save settings button
|
129 |
+
submit_button( __('Save Settings', 'super-progressive-web-apps') );
|
130 |
+
?>
|
131 |
+
</form>
|
132 |
+
</div>
|
133 |
+
<?php
|
134 |
+
}
|
admin/basic-setup.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Basic setup functions for the plugin
|
4 |
+
*
|
5 |
+
* @since 1.0
|
6 |
+
* @function superpwa_activate_plugin() Plugin activatation todo list
|
7 |
+
* @function superpwa_deactivate_plugin Plugin deactivation todo list
|
8 |
+
* @function superpwa_load_plugin_textdomain() Load plugin text domain
|
9 |
+
* @function superpwa_settings_link() Print direct link to plugin settings in plugins list in admin
|
10 |
+
* @function superpwa_plugin_row_meta() Add donate and other links to plugins list
|
11 |
+
* @function superpwa_footer_text() Admin footer text
|
12 |
+
* @function superpwa_footer_version() Admin footer version
|
13 |
+
*/
|
14 |
+
|
15 |
+
// Exit if accessed directly
|
16 |
+
if ( ! defined('ABSPATH') ) exit;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Plugin activatation todo list
|
20 |
+
*
|
21 |
+
* This function runs when user activates the plugin. Used in register_activation_hook in the main plugin file.
|
22 |
+
* @since 1.0
|
23 |
+
*/
|
24 |
+
function superpwa_activate_plugin() {
|
25 |
+
|
26 |
+
// Generate manifest with default options
|
27 |
+
superpwa_generate_manifest();
|
28 |
+
|
29 |
+
// Generate service worker
|
30 |
+
superpwa_generate_sw();
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Plugin deactivation todo list
|
35 |
+
*
|
36 |
+
* Runs during deactivation. During uninstall uninstall.php is also executed
|
37 |
+
* @since 1.0
|
38 |
+
*/
|
39 |
+
function superpwa_deactivate_plugin() {
|
40 |
+
|
41 |
+
// Delete manifest
|
42 |
+
superpwa_delete_manifest();
|
43 |
+
|
44 |
+
// Delete service worker
|
45 |
+
superpwa_delete_sw();
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Load plugin text domain
|
50 |
+
*
|
51 |
+
* @since 1.0
|
52 |
+
*/
|
53 |
+
function superpwa_load_plugin_textdomain() {
|
54 |
+
|
55 |
+
load_plugin_textdomain( 'super-progressive-web-apps', FALSE, SUPERPWA_PATH_ABS . '/languages/' );
|
56 |
+
}
|
57 |
+
add_action( 'plugins_loaded', 'superpwa_load_plugin_textdomain' );
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Print direct link to plugin settings in plugins list in admin
|
61 |
+
*
|
62 |
+
* @since 1.0
|
63 |
+
*/
|
64 |
+
function superpwa_settings_link( $links ) {
|
65 |
+
|
66 |
+
return array_merge(
|
67 |
+
array(
|
68 |
+
'settings' => '<a href="' . admin_url( 'options-general.php?page=superpwa' ) . '">' . __( 'Settings', 'super-progressive-web-apps' ) . '</a>'
|
69 |
+
),
|
70 |
+
$links
|
71 |
+
);
|
72 |
+
}
|
73 |
+
add_filter( 'plugin_action_links_super-progressive-web-apps/superpwa.php', 'superpwa_settings_link' );
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Add donate and other links to plugins list
|
77 |
+
*
|
78 |
+
* @since 1.0
|
79 |
+
*/
|
80 |
+
function superpwa_plugin_row_meta( $links, $file ) {
|
81 |
+
|
82 |
+
if ( strpos( $file, 'superpwa.php' ) !== false ) {
|
83 |
+
$new_links = array(
|
84 |
+
'demo' => '<a href="https://superpwa.com" target="_blank">Demo</a>',
|
85 |
+
);
|
86 |
+
$links = array_merge( $links, $new_links );
|
87 |
+
}
|
88 |
+
|
89 |
+
return $links;
|
90 |
+
}
|
91 |
+
// add_filter( 'plugin_row_meta', 'superpwa_plugin_row_meta', 10, 2 ); // Todo: To be added once demo website is ready
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Admin footer text
|
95 |
+
*
|
96 |
+
* A function to add footer text to the settings page of the plugin.
|
97 |
+
* @since 1.0
|
98 |
+
* @refer https://codex.wordpress.org/Function_Reference/get_current_screen
|
99 |
+
*/
|
100 |
+
function superpwa_footer_text($default) {
|
101 |
+
|
102 |
+
// Retun default on non-plugin pages
|
103 |
+
$screen = get_current_screen();
|
104 |
+
if ( $screen->id !== "settings_page_superpwa" ) {
|
105 |
+
return $default;
|
106 |
+
}
|
107 |
+
|
108 |
+
$superpwa_footer_text = sprintf( __( 'If you like SuperPWA, please leave a <a href="%s" target="_blank">★★★★★</a> rating to support continued development. Thanks a bunch!', 'super-progressive-web-apps' ),
|
109 |
+
'https://wordpress.org/support/plugin/super-progressive-web-apps/reviews/?rate=5#new-post'
|
110 |
+
);
|
111 |
+
|
112 |
+
return $superpwa_footer_text;
|
113 |
+
}
|
114 |
+
// add_filter('admin_footer_text', 'superpwa_footer_text'); // Todo: Wait till ver 1.1 or more to add this
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Admin footer version
|
118 |
+
*
|
119 |
+
* @since 1.0
|
120 |
+
*/
|
121 |
+
function superpwa_footer_version($default) {
|
122 |
+
|
123 |
+
// Retun default on non-plugin pages
|
124 |
+
$screen = get_current_screen();
|
125 |
+
if ( $screen->id !== "settings_page_superpwa" ) {
|
126 |
+
return $default;
|
127 |
+
}
|
128 |
+
|
129 |
+
return 'SuperPWA ' . SUPERPWA_VERSION;
|
130 |
+
}
|
131 |
+
add_filter( 'update_footer', 'superpwa_footer_version', 11 );
|
admin/do.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Operations of the plugin are included here.
|
4 |
+
*
|
5 |
+
* @since 1.0
|
6 |
+
* @function superpwa_after_save_settings_todo() Todo list after saving admin options
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
if ( ! defined('ABSPATH') ) exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Todo list after saving admin options
|
14 |
+
*
|
15 |
+
* Regenerate manifest
|
16 |
+
* Regenerate service worker
|
17 |
+
*
|
18 |
+
* @since 1.0
|
19 |
+
*/
|
20 |
+
function superpwa_after_save_settings_todo() {
|
21 |
+
|
22 |
+
// Regenerate manifest
|
23 |
+
superpwa_generate_manifest();
|
24 |
+
|
25 |
+
// Regenerate service worker
|
26 |
+
superpwa_generate_sw();
|
27 |
+
}
|
28 |
+
add_action( 'add_option_superpwa_settings', 'superpwa_after_save_settings_todo' );
|
29 |
+
add_action( 'update_option_superpwa_settings', 'superpwa_after_save_settings_todo' );
|
admin/filesystem.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Filesystem Operations
|
4 |
+
*
|
5 |
+
* @since 1.0
|
6 |
+
* @function superpwa_wp_filesystem_init() Initialize the WP filesystem
|
7 |
+
* @function superpwa_put_contents() Write to a file using WP_Filesystem() functions
|
8 |
+
* @function superpwa_get_contents() Read contents of a file using WP_Filesystem() functions
|
9 |
+
* @function superpwa_delete() Delete a file
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined('ABSPATH') ) exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Initialize the WP filesystem
|
17 |
+
*
|
18 |
+
* @since 1.0
|
19 |
+
*/
|
20 |
+
function superpwa_wp_filesystem_init() {
|
21 |
+
|
22 |
+
global $wp_filesystem;
|
23 |
+
|
24 |
+
if ( empty( $wp_filesystem ) ) {
|
25 |
+
require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/file.php' );
|
26 |
+
WP_Filesystem();
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Write to a file using WP_Filesystem() functions
|
32 |
+
*
|
33 |
+
* @param $file Filename with path
|
34 |
+
* @param $content Contents to be written to the file. Default null
|
35 |
+
* @return True on success, false if file isn't passed or if writing failed.
|
36 |
+
* @since 1.0
|
37 |
+
*/
|
38 |
+
function superpwa_put_contents( $file, $content = null ) {
|
39 |
+
|
40 |
+
// Return false if no filename is provided
|
41 |
+
if ( empty( $file ) )
|
42 |
+
return false;
|
43 |
+
|
44 |
+
// Initialize the WP filesystem
|
45 |
+
superpwa_wp_filesystem_init();
|
46 |
+
global $wp_filesystem;
|
47 |
+
|
48 |
+
if( ! $wp_filesystem->put_contents( $file, $content, 0644) ) {
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
|
52 |
+
return true;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Read contents of a file using WP_Filesystem() functions
|
57 |
+
*
|
58 |
+
* @param $file Filename with path.
|
59 |
+
* @paral $array Set true to return read data as an array. False by default.
|
60 |
+
* @return string|bool The function returns the read data or false on failure.
|
61 |
+
* @since 1.0
|
62 |
+
*/
|
63 |
+
function superpwa_get_contents( $file, $array = false ) {
|
64 |
+
|
65 |
+
// Return false if no filename is provided
|
66 |
+
if ( empty( $file ) )
|
67 |
+
return false;
|
68 |
+
|
69 |
+
// Initialize the WP filesystem
|
70 |
+
superpwa_wp_filesystem_init();
|
71 |
+
global $wp_filesystem;
|
72 |
+
|
73 |
+
// Reads entire file into a string
|
74 |
+
if ( $array == false )
|
75 |
+
return $wp_filesystem->get_contents( $file );
|
76 |
+
|
77 |
+
// Reads entire file into an array
|
78 |
+
return $wp_filesystem->get_contents_array( $file );
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Delete a file
|
83 |
+
*
|
84 |
+
* @param $file Filename with path
|
85 |
+
* @return bool True on success, false otherwise
|
86 |
+
* @since 1.0
|
87 |
+
*/
|
88 |
+
function superpwa_delete( $file ) {
|
89 |
+
|
90 |
+
// Return false if no filename is provided
|
91 |
+
if ( empty( $file ) )
|
92 |
+
return false;
|
93 |
+
|
94 |
+
// Initialize the WP filesystem
|
95 |
+
superpwa_wp_filesystem_init();
|
96 |
+
global $wp_filesystem;
|
97 |
+
|
98 |
+
return $wp_filesystem->delete( $file );
|
99 |
+
}
|
admin/index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden
|
admin/js/main.js
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($){
|
2 |
+
$('.superpwa-colorpicker').wpColorPicker(); // Color picker
|
3 |
+
$('.superpwa-icon-upload').click(function(e) { // Media 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 |
+
});
|
admin/loader.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 basic setup. Plugin list links, text domain, footer links etc.
|
12 |
+
require_once( SUPERPWA_PATH_ABS . 'admin/basic-setup.php');
|
13 |
+
|
14 |
+
// Load admin setup. Register menus and settings
|
15 |
+
require_once( SUPERPWA_PATH_ABS . 'admin/admin-setup.php');
|
16 |
+
|
17 |
+
// Render Admin UI
|
18 |
+
require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render.php');
|
19 |
+
|
20 |
+
// Load Filesystem functions
|
21 |
+
require_once( SUPERPWA_PATH_ABS . 'admin/filesystem.php');
|
22 |
+
|
23 |
+
// Manifest Functions
|
24 |
+
require_once( SUPERPWA_PATH_ABS . 'public/manifest.php');
|
25 |
+
|
26 |
+
// Service Worker Functions
|
27 |
+
require_once( SUPERPWA_PATH_ABS . 'public/sw.php');
|
28 |
+
|
29 |
+
// Do plugin operations
|
30 |
+
require_once( SUPERPWA_PATH_ABS . 'admin/do.php');
|
includes/index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden
|
index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden
|
languages/super-progressive-web-apps.pot
ADDED
File without changes
|
license.txt
ADDED
@@ -0,0 +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 |
+
|
public/images/logo.png
ADDED
Binary file
|
public/index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden
|
public/js/register-sw.js
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
if ('serviceWorker' in navigator) {
|
2 |
+
window.addEventListener('load', function() {
|
3 |
+
navigator.serviceWorker.register(superpwa_sw.url)
|
4 |
+
.then(function() { console.log('SuperPWA Service Worker Registered'); });
|
5 |
+
});
|
6 |
+
}
|
public/manifest.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Operations of the plugin are included here.
|
4 |
+
*
|
5 |
+
* @since 1.0
|
6 |
+
* @function superpwa_generate_manifest() Generate and write manifest
|
7 |
+
* @function superpwa_add_manifest_to_header() Add manifest to header (wp_head)
|
8 |
+
* @function superpwa_register_service_worker() Register service worker in the footer (wp_footer)
|
9 |
+
* @function superpwa_delete_manifest() Delete manifest
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined('ABSPATH') ) exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Generate and write manifest into WordPress root folder
|
17 |
+
*
|
18 |
+
* @return true on success, false on failure.
|
19 |
+
* @since 1.0
|
20 |
+
*/
|
21 |
+
function superpwa_generate_manifest() {
|
22 |
+
|
23 |
+
// Get Settings
|
24 |
+
$settings = superpwa_get_settings();
|
25 |
+
|
26 |
+
$manifest = array(
|
27 |
+
'name' => get_bloginfo('name'),
|
28 |
+
'short_name' => get_bloginfo('name'),
|
29 |
+
'icons' => array(
|
30 |
+
array(
|
31 |
+
'src' => $settings['icon'],
|
32 |
+
'sizes' => '192x192', // must be 192x192. Todo: use getimagesize($settings['icon'])[0].'x'.getimagesize($settings['icon'])[1] in the future
|
33 |
+
'type' => 'image/png', // must be image/png. Todo: use getimagesize($settings['icon'])['mime']
|
34 |
+
),
|
35 |
+
),
|
36 |
+
'background_color' => $settings['background_color'],
|
37 |
+
'theme_color' => $settings['background_color'],
|
38 |
+
'display' => 'standalone',
|
39 |
+
'orientation' => 'natural',
|
40 |
+
'start_url' => '/',
|
41 |
+
);
|
42 |
+
|
43 |
+
// Delete manifest if it exists
|
44 |
+
superpwa_delete_manifest();
|
45 |
+
|
46 |
+
if ( ! superpwa_put_contents( SUPERPWA_MANIFEST_ABS, json_encode($manifest) ) )
|
47 |
+
return false;
|
48 |
+
|
49 |
+
return true;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Add manifest to header (wp_head)
|
54 |
+
*
|
55 |
+
* @since 1.0
|
56 |
+
*/
|
57 |
+
function superpwa_add_manifest_to_header() {
|
58 |
+
|
59 |
+
echo '<!-- Manifest added by SuperPWA -->' . PHP_EOL . '<link rel="manifest" href="'. SUPERPWA_MANIFEST_SRC . '">';
|
60 |
+
}
|
61 |
+
add_action( 'wp_head', 'superpwa_add_manifest_to_header' );
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Delete manifest
|
65 |
+
*
|
66 |
+
* @return true on success, false on failure
|
67 |
+
* @since 1.0
|
68 |
+
*/
|
69 |
+
function superpwa_delete_manifest() {
|
70 |
+
|
71 |
+
return superpwa_delete( SUPERPWA_MANIFEST_ABS );
|
72 |
+
}
|
public/sw.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Operations of the plugin are included here.
|
4 |
+
*
|
5 |
+
* @since 1.0
|
6 |
+
* @function superpwa_generate_sw() Generate and write service worker into sw.js
|
7 |
+
* @function superpwa_sw_template() Service Worker Tempalte
|
8 |
+
* @function superpwa_register_sw() Register service worker
|
9 |
+
* @function superpwa_delete_sw() Delete Service Worker
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined('ABSPATH') ) exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Generate and write service worker into superpwa-sw.js
|
17 |
+
*
|
18 |
+
* @return true on success, false on failure.
|
19 |
+
* @since 1.0
|
20 |
+
*/
|
21 |
+
function superpwa_generate_sw() {
|
22 |
+
|
23 |
+
// Get Settings
|
24 |
+
$settings = superpwa_get_settings();
|
25 |
+
|
26 |
+
// Get the service worker tempalte
|
27 |
+
$sw = superpwa_sw_template();
|
28 |
+
|
29 |
+
// Delete service worker if it exists
|
30 |
+
superpwa_delete_sw();
|
31 |
+
|
32 |
+
if ( ! superpwa_put_contents( SUPERPWA_SW_ABS, $sw ) )
|
33 |
+
return false;
|
34 |
+
|
35 |
+
return true;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Service Worker Tempalte
|
40 |
+
*
|
41 |
+
* @return String Contents to be written to superpwa-sw.js
|
42 |
+
* @since 1.0
|
43 |
+
*/
|
44 |
+
function superpwa_sw_template() {
|
45 |
+
|
46 |
+
// Get Settings
|
47 |
+
$settings = superpwa_get_settings();
|
48 |
+
|
49 |
+
// Start output buffer. Everything from here till ob_get_clean() is returned
|
50 |
+
ob_start(); ?>
|
51 |
+
'use strict';
|
52 |
+
const cacheName = '<?php echo parse_url( get_bloginfo( 'wpurl' ) )['host'] . '-ver-' . SUPERPWA_VERSION; ?>';
|
53 |
+
const startPage = '/';
|
54 |
+
const offlinePage = '/';
|
55 |
+
const fallbackImage = '<?php echo $settings['icon']; ?>';
|
56 |
+
const filesToCache = [startPage, offlinePage, fallbackImage];
|
57 |
+
const neverCache = [/\/wp-admin/,/\/wp-login/,/preview=true/];
|
58 |
+
|
59 |
+
// Install
|
60 |
+
self.addEventListener('install', function(e) {
|
61 |
+
console.log('SuperPWA Service Worker Installation');
|
62 |
+
e.waitUntil(
|
63 |
+
caches.open(cacheName).then(function(cache) {
|
64 |
+
console.log('SuperPWA Service Worker Caching Dependencies');
|
65 |
+
return cache.addAll(filesToCache);
|
66 |
+
})
|
67 |
+
);
|
68 |
+
});
|
69 |
+
|
70 |
+
// Activate
|
71 |
+
self.addEventListener('activate', function(e) {
|
72 |
+
console.log('SuperPWA Service Worker Activation');
|
73 |
+
e.waitUntil(
|
74 |
+
caches.keys().then(function(keyList) {
|
75 |
+
return Promise.all(keyList.map(function(key) {
|
76 |
+
if (key !== cacheName) {
|
77 |
+
console.log('SuperPWA Service Worker Old Cache Removed', key);
|
78 |
+
return caches.delete(key);
|
79 |
+
}
|
80 |
+
}));
|
81 |
+
})
|
82 |
+
);
|
83 |
+
return self.clients.claim();
|
84 |
+
});
|
85 |
+
|
86 |
+
// Fetch
|
87 |
+
self.addEventListener('fetch', function(e) {
|
88 |
+
console.log('SuperPWA fetched ', e.request.url);
|
89 |
+
e.respondWith(
|
90 |
+
caches.match(e.request).then(function(response) {
|
91 |
+
return response || fetch(e.request);
|
92 |
+
})
|
93 |
+
);
|
94 |
+
});
|
95 |
+
<?php return ob_get_clean();
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Register service worker
|
100 |
+
*
|
101 |
+
* @since 1.0
|
102 |
+
* @refer https://developers.google.com/web/fundamentals/primers/service-workers/registration#conclusion
|
103 |
+
*/
|
104 |
+
function superpwa_register_sw() {
|
105 |
+
|
106 |
+
wp_enqueue_script('superpwa-register-sw', SUPERPWA_PATH_SRC . 'public/js/register-sw.js', array(), null, true );
|
107 |
+
wp_localize_script('superpwa-register-sw', 'superpwa_sw', array(
|
108 |
+
'url' => SUPERPWA_SW_SRC,
|
109 |
+
)
|
110 |
+
);
|
111 |
+
}
|
112 |
+
add_action( 'wp_enqueue_scripts', 'superpwa_register_sw' );
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Delete Service Worker
|
116 |
+
*
|
117 |
+
* @return true on success, false on failure
|
118 |
+
* @since 1.0
|
119 |
+
*/
|
120 |
+
function superpwa_delete_sw() {
|
121 |
+
|
122 |
+
return superpwa_delete( SUPERPWA_SW_ABS );
|
123 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Super Progressive Web Apps ===
|
2 |
+
Contributors: arunbasillal, josevarghese
|
3 |
+
Donate link: http://millionclues.com/donate/
|
4 |
+
Tags: pwa, progressive web apps, manifest, android app, mobile, superpwa
|
5 |
+
Requires at least: 3.5.0
|
6 |
+
Tested up to: 4.9.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.
|
13 |
+
|
14 |
+
== Description ==
|
15 |
+
|
16 |
+
A Progressive Web App (PWA) is a new technology that is 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.
|
17 |
+
|
18 |
+
Users can come back to your website by launching the app from their home screen and interact with your website through an app like interface.
|
19 |
+
|
20 |
+
**What included in the box**
|
21 |
+
|
22 |
+
Here is a list of feature the current release can do:
|
23 |
+
|
24 |
+
* Generate a manifest for your website and add it to the <head> of the page
|
25 |
+
* Set the application icon for your Progressive Web App.
|
26 |
+
* Set the background color for the splash screen of your Progressive Web App.
|
27 |
+
* Your website will show "Add to home screen" notice when accessed in a supported browser (please refer FAQ).
|
28 |
+
|
29 |
+
Please note that the app is very basic at the moment and does not include offline fall-backs. Only the homepage is cached offline as of now.
|
30 |
+
|
31 |
+
**What features are we working on**
|
32 |
+
|
33 |
+
* Offline pages
|
34 |
+
* Aggressive caching of pages
|
35 |
+
* Better admin notices and info
|
36 |
+
|
37 |
+
**About us**
|
38 |
+
|
39 |
+
We are a duo who got excited about the idea. Our mission is simple: Help you build an awesome PWA that users would want to have on their home screen.
|
40 |
+
|
41 |
+
When we first heard about PWA we wanted to learn everything about. We have spent countless hours learning and wants to share it with the world.
|
42 |
+
|
43 |
+
Please give us your constructive feedback and support.
|
44 |
+
|
45 |
+
**Feature Requests, Issues, Pull Requests**
|
46 |
+
|
47 |
+
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.
|
48 |
+
|
49 |
+
== Installation ==
|
50 |
+
|
51 |
+
To install this plugin:
|
52 |
+
|
53 |
+
1. Install the plugin through the WordPress admin interface, or upload the plugin folder to /wp-content/plugins/ using ftp.
|
54 |
+
2. Activate the plugin through the 'Plugins' screen in WordPress.
|
55 |
+
3. Go to WordPress Admin > Settings > SuperPWA
|
56 |
+
|
57 |
+
== Frequently Asked Questions ==
|
58 |
+
|
59 |
+
= Which devices and browsers will it work? =
|
60 |
+
|
61 |
+
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. The list is fast growing and is likely to be supported in most major browsers by the end of this year.
|
62 |
+
|
63 |
+
== Screenshots ==
|
64 |
+
|
65 |
+
1. Settings page in WordPress Admin > Settings > SuperPWA
|
66 |
+
|
67 |
+
== Changelog ==
|
68 |
+
|
69 |
+
= 1.0 =
|
70 |
+
* Date: 22.January.2018
|
71 |
+
* First release of the plugin.
|
72 |
+
|
73 |
+
== Upgrade Notice ==
|
74 |
+
|
75 |
+
= 1.0 =
|
76 |
+
* First release of the plugin.
|
superpwa.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Super Progressive Web Apps
|
4 |
+
* Plugin URI: https://github.com/SuperPWA/Super-Progressive-Web-Apps
|
5 |
+
* Description: Convert your WordPress website into a Progressive Web App
|
6 |
+
* Author: SuperPWA
|
7 |
+
* Contributors: Arun Basil Lal, Jose Varghese
|
8 |
+
* Version: 1.0
|
9 |
+
* Text Domain: super-progressive-web-apps
|
10 |
+
* Domain Path: /languages
|
11 |
+
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
|
14 |
+
/**
|
15 |
+
* This plugin was developed using the WordPress starter plugin template by Arun Basil Lal <arunbasillal@gmail.com>
|
16 |
+
* Please leave this credit and the directory structure intact for future developers who might read the code.
|
17 |
+
* @Github https://github.com/arunbasillal/WordPress-Starter-Plugin
|
18 |
+
*/
|
19 |
+
|
20 |
+
/**
|
21 |
+
* ~ Directory Structure ~
|
22 |
+
*
|
23 |
+
* /admin/ - Plugin backend stuff.
|
24 |
+
* /includes/ - External third party classes and libraries.
|
25 |
+
* /languages/ - Translation files go here.
|
26 |
+
* /public/ - Front end files go here.
|
27 |
+
* index.php - Dummy file.
|
28 |
+
* license.txt - GPL v2
|
29 |
+
* superpwa.php - File containing plugin name and other version info for WordPress.
|
30 |
+
* readme.txt - Readme for WordPress plugin repository. https://wordpress.org/plugins/files/2017/03/readme.txt
|
31 |
+
* uninstall.php - Fired when the plugin is uninstalled.
|
32 |
+
*/
|
33 |
+
|
34 |
+
/**
|
35 |
+
* ~ Release TODO ~
|
36 |
+
*
|
37 |
+
* Update SUPERPWA_VERSION
|
38 |
+
*/
|
39 |
+
|
40 |
+
// Exit if accessed directly
|
41 |
+
if ( ! defined('ABSPATH') ) exit;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Define constants
|
45 |
+
*
|
46 |
+
* @since 1.0
|
47 |
+
*/
|
48 |
+
if ( ! defined('SUPERPWA_PATH_ABS ') ) define('SUPERPWA_PATH_ABS', plugin_dir_path( __FILE__ )); // absolute path to the plugin directory. eg - /var/www/html/wp-content/plugins/superpwa/
|
49 |
+
if ( ! defined('SUPERPWA_PATH_SRC') ) define('SUPERPWA_PATH_SRC', plugin_dir_url( __FILE__ )); // link to the plugin folder. eg - http://example.com/wp/wp-content/plugins/superpwa/
|
50 |
+
if ( ! defined('SUPERPWA_VERSION') ) define('SUPERPWA_VERSION', '1.0'); // Plugin version
|
51 |
+
if ( ! defined('SUPERPWA_MANIFEST_FILENAME') ) define('SUPERPWA_MANIFEST_FILENAME', 'superpwa-manifest.json'); // Name of Manifest file
|
52 |
+
if ( ! defined('SUPERPWA_MANIFEST_ABS') ) define('SUPERPWA_MANIFEST_ABS', trailingslashit( ABSPATH ) . SUPERPWA_MANIFEST_FILENAME); // Absolute path to manifest
|
53 |
+
if ( ! defined('SUPERPWA_MANIFEST_SRC') ) define('SUPERPWA_MANIFEST_SRC', trailingslashit( get_bloginfo('wpurl') ) . SUPERPWA_MANIFEST_FILENAME); // Link to manifest
|
54 |
+
if ( ! defined('SUPERPWA_SW_FILENAME') ) define('SUPERPWA_SW_FILENAME', 'superpwa-sw.js'); // Name of service worker file
|
55 |
+
if ( ! defined('SUPERPWA_SW_ABS') ) define('SUPERPWA_SW_ABS', trailingslashit( ABSPATH ) . SUPERPWA_SW_FILENAME); // Absolute path to service worker. SW must be in the root folder
|
56 |
+
if ( ! defined('SUPERPWA_SW_SRC') ) define('SUPERPWA_SW_SRC', trailingslashit( get_bloginfo('wpurl') ) . SUPERPWA_SW_FILENAME); // Link to service worker
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Add plugin version to database
|
60 |
+
*
|
61 |
+
* @since 1.0
|
62 |
+
* @refer https://codex.wordpress.org/Creating_Tables_with_Plugins#Adding_an_Upgrade_Function
|
63 |
+
*/
|
64 |
+
update_option('superpwa_version', SUPERPWA_VERSION); // Change this to add_option if a release needs to check installed version.
|
65 |
+
|
66 |
+
// Load everything
|
67 |
+
require_once( SUPERPWA_PATH_ABS . 'admin/loader.php');
|
68 |
+
|
69 |
+
// Register activation hook (this has to be in the main plugin file.)
|
70 |
+
register_activation_hook( __FILE__, 'superpwa_activate_plugin' );
|
71 |
+
|
72 |
+
// Register deactivatation hook
|
73 |
+
register_deactivation_hook( __FILE__, 'superpwa_deactivate_plugin' );
|
uninstall.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @since 1.0
|
7 |
+
*/
|
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 |
+
/**
|
18 |
+
* Delete database settings
|
19 |
+
*
|
20 |
+
* @since 1.0
|
21 |
+
*/
|
22 |
+
delete_option( 'superpwa_settings' );
|
23 |
+
delete_option( 'superpwa_version' );
|