diff --git a/3rd-party/onesignal.php b/3rd-party/onesignal.php index 87843d7..de84a45 100644 --- a/3rd-party/onesignal.php +++ b/3rd-party/onesignal.php @@ -2,58 +2,147 @@ /** * OneSignal integration * + * @link https://wordpress.org/plugins/onesignal-free-web-push-notifications/ + * * @since 1.6 - * @function superpwa_onesignal_manifest_notice_check() Check if OneSignal integration notice should be displayed or not. - * @function superpwa_onesignal_get_gcm_sender_id() Extract gcm_sender_id from OneSignal settings + * + * @function superpwa_onesignal_add_gcm_sender_id() Add gcm_sender_id to SuperPWA manifest + * @function superpwa_onesignal_sw_filename() Change Service Worker filename to OneSignalSDKWorker.js.php + * @function superpwa_onesignal_sw() Import OneSignal service worker in SuperPWA + * @function superpwa_onesignal_activation() OneSignal activation todo + * @function superpwa_onesignal_deactivation() OneSignal deactivation todo */ // Exit if accessed directly if ( ! defined('ABSPATH') ) exit; -/** - * Check if OneSignal integration notice should be displayed or not. - * - * @return Bool True if notice should be displayed. False otherwise. - * @since 1.5 - */ -function superpwa_onesignal_manifest_notice_check() { - - // No notice needed if OneSignal is not installed or there is no gcm_sender_id - if ( ! superpwa_onesignal_get_gcm_sender_id() ) { - return false; - } - - // Get OneSignal settins - $onesignal_wp_settings = get_option( 'OneSignalWPSetting' ); - - // No notice needed if OneSignal custom manifest is enabled and the manifest is the SuperPWA manifest - if ( - ( isset( $onesignal_wp_settings["use_custom_manifest"] ) ) && ( $onesignal_wp_settings["use_custom_manifest"] == 1 ) && - ( isset( $onesignal_wp_settings["custom_manifest_url"] ) ) && ( strcasecmp( trim( $onesignal_wp_settings["custom_manifest_url"] ), superpwa_manifest( 'src' ) ) == 0 ) - ) { - return false; - } - - // Display notice for every other case - return true; +// If OneSignal is installed and active +if ( class_exists( 'OneSignal' ) ) { + + // Add gcm_sender_id to SuperPWA manifest + add_filter( 'superpwa_manifest', 'superpwa_onesignal_add_gcm_sender_id' ); + + // Change service worker filename to match OneSignal's service worker + add_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' ); + + // Import OneSignal service worker in SuperPWA + add_filter( 'superpwa_sw_template', 'superpwa_onesignal_sw' ); } /** - * Extract gcm_sender_id from OneSignal settings + * Add gcm_sender_id to SuperPWA manifest * - * @link https://wordpress.org/plugins/onesignal-free-web-push-notifications/ + * OneSignal's gcm_sender_id is 482941778795 * - * @return (String|Bool) gcm_sender_id of OneSignal if OneSignal is installed, false otherwise - * @since 1.5 + * @param (array) $manifest Array with the manifest entries passed via the superpwa_manifest filter. + * + * @return (array) Array appended with the gcm_sender_id of OneSignal + * + * @since 1.8 + */ +function superpwa_onesignal_add_gcm_sender_id( $manifest ) { + + $manifest['gcm_sender_id'] = '482941778795'; + + return $manifest; +} + +/** + * Change Service Worker filename to OneSignalSDKWorker.js.php + * + * OneSignalSDKWorker.js.php is the name of the service worker of OneSignal. + * Since only one service worker is allowed in a given scope, OneSignal unregisters all other service workers and registers theirs. + * Having the same name prevents OneSignal from unregistering our service worker. + * + * @link https://documentation.onesignal.com/docs/web-push-setup-faq + * + * @param (string) $sw_filename Filename of SuperPWA service worker passed via superpwa_sw_filename filter. + * + * @return (string) Service worker filename changed to OneSignalSDKWorker.js.php + * + * @since 1.8 + */ +function superpwa_onesignal_sw_filename( $sw_filename ) { + return 'OneSignalSDKWorker.js.php'; +} + +/** + * Import OneSignal service worker in SuperPWA + * + * @param (string) $sw Service worker template of SuperPWA passed via superpwa_sw_template filter + * + * @return (string) Import OneSignal's service worker into SuperPWA + * + * @since 1.8 */ -function superpwa_onesignal_get_gcm_sender_id() { +function superpwa_onesignal_sw( $sw ) { - // If OneSignal is installed and active - if ( class_exists( 'OneSignal' ) ) { - - // This is the gcm_sender_id of OneSignal, same for all installs. - return '482941778795'; - } + $onesignal = '' . PHP_EOL . PHP_EOL; - return false; -} \ No newline at end of file + return $onesignal . $sw; +} + +/** + * OneSignal activation todo + * + * Regenerates SuperPWA manifest with the gcm_sender_id added. + * Delete current service worker. + * Regenerate SuperPWA service worker with the new filename. + * + * @since 1.8 + */ +function superpwa_onesignal_activation() { + + // Filter in gcm_sender_id to SuperPWA manifest + add_filter( 'superpwa_manifest', 'superpwa_onesignal_add_gcm_sender_id' ); + + // Regenerate SuperPWA manifest + superpwa_generate_manifest(); + + // Delete service worker if it exists + superpwa_delete_sw(); + + // Change service worker filename to match OneSignal's service worker + add_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' ); + + // Import OneSignal service worker in SuperPWA + add_filter( 'superpwa_sw_template', 'superpwa_onesignal_sw' ); + + // Regenerate SuperPWA service worker + superpwa_generate_sw(); +} +add_action( 'activate_onesignal-free-web-push-notifications/onesignal.php', 'superpwa_onesignal_activation', 11 ); + +/** + * OneSignal deactivation todo + * + * Regenerates SuperPWA manifest. + * Delete current service worker. + * Regenerate SuperPWA service worker. + * + * @since 1.8 + */ +function superpwa_onesignal_deactivation() { + + // Remove gcm_sender_id from SuperPWA manifest + remove_filter( 'superpwa_manifest', 'superpwa_onesignal_add_gcm_sender_id' ); + + // Regenerate SuperPWA manifest + superpwa_generate_manifest(); + + // Delete service worker if it exists + superpwa_delete_sw(); + + // Restore the default service worker of SuperPWA + remove_filter( 'superpwa_sw_filename', 'superpwa_onesignal_sw_filename' ); + + // Remove OneSignal service worker in SuperPWA + remove_filter( 'superpwa_sw_template', 'superpwa_onesignal_sw' ); + + // Regenerate SuperPWA service worker + superpwa_generate_sw(); +} +add_action( 'deactivate_onesignal-free-web-push-notifications/onesignal.php', 'superpwa_onesignal_deactivation', 11 ); \ No newline at end of file diff --git a/README.MD b/README.MD index d7c72c7..899221f 100644 --- a/README.MD +++ b/README.MD @@ -11,8 +11,8 @@
+ Supported + + + + + Beta or Partial Support + + + + + In Development +
+ 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. diff --git a/addons/apple-touch-icons.php b/addons/apple-touch-icons.php new file mode 100644 index 0000000..2fae81b --- /dev/null +++ b/addons/apple-touch-icons.php @@ -0,0 +1,36 @@ + Settings + * and adds them to wp_head using the superpwa_wp_head_tags filter. + * + * @param (string) $tags HTML element tags passed on by superpwa_wp_head_tags + * + * @return (string) Appends the Apple Touch Icons to the existing tag string + * + * @since 1.8 + */ +function superpwa_ati_add_apple_touch_icons( $tags ) { + + // Get the icons added via SuperPWA > Settings + $icons = superpwa_get_pwa_icons(); + + foreach( $icons as $icon ) { + $tags .= '' . PHP_EOL; + } + + return $tags; +} +add_filter( 'superpwa_wp_head_tags', 'superpwa_ati_add_apple_touch_icons' ); \ No newline at end of file diff --git a/addons/utm-tracking.php b/addons/utm-tracking.php index 8dc066a..f4b6ebf 100644 --- a/addons/utm-tracking.php +++ b/addons/utm-tracking.php @@ -231,7 +231,7 @@ function superpwa_utm_tracking_section_cb() { // Get add-on info $addon_utm_tracking = superpwa_get_addons( 'utm_tracking' ); - printf( '' . __( 'Add UTM campaign parameters to the Start Page
URL in your manifest. This will help you identify visitors coming specifically from your app. Read more about UTM Tracking.', 'super-progressive-web-apps' ) . '
' . __( 'This add-on automatically adds UTM campaign parameters to the Start Page
URL in your manifest. This will help you identify visitors coming specifically from your app. Read more about UTM Tracking.', 'super-progressive-web-apps' ) . '
' . superpwa_get_start_url( true ) . '
';
+ echo '' . superpwa_get_start_url( true ) . '
';
}
/**
@@ -260,8 +260,8 @@ function superpwa_utm_tracking_source_cb() {
- - superpwa', 'super-progressive-web-apps' ); ?> +
+ superpwa. The remaining fields are optional.', 'super-progressive-web-apps' ); ?>
- + @@ -298,7 +298,7 @@ function superpwa_utm_tracking_name_cb() { @@ -317,7 +317,7 @@ function superpwa_utm_tracking_term_cb() { @@ -336,7 +336,7 @@ function superpwa_utm_tracking_content_cb() { diff --git a/admin/admin-ui-render-addons.php b/admin/admin-ui-render-addons.php index 43c49b6..6892f9b 100644 --- a/admin/admin-ui-render-addons.php +++ b/admin/admin-ui-render-addons.php @@ -9,8 +9,8 @@ * @function superpwa_addons_status() Find add-on status * @function superpwa_addons_button_text() Button text based on add-on status * @function superpwa_addons_button_link() Action URL based on add-on status - * @function superpwa_addons_activator() Do bundled add-on activation and deactivation - * @function superpwa_addons_handle_activation() Handle add-on activation and deactivation + * @function superpwa_addons_handle_activation() Handle add-on activation + * @function superpwa_addons_handle_deactivation() Handle add-on deactivation */ // Exit if accessed directly @@ -23,19 +23,23 @@ * array( * 'addon-slug' => array( * 'name' => 'Add-On Name', - * 'type' => 'bundled | addon', * 'description' => 'Add-On description', + * 'type' => 'bundled | addon', * 'icon' => 'icon-for-addon-128x128.png', * 'link' => 'https://superpwa.com/addons/details-page-of-addon', + * 'admin_link' => admin_url( 'admin.php?page=superpwa-addon-admin-page' ), + * 'admin_link_text' => __( 'Customize settings | More Details →', 'super-progressive-web-apps' ), + * 'admin_link_target' => 'admin | external', * 'superpwa_min_version' => '1.7' // min version of SuperPWA required to use the add-on. * ) * ); * * @param (string) addon-slug to retrieve the details about a specific add-on. False by default and then returns all add-ons. * - * @return (array) an associative array containing all the info about SuperPWA add-ons. + * @return (array|boolean) an associative array containing all the info about the requested add-on. False if add-on not found. * * @since 1.7 + * @since 1.8 Returns false of $slug isn't found. */ function superpwa_get_addons( $slug = false ) { @@ -43,18 +47,36 @@ function superpwa_get_addons( $slug = false ) { $addons = array( 'utm_tracking' => array( 'name' => __( 'UTM Tracking', 'super-progressive-web-apps' ), - 'type' => 'bundled', 'description' => __( 'Track visits from your app by adding UTM tracking parameters to the Start Page URL.', 'super-progressive-web-apps' ), + 'type' => 'bundled', 'icon' => 'superpwa-128x128.png', 'link' => 'https://superpwa.com/addons/utm-tracking/', + 'admin_link' => admin_url( 'admin.php?page=superpwa-utm-tracking' ), + 'admin_link_text' => __( 'Customize Settings →', 'super-progressive-web-apps' ), + 'admin_link_target' => 'admin', 'superpwa_min_version' => '1.7', ), + 'apple_touch_icons' => array( + 'name' => __( 'Apple Touch Icons', 'super-progressive-web-apps' ), + 'description' => __( 'Set the Application Icon and Splash Screen Icon as Apple Touch Icons for compatibility with iOS devices.', 'super-progressive-web-apps' ), + 'type' => 'bundled', + 'icon' => 'superpwa-128x128.png', + 'link' => 'https://superpwa.com/addons/apple-touch-icons/', + 'admin_link' => 'https://superpwa.com/addons/apple-touch-icons/', + 'admin_link_text' => __( 'More Details →', 'super-progressive-web-apps' ), + 'admin_link_target' => 'external', + 'superpwa_min_version' => '1.8', + ), ); - if ( ( $slug === false ) || ( ! isset( $addons[$slug] ) ) ) { + if ( $slug === false ) { return $addons; } + if ( ! isset( $addons[$slug] ) ) { + return false; + } + return $addons[$slug]; } @@ -70,24 +92,35 @@ function superpwa_addons_interface_render() { return; } - // Add-on activation notice + // Add-on activation todo if ( isset( $_GET['activated'] ) && isset( $_GET['addon'] ) ) { // Add-on activation action. Functions defined in the add-on file are loaded by now. do_action( 'superpwa_addon_activated_' . $_GET['addon'] ); - - // Add settings saved message with the class of "updated" - add_settings_error( 'superpwa_settings_group', 'superpwa_addon_activated_message', __( 'Add-On activated.', 'super-progressive-web-apps' ), 'updated' ); - // Show Settings Saved Message - settings_errors( 'superpwa_settings_group' ); + // Get add-on info + $addon = superpwa_get_addons( $_GET['addon'] ); + + // Add UTM Tracking to admin_link_text if its not an admin page. + if ( $addon['admin_link_target'] === 'external' ) { + $addon['admin_link'] .= '?utm_source=superpwa-plugin&utm_medium=addon-activation-notice'; + } + + // Set link target attribute so that external links open in a new tab. + $link_target = ( $addon['admin_link_target'] === 'external' ) ? 'target="_blank"' : ''; + + if ( $addon !== false ) { + + // Add-on activation notice + echo '' . sprintf( __( 'Add-On activated: %s. %s', 'super-progressive-web-apps' ), $addon['name'], $addon['admin_link'], $link_target, $addon['admin_link_text'] ) . '
+
12 characters or less.', 'super-progressive-web-apps'); ?>
@@ -79,7 +79,7 @@ function superpwa_description_cb() { -+
@@ -104,7 +104,7 @@ function superpwa_app_icon_cb() { Choose Icon -
+
PNG image exactly 192x192
in size.', 'super-progressive-web-apps'); ?>
+
PNG image exactly 512x512
in size.', 'super-progressive-web-apps'); ?>
+
@@ -167,7 +167,7 @@ function superpwa_theme_color_cb() { -
+
Background Color.', 'super-progressive-web-apps'); ?>
@@ -197,7 +197,7 @@ function superpwa_start_url_cb() { )); ?> -+
%s', 'super-progressive-web-apps' ), superpwa_get_start_url() ); ?>
@@ -211,7 +211,7 @@ function superpwa_start_url_cb() { -+
@@ -244,7 +244,7 @@ function superpwa_offline_page_cb() { )); ?> -
+
%s', 'super-progressive-web-apps' ), get_permalink($settings['offline_page']) ? get_permalink( $settings['offline_page'] ) : get_bloginfo( 'wpurl' ) ); ?>
@@ -276,7 +276,7 @@ function superpwa_orientation_cb() { -+
Follow Device Orientation your app will rotate as the device is rotated.', 'super-progressive-web-apps' ); ?>
@@ -286,16 +286,23 @@ function superpwa_orientation_cb() { /** * Manifest Status * - * @since 1.0 + * @since 1.2 + * @since 1.8 Attempt to generate manifest again if the manifest doesn't exist. */ function superpwa_manifest_status_cb() { - - if ( superpwa_get_contents( superpwa_manifest( 'abs' ) ) ) { + + /** + * Check to see if the manifest exists, If not attempts to generate a new one. + * + * Users who had permissions issue in the beginning will check the status after changing file system permissions. + * At this point we try to generate the manifest and service worker to see if its possible with the new permissions. + */ + if ( superpwa_get_contents( superpwa_manifest( 'abs' ) ) || superpwa_generate_manifest() ) { - printf( '' . __( 'Manifest generated successfully. You can see it here →.', 'super-progressive-web-apps' ) . '
', superpwa_manifest( 'src' ) ); + printf( '' . __( 'Manifest generated successfully. You can see it here →', 'super-progressive-web-apps' ) . '
', superpwa_manifest( 'src' ) ); } else { - echo '' . __('Manifest generation failed. Check if WordPress can write to your root folder (the same folder with wp-config.php).', 'super-progressive-web-apps') . '
'; + printf( '' . __( 'Manifest generation failed. Check if WordPress can write to your root folder (the same folder with wp-config.php). Read more →', 'super-progressive-web-apps' ) . '
', 'https://superpwa.com/doc/fixing-manifest-service-worker-generation-failed-error/?utm_source=superpwa-plugin&utm_medium=settings-status-no-manifest' ); } } @@ -303,15 +310,17 @@ function superpwa_manifest_status_cb() { * Service Worker Status * * @since 1.2 + * @since 1.8 Attempt to generate service worker again if it doesn't exist. */ function superpwa_sw_status_cb() { - if ( superpwa_get_contents( superpwa_sw( 'abs' ) ) ) { + // See superpwa_manifest_status_cb() for documentation. + if ( superpwa_get_contents( superpwa_sw( 'abs' ) ) || superpwa_generate_sw() ) { printf( '' . __( 'Service worker generated successfully.', 'super-progressive-web-apps' ) . '
' ); } else { - echo '' . __('Service worker generation failed. Check if WordPress can write to your root folder (the same folder with wp-config.php).', 'super-progressive-web-apps') . '
'; + printf( '' . __( 'Service worker generation failed. Check if WordPress can write to your root folder (the same folder with wp-config.php). Read more →', 'super-progressive-web-apps' ) . '
', 'https://superpwa.com/doc/fixing-manifest-service-worker-generation-failed-error/?utm_source=superpwa-plugin&utm_medium=settings-status-no-sw' ); } } @@ -352,18 +361,6 @@ function superpwa_admin_interface_render() { // Show Settings Saved Message settings_errors( 'superpwa_settings_group' ); - } - - // Display the notice to use SuperPWA manifest as OneSignal custom manifest. - if ( superpwa_onesignal_manifest_notice_check() ) { - - echo '' .
- sprintf(
- __( 'To integrate with OneSignal: Enable Use my own manifest.json and set %s
as Custom manifest.json URL in OneSignal Configuration > Advanced Settings →', 'super-progressive-web-apps' ),
- superpwa_manifest( 'src' ),
- admin_url( 'admin.php?page=onesignal-push#configuration' )
- ) .
- '
' . sprintf( __( 'Thank you for installing Super Progressive Web Apps! '. $superpwa_is_ready .'Customize your app →', 'super-progressive-web-apps' ), admin_url( 'options-general.php?page=superpwa' ) ) . '
' . sprintf( __( 'Thank you for installing Super Progressive Web Apps! '. $superpwa_is_ready .'Customize your app →', 'super-progressive-web-apps' ), admin_url( 'admin.php?page=superpwa' ) ) . '
' . sprintf( __( 'SuperPWA: Successfully updated to version %s. Thank you! Discover new features and read the story →', 'super-progressive-web-apps' ), SUPERPWA_VERSION, 'https://superpwa.com/category/release-notes/latest/?utm_source=superpwa-plugin&utm_medium=update-success-notice' ) . '
' . sprintf( __( 'Thank you for installing Super Progressive Web Apps! '. $superpwa_is_ready .'Customize your app →
Note: manifest and service worker for the individual websites will be generated on the first visit to the respective WordPress admin.', 'super-progressive-web-apps' ), admin_url( 'options-general.php?page=superpwa' ) ) . '
' . sprintf( __( 'Thank you for installing Super Progressive Web Apps! '. $superpwa_is_ready .'Customize your app →
Note: manifest and service worker for the individual websites will be generated on the first visit to the respective WordPress admin.', 'super-progressive-web-apps' ), admin_url( 'admin.php?page=superpwa' ) ) . '
' . sprintf( __( 'SuperPWA: Successfully updated to version %s. Thank you! Discover new features and read the story →', 'super-progressive-web-apps' ), SUPERPWA_VERSION, 'https://superpwa.com/category/release-notes/latest/?utm_source=superpwa-plugin&utm_medium=update-success-notice-mu' ) . '
Start "
+"Page
URL in your manifest. This "
+"will help you identify visitors coming specifically from your app. Read more about UTM Tracking."
+msgstr ""
+
+#: addons/utm-tracking.php:264
+msgid ""
+"Campaign Source is mandatory and defaults to superpwa
. The "
+"remaining fields are optional."
+msgstr ""
+
+#: addons/utm-tracking.php:362 admin/admin-ui-render-settings.php:360
+msgid "Settings saved."
+msgstr ""
+
+#: addons/utm-tracking.php:371
+msgid "UTM Tracking for"
+msgstr ""
+
+#: addons/utm-tracking.php:382 admin/admin-ui-render-settings.php:383
+msgid "Save Settings"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:50
+msgid ""
+"Track visits from your app by adding UTM tracking parameters to the Start "
+"Page URL."
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:55
+msgid "Customize Settings →"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:60
+msgid "Apple Touch Icons"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:61
+msgid ""
+"Set the Application Icon and Splash Screen Icon as Apple Touch Icons for "
+"compatibility with iOS devices."
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:66
+msgid "More Details →"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:115
+msgid "Add-On activated: %s. %s"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:123
+msgid "Add-On deactivated"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:135
+msgid "Add-Ons for"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:137
+msgid "Add-Ons extend the functionality of SuperPWA."
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:177 admin/admin-ui-render-addons.php:349
+msgid "Deactivate"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:182
+msgid "More information about %s"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:182
+msgid "More Details"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:197
+msgid ""
+"Add-On active. %s"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:200
+msgid ""
+"Compatible with "
+"your version of SuperPWA"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:203
+msgid ""
+"Please upgrade "
+"to the latest version of SuperPWA"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:217
+msgid "SuperPWA Newsletter"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:221
+msgid ""
+"Learn more about Progressive Web Appsroot
password before we share your email with "
+"anyone else."
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:345
+msgid "Activate"
+msgstr ""
+
+#: admin/admin-ui-render-addons.php:354
+msgid "Install"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:60
+msgid ""
+"Used when there is insufficient space to display the full name of the "
+"application. 12
characters or less."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:83
+msgid "A brief description of what your app is about."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:108
+msgid ""
+"This will be the icon of your app when installed on the phone. Must be a "
+"PNG
image exactly 192x192
in size."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:131
+msgid ""
+"This icon will be displayed on the splash screen of your app on supported "
+"devices. Must be a PNG
image exactly 512x512
in "
+"size."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:151
+msgid "Background color of the splash screen."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:171
+msgid ""
+"Theme color is used on supported devices to tint the UI elements of the "
+"browser and app switcher. When in doubt, use the same color as "
+"Background Color
."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:194
+msgid "— Homepage —"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:201
+msgid ""
+"Specify the page to load when the application is launched from a device. "
+"Current start page is %s
"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:209
+msgid "Use AMP version of the start page."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:215
+msgid ""
+"Do not check this if your start page is the homepage, the blog index, or the "
+"archives page. AMP for WordPress does not create AMP versions for these "
+"pages."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:241
+msgid "— Default —"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:248
+msgid ""
+"Offline page is displayed when the device is offline and the requested page "
+"is not already cached. Current offline page is %s
"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:268
+msgid "Follow Device Orientation"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:271
+msgid "Portrait"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:274
+msgid "Landscape"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:280
+msgid ""
+"Set the orientation of your app on devices. When set to Follow Device "
+"Orientation
your app will rotate as the device is rotated."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:302
+msgid ""
+"Manifest generated successfully. You can see it here →"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:305
+msgid ""
+"Manifest generation failed. Check if WordPress can write to your root folder "
+"(the same folder with wp-config.php). Read "
+"more →"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:320
+msgid "Service worker generated successfully."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:323
+msgid ""
+"Service worker generation failed. Check if WordPress can write to your root "
+"folder (the same folder with wp-config.php). Read more →"
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:336
+msgid "Your website is served over HTTPS."
+msgstr ""
+
+#: admin/admin-ui-render-settings.php:339
+msgid ""
+"Progressive Web Apps require that your website is served over HTTPS. Please "
+"contact your host to add a SSL certificate to your domain."
+msgstr ""
+
+#. #-#-#-#-# super-progressive-web-apps.pot (Super Progressive Web Apps 1.8) #-#-#-#-#
+#. Author of the plugin/theme
+#: admin/admin-ui-setup.php:28
+msgid "SuperPWA"
+msgstr ""
+
+#: admin/admin-ui-setup.php:31 admin/basic-setup.php:279
+msgid "Settings"
+msgstr ""
+
+#: admin/admin-ui-setup.php:34
+msgid "Add-Ons"
+msgstr ""
+
+#: admin/admin-ui-setup.php:63
+msgid "Application Name"
+msgstr ""
+
+#: admin/admin-ui-setup.php:72
+msgid "Application Short Name"
+msgstr ""
+
+#: admin/admin-ui-setup.php:81
+msgid "Description"
+msgstr ""
+
+#: admin/admin-ui-setup.php:90
+msgid "Application Icon"
+msgstr ""
+
+#: admin/admin-ui-setup.php:99
+msgid "Splash Screen Icon"
+msgstr ""
+
+#: admin/admin-ui-setup.php:108
+msgid "Background Color"
+msgstr ""
+
+#: admin/admin-ui-setup.php:117
+msgid "Theme Color"
+msgstr ""
+
+#: admin/admin-ui-setup.php:126
+msgid "Start Page"
+msgstr ""
+
+#: admin/admin-ui-setup.php:135
+msgid "Offline Page"
+msgstr ""
+
+#: admin/admin-ui-setup.php:144
+msgid "Orientation"
+msgstr ""
+
+#: admin/admin-ui-setup.php:153
+msgid "Status"
+msgstr ""
+
+#: admin/admin-ui-setup.php:161
+msgid "Manifest"
+msgstr ""
+
+#: admin/admin-ui-setup.php:170
+msgid "Service Worker"
+msgstr ""
+
+#: admin/admin-ui-setup.php:179
+msgid "HTTPS"
+msgstr ""
+
+#: admin/admin-ui-setup.php:305
+msgid ""
+"If you like SuperPWA, please make a "
+"donation or leave a ★★"
+"★★★ rating to support continued development. Thanks a "
+"bunch!"
+msgstr ""
+
+#: admin/basic-setup.php:82 admin/basic-setup.php:116
+msgid ""
+"SuperPWA: Successfully updated to version %s. Thank you! Discover new features and read the story →"
+""
+msgstr ""
+
+#: admin/basic-setup.php:295
+msgid "Demo"
+msgstr ""
+
+#. Plugin URI of the plugin/theme
+msgid "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=plugin-uri"
+msgstr ""
+
+#. Description of the plugin/theme
+msgid "Convert your WordPress website into a Progressive Web App"
+msgstr ""
+
+#. Author URI of the plugin/theme
+msgid "https://superpwa.com/?utm_source=superpwa-plugin&utm_medium=author-uri"
+msgstr ""
diff --git a/loader.php b/loader.php
index c2d3ee1..0f4e539 100644
--- a/loader.php
+++ b/loader.php
@@ -10,12 +10,12 @@
// Load admin
require_once( SUPERPWA_PATH_ABS . 'admin/basic-setup.php' );
-require_once( SUPERPWA_PATH_ABS . 'admin/admin-setup.php' );
+require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-setup.php' );
require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-settings.php' );
require_once( SUPERPWA_PATH_ABS . 'admin/admin-ui-render-addons.php' );
// 3rd party compatibility
-require_once( SUPERPWA_PATH_ABS . '3rd-party/onesignal.php' );
+if ( ! is_multisite() ) require_once( SUPERPWA_PATH_ABS . '3rd-party/onesignal.php' );
// Load functions
require_once( SUPERPWA_PATH_ABS . 'functions/common.php' );
@@ -27,6 +27,5 @@
require_once( SUPERPWA_PATH_ABS . 'public/sw.php' );
// Load bundled add-ons
-if ( superpwa_addons_status( 'utm_tracking' ) == 'active' ) {
- require_once( SUPERPWA_PATH_ABS . 'addons/utm-tracking.php' );
-}
\ No newline at end of file
+if ( superpwa_addons_status( 'utm_tracking' ) == 'active' ) require_once( SUPERPWA_PATH_ABS . 'addons/utm-tracking.php' );
+if ( superpwa_addons_status( 'apple_touch_icons' ) == 'active' ) require_once( SUPERPWA_PATH_ABS . 'addons/apple-touch-icons.php' );
\ No newline at end of file
diff --git a/public/js/register-sw.js b/public/js/register-sw.js
index dd7fa27..1939e7c 100644
--- a/public/js/register-sw.js
+++ b/public/js/register-sw.js
@@ -3,5 +3,6 @@ if ('serviceWorker' in navigator) {
navigator.serviceWorker.register(superpwa_sw.url)
.then(function(registration) { console.log('SuperPWA service worker ready'); registration.update(); })
.catch(function(error) { console.log('Registration failed with ' + error); });
+ window.addEventListener('beforeinstallprompt', (e) => { e.prompt(); });
});
}
\ No newline at end of file
diff --git a/public/manifest.php b/public/manifest.php
index a6361f6..11d09c0 100644
--- a/public/manifest.php
+++ b/public/manifest.php
@@ -60,11 +60,12 @@ function superpwa_manifest( $arg = 'src' ) {
*
* @return (boolean) true on success, false on failure.
*
- * @since 1.0
- * @since 1.3 Added support for 512x512 icon.
- * @since 1.4 Added orientation and scope.
- * @since 1.5 Added gcm_sender_id
- * @since 1.6 Added description
+ * @since 1.0
+ * @since 1.3 Added support for 512x512 icon.
+ * @since 1.4 Added orientation and scope.
+ * @since 1.5 Added gcm_sender_id
+ * @since 1.6 Added description
+ * @since 1.8 Removed gcm_sender_id and introduced filter superpwa_manifest. gcm_sender_id is added in /3rd-party/onesignal.php
*/
function superpwa_generate_manifest() {
@@ -75,7 +76,7 @@ function superpwa_generate_manifest() {
$manifest['name'] = $settings['app_name'];
$manifest['short_name'] = $settings['app_short_name'];
- // description
+ // Description
if ( isset( $settings['description'] ) && ! empty( $settings['description'] ) ) {
$manifest['description'] = $settings['description'];
}
@@ -88,14 +89,13 @@ function superpwa_generate_manifest() {
$manifest['start_url'] = superpwa_get_start_url( true );
$manifest['scope'] = superpwa_get_scope();
- // gcm_sender_id
- if ( superpwa_onesignal_get_gcm_sender_id() !== false ) {
- $manifest['gcm_sender_id'] = superpwa_onesignal_get_gcm_sender_id();
- }
+ // Filter the manifest.
+ $manifest = apply_filters( 'superpwa_manifest', $manifest );
- // Delete manifest if it exists
+ // Delete manifest if it exists.
superpwa_delete_manifest();
+ // Write the manfiest to disk.
if ( ! superpwa_put_contents( superpwa_manifest( 'abs' ), json_encode( $manifest ) ) ) {
return false;
}
@@ -107,14 +107,22 @@ function superpwa_generate_manifest() {
* Add manifest to header (wp_head)
*
* @since 1.0
+ * @since 1.8 Introduced filter superpwa_wp_head_tags
*/
function superpwa_add_manifest_to_wp_head() {
// Get Settings
$settings = superpwa_get_settings();
- echo '' . PHP_EOL . '' . PHP_EOL;
- echo '' . PHP_EOL;
+ $tags = '' . PHP_EOL;
+ $tags .= '' . PHP_EOL;
+ $tags .= '' . PHP_EOL;
+
+ $tags = apply_filters( 'superpwa_wp_head_tags', $tags );
+
+ $tags .= '' . PHP_EOL . PHP_EOL;
+
+ echo $tags;
}
add_action( 'wp_head', 'superpwa_add_manifest_to_wp_head', 0 );
diff --git a/public/sw.php b/public/sw.php
index e4f5dfb..99804b1 100644
--- a/public/sw.php
+++ b/public/sw.php
@@ -28,10 +28,11 @@
*
* @since 1.6
* @since 1.7 src to service worker is made relative to accomodate for domain mapped multisites.
+ * @since 1.8 Added filter superpwa_sw_filename.
*/
function superpwa_sw( $arg = 'src' ) {
- $sw_filename = 'superpwa-sw' . superpwa_multisite_filename_postfix() . '.js';
+ $sw_filename = apply_filters( 'superpwa_sw_filename', 'superpwa-sw' . superpwa_multisite_filename_postfix() . '.js' );
switch( $arg ) {
@@ -105,7 +106,7 @@ function superpwa_sw_template() {
const offlinePage = '';
const fallbackImage = '';
const filesToCache = [startPage, offlinePage, fallbackImage];
-const neverCacheUrls = [/\/wp-admin/,/\/wp-login/,/preview=true/];
+const neverCacheUrls = [];
// Install
self.addEventListener('install', function(e) {
diff --git a/readme.txt b/readme.txt
index 6b0a50e..3b90311 100644
--- a/readme.txt
+++ b/readme.txt
@@ -3,7 +3,7 @@ Contributors: arunbasillal, josevarghese, superpwa
Donate link: http://millionclues.com/donate/
Tags: pwa, progressive web apps, manifest, web manifest, android app, chrome app, add to homescreen, mobile web
Requires at least: 3.6.0
-Tested up to: 4.9.5
+Tested up to: 4.9.6
Requires PHP: 5.3
Stable tag: trunk
License: GPLv2 or later
@@ -25,6 +25,14 @@ SuperPWA is easy to configure, it takes less than a minute to set-up your Progre
And the best part? If you ever get stuck, we are here to watch your back! [Open a support](https://wordpress.org/support/plugin/super-progressive-web-apps) ticket if you have a question or need a feature. We are super excited to hear your feedback and we want to genuinely help you build the best Progressive Web App for your WordPress website!
+#### Quick Demo?
+
+* Open up [SuperPWA.com](https://superpwa.com/?utm_source=wordpress.org&utm_medium=description-demo) in a supported device.
+* Add the website to your home screen either from the Add to Home Screen prompt (Chrome for Android) or from the browser menu.
+* Open the app from your home screen and you will see the splash screen.
+* Turn off your data and wifi to go offline and open up the app. You will still be able to see the app and browse the pages you have already visited.
+* Browse to a page that you haven't visited before. The offline page will be displayed.
+
#### Thank You PWA Enthusiasts!
We are humbled by the feedback from the community. Thanks to everyone who believed in us and tried our plugin. Your feedback has been invaluable and we have learned a lot from your experience. Thank you for your love and support and we hope to return the love by striving to bring you the best ever Progressive Web Apps plugin for WordPress!
@@ -40,7 +48,7 @@ Here are the current features of Super Progressive Web Apps:
* Aggressive caching of pages using CacheStorage API.
* Pages once cached are served even if the user is offline.
* Set custom offline page: Select the page you want the user to see when a page that isn't in the cache is accessed and the user is offline.
-* New in version 1.2: Support for theme-color.
+* New in version 1.2: Support for theme-color meta property. Change the color of browser address bar of Chrome, Firefox OS and Opera to match your website colors.
* New in version 1.2: Now you can edit the Application Name and Application Short name.
* New in version 1.2: Set the start page of your PWA.
* New in version 1.2: Set Accelerated Mobile Pages (AMP) version of the start page. Supported plugins: AMP for WordPress, AMP for WP, Better AMP, AMP Supremacy, WP AMP.
@@ -52,6 +60,8 @@ Here are the current features of Super Progressive Web Apps:
* New in version 1.5: OneSignal integration for Push notifications.
* New in version 1.6: WordPress Multisite Network compatibility.
* 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.
+* New in version 1.8: Compatibility issues with OneSignal are now resolved!
+* New in version 1.8: New Add-On: [Apple Touch Icons](https://superpwa.com/addons/apple-touch-icons/?utm_source=wordpress.org&utm_medium=description) that sets your app icons as Apple Touch Icons.
**Upcoming features:**
@@ -107,7 +117,7 @@ Uh, oh. Your PWA did not work as expected? You do not see the "Add to Home Scree
* Make sure your website has a SSL certificate installed. i.e. your website should be https instead of http (as in https://your-domain.com).
* Make sure you are using a supported device and a supported browser. Refer to the "Device and Browser Support For PWA" list above.
-* Make sure your icon is a PNG and 192px X 192 px in size.
+* Make sure your Application Icon and Splash Screen Icon's are of PNG format and 192px X 192px and 512px X 512px in size respectively.
* Clear the browser cache and try again. In Chrome for Android, go to Settings > Privacy > "Clear browsing data".
* If the application icon does not update after first install, delete the PWA from your phone, clear browser cache and install again. (We are working on making it better.)
* Create a [new support ticket](https://wordpress.org/support/plugin/super-progressive-web-apps) and share a link to your website. We will take a look and figure it out for you.
@@ -138,7 +148,27 @@ If you have any questions, please ask it on the [support forum](https://wordpres
= Will Progressive Web Apps work on iOS devices? =
-PWA's require browsers with support for service workers and for iOS devices, support is available in Safari Technology Preview 48, macOS High Sierra 10.13.4 and iOS 11.3 beta seed 2. Since none of these are production releases, the general public will not be able to install your app on their mobile phones and smart devices. We will hopefully see full support by mid 2018.
+Starting with Safari for iOS 11.3, Apple devices offer partial support for PWA's. However, there is no native Add To Home Screen prompt just yet. You can add your app by tapping "Add to Home Screen" button in the share menu of the browser ( look for the square icon with an up arrow in the foreground ).
+
+Just like you, we are eagerly awaiting the upcoming releases and we hope to see better compatibility in the coming months.
+
+= How To Customize Splash Screen =
+
+You can easily change the icon and the background color in SuperPWA > Settings.
+
+Further customizations are not available right now, not because of any limitation of SuperPWA, but because they are not available in the PWA technology. When more options come up in the future, we will add them to SuperPWA then.
+
+= How To Track Visits Originating From Your Progressive Web App =
+
+You can track visits from your PWA in your analytics software (for e.g. Google Analytics) using the UTM Tracking add-on of SuperPWA. Go to SuperPWA > Add-Ons and activate UTM Tracking. Then in SuperPWA > UTM Tracking, you can set the UTM parameters as needed. Please [refer the documentation](https://superpwa.com/addons/utm-tracking/?utm_source=wordpress.org&utm_medium=description-faq) for further information.
+
+= GDPR Compliance =
+
+SuperPWA does not collect or store user data, nor does it set cookies or store tracking data. Content visited by users from your PWA is stored in the user's own device, in the cache of the browser. This is very similar to how modern browsers caches content offline for faster browsing.
+
+With the UTM Tracking Add-On, you will be able to differentiate the visits originating from your PWA in your analytics software. You may have to include this in your privacy policy. Please note that SuperPWA does not track the visits, we just help you add the UTM parameters to the URL of the Start Page of your app so that third party analytics tools can differentiate the visits.
+
+Feel free to get in touch if you have any questions.
== Screenshots ==
@@ -146,12 +176,23 @@ PWA's require browsers with support for service workers and for iOS devices, sup
== Changelog ==
+= 1.8 =
+* Date: [31.May.2018](https://superpwa.com/push-notifications-are-here-again/?utm_source=wordpress.org&utm_medium=changelog)
+* Tested with WordPress 4.9.6.
+* New Add-On: Apple Touch Icons. Set the Application Icon and Splash Screen Icon as Apple Touch Icons for compatibility with iOS devices.
+* Enhancement: Added support for Add to Home Screen prompt for Chrome 68 and beyond.
+* Enhancement: Better add-on activation and deactivation by hooking onto admin_post action.
+* Enhancement: Attempt to generate manifest and service worker automatically on visiting the SuperPWA settings page after adjusting root folder permissions.
+* Enhancement: Generated a .pot file with all strings for translation. You can also translate SuperPWA to your language by visiting [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/super-progressive-web-apps)
+* Bug Fix: Compatibility issues with OneSignal are resolved for single installs.
+* Bug Fix: Updated plugin action links and admin notices with the correct admin menu link.
+
= 1.7.1 =
* Date: 05.May.2018
* Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
= 1.7 =
-* Date: 03.May.2018
+* Date: [03.May.2018](https://superpwa.com/introducing-add-ons-for-superpwa/?utm_source=wordpress.org&utm_medium=changelog)
* 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.
@@ -161,7 +202,7 @@ PWA's require browsers with support for service workers and for iOS devices, sup
* Bug Fix: Incorrect manifest and service worker URLs when WordPress is installed in a folder.
= 1.6 =
-* Date: 23.April.2018
+* Date: [23.April.2018](https://superpwa.com/1-6-released-multisite-network-support/?utm_source=wordpress.org&utm_medium=changelog)
* 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.
* New Feature: Added description to the manifest. You can now include a brief description of what your app is about.
* Enhancement: Moved manifest to the very top of wp_head for better compatibility with some browsers.
@@ -178,7 +219,7 @@ PWA's require browsers with support for service workers and for iOS devices, sup
* Enhancement: Added UI notice when using AMP for WordPress to warn user not to use the AMP version of start page if the start page is the homepage, the blog index, or the archives page.
= 1.4 =
-* Date: 21.February.2018
+* Date: [21.February.2018](https://wordpress.org/support/topic/you-asked-and-we-listened-superpwa-1-4-ships-with-two-user-feature-requests/)
* New Feature: Added UI for default orientation of your PWA. Orientation can now be set as "any", "portrait" or "landscape". [Feature request from @doofustoo](https://wordpress.org/support/topic/almost-perfect-335/).
* New Feature: Added UI for theme_color property in manifest. [Feature request from @krunalsm](https://wordpress.org/support/topic/diffrent-theme_color-and-background_color/).
* Enhancement: Improved compatibility with all major Accelerated Mobile Pages (AMP) plugins.
@@ -225,6 +266,16 @@ PWA's require browsers with support for service workers and for iOS devices, sup
== Upgrade Notice ==
+= 1.8 =
+* Tested with WordPress 4.9.6.
+* New Add-On: Apple Touch Icons. Set the Application Icon and Splash Screen Icon as Apple Touch Icons for compatibility with iOS devices.
+* Enhancement: Added support for Add to Home Screen prompt for Chrome 68 and beyond.
+* Enhancement: Better add-on activation and deactivation by hooking onto admin_post action.
+* Enhancement: Attempt to generate manifest and service worker automatically on visiting the SuperPWA settings page after adjusting root folder permissions.
+* Enhancement: Generated a .pot file with all strings for translation. You can also translate SuperPWA to your language by visiting translate.wordpress.org/projects/wp-plugins/super-progressive-web-apps
+* Bug Fix: Compatibility issues with OneSignal are resolved for single installs.
+* Bug Fix: Updated plugin action links and admin notices with the correct admin menu link.
+
= 1.7.1 =
* Bug Fix: Fix fatal error in PHP versions prior to PHP 5.5. "Cant use function return value in write context".
diff --git a/superpwa.php b/superpwa.php
index af33306..5d9cb5e 100644
--- a/superpwa.php
+++ b/superpwa.php
@@ -1,12 +1,12 @@