SayHelloGmbH / progressive-wordpress

This Plugin adds progressive features to your WordPress site and converts it to a progressive web app
58 stars 14 forks source link

Progressive WordPress

Description

It has never been easier to add progressive web app features (PWA) to your WordPress website. It even supports Accelerate Mobile Pages (AMP) and is compatible with OneSignal!

Add to homescreen

Provide an integrated user experience!

Progressive WordPress makes it easy to encourage users to add your website to their homescreen. But that's not all. It also allows you to control the display behaviour of your website so it will be shown without any browser elements. Just like a native app.

Offline usage

Make your website reliable. Even on flaky internet connections!

No connection? No problem. Progressive WordPress pre-caches all critical assets of your website, as well as all visited resources. So if there's no internet connection it will serve the resources from the local storage. No more error downasaur!

Push notifications

Send push notifications from the WP Admin interface!

Keep your users engaged by sending push notifications!

You just published new content and you want to let everyone know? Why not send a push notification? Progressive WordPress has an integrated connection to Firebase that lets you manage registered devices and send push notifications to all or selected devices!

Support for OneSignal

Since Version 2.1.0 Progressive WordPress fully supports OneSignal. It detects if the OneSignal WordPress Plugin is active and uses their push messaging functionalities instead.

⚡ AMP ready

Progressive WordPress is the first PWA-Plugin for WordPress that also supports Accelerated Mobile Pages!
It precaches required resources, it adds special AMP caching strategies and it registers the ServiceWorker and the Web App Manifest also on AMP Pages.
Progressive WordPress currently supports AMP for WordPress and AMP for WP – Accelerated Mobile Pages.

Developers

Progressive WordPress offers a lot of possibilities for developers the extend it the way you need it.

ServiceWorker

Add pre-cache resource:

function myplugin_offline_precache( $caches ) {
    $caches[] = 'https://myurl.com';
    return $caches;
}
add_filter( 'pwp_offline_precache', 'myplugin_offline_precache' );

Manifest

Change the site Icon
By default Progressive WordPress takes the WordPress Favicon as the Site Icon. But you can change that by using this filter:

function myplugin_manifest_icon( $attachment_is ) {
    return 10; //should be the Post ID of an attachment.
}
add_filter( 'pwp_manifest_icon', 'myplugin_manifest_icon' );

Add content to the manifest:

function myplugin_manifest_values( $values ) {
    $values['new'] = 'New';
    return $values; //needs to be valid an array (will be json_endoded)
}
add_filter( 'web_app_manifest', 'myplugin_manifest_values' );

Push notifications

If you are using OneSignal please visit https://documentation.onesignal.com.

customoize Button
If you don't want to use the built in Button, you can create your own from a shortcode or a php function:

// Shortcode
[pwp_notification_button size="1rem" class="your-class"]

// Function
$atts = [
    'class' => 'notification-button--fixedfooter',
    'style' => "background-color: #ff0000; color: #00ff00; font-size: 35px",
];
pwp_get_notification_button( $atts ); // returns the html template.

Filter: pwp_notification_button_attributes

This filter adds custom attributes to the notification button:

function myplugin_notification_button_atttibutes( $attributes ) {
    $attributes['data-test'] = 'My value';
    return $attributes;
}
add_filter( 'pwp_notification_button_attributes', 'myplugin_notification_button_atttibutes' );

The key will be used as attribute key (will be sanitized sanitize_title()), the value will be used as attribute value (sanitized with esc_attr()).

Create your own button
You are also free to create your own button. The states are indicated as body classes:

You can then use the JS functions pwpRegisterPushDevice(); and pwpDeregisterPushDevice();.

⚡ AMP support

Progressive WordPress currently supports AMP for WordPress and AMP for WP – Accelerated Mobile Pages.
You can easily make your AMP Theme or Plugin comatible with the following hooks:

Filter: pwp_site_supports_amp

Should be set to true is the website supports AMP

add_filter( 'pwp_site_supports_amp', '__return_true' );

Filter: pwp_current_page_is_amp

Should be set to true is the website supports AMP

function myplugin_current_page_is_amp( $boolean ) {
    if ( this_site_is_an_amp_site() ) {
        $boolean = true;
    }
    return $boolean;
}
add_filter( 'pwp_current_page_is_amp', 'myplugin_current_page_is_amp' );

Filter: pwp_get_ampurl_from_url

Should return the input-URL or the AMP-Version of this URL if exists.

function myplugin_get_ampurl_from_url( $url ) {
    if ( this_url_amp_url() ) {
        $url = $url . 'amp/';
    }
    return $url;
}
add_filter( 'pwp_get_ampurl_from_url', 'myplugin_get_ampurl_from_url' );

You can find a working example here: https://github.com/SayHelloGmbH/progressive-wordpress/blob/master/3rdparty-support/amp.php

Your Theme or plugin should also support the amp_post_template_head and amp_post_template_footer actions.

Privacy

This plugin does not use any Cookies. Also it does not collect any personal information without the following

Push notification

If the user subscribes to push notifications, the following informations will be saved inside the WP database:

Also if you send push notifications, those will be passed to firebase cloud messaging and they will send it to the client.

Changelog

2.1.10

2.1.9

2.1.8

2.1.7

2.1.6

2.1.5

2.1.3

2.1.2

2.1.0

2.0.1

2.0.0

1.3.2

1.3.1

1.3.0

1.2.0

1.1.2

1.1.1

1.1.0

1.0.2

1.0.1

1.0.0

0.7.0

0.6.2

0.6.1

0.6.0

0.5.1

0.5.0

0.4.0

0.3.0

0.2.0

0.1.0

Contributors

License

Use this code freely, widely and for free. Provision of this code provides and implies no guarantee.

Please respect the GPL v3 licence, which is available via http://www.gnu.org/licenses/gpl-3.0.html