GithubHelp home page GithubHelp logo

sayhellogmbh / progressive-wordpress Goto Github PK

View Code? Open in Web Editor NEW
58.0 11.0 14.0 4.4 MB

This Plugin adds progressive features to your WordPress site and converts it to a progressive web app

CSS 8.67% JavaScript 9.69% PHP 43.43% SCSS 38.20%

progressive-wordpress's Introduction

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:

  • body.pwp-notification if push notifications are supported
  • body.pwp-notification.pwp-notification--on if the device is registered
  • body.pwp-notification.pwp-notification--loader if there is something loading

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:

  • Browser and Version
  • Operating System (and Version)
  • Device
  • Push Notification endpoint (a key that will be generated by the browser and the firebase server so push notifications can be sent)

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

  • Changed Text Domain from pwp to progressive-wp
  • added privacy information to the readme
  • short_name can now contain spaces
  • added WP Rest to caching strategies

2.1.9

  • Minor Bugfix (PHP Warning)

2.1.8

  • Fixed Push notifications

2.1.7

  • removed jQuery! It's now only pure JavaScript
  • conditional JS / CSS loading
  • small stability improvements for the Site Icon
  • httpsify start url

2.1.6

  • AMP register ServiceWorker Bugfix

2.1.5

  • Improvements for service worker registration
  • Add to homescreen prompt fix

2.1.3

  • New Filter to adjust the Site Icon: pwp_manifest_icon
  • Fix for ServiceWorker registration inside subfolder
  • Multisite fixes for OneSignal compatibility

2.1.2

  • Multisite fixes for OneSignal compatibility

2.1.0

2.0.1

  • New caching strategy "Network Only"
  • ServiceWorker minify
  • Precache fixes

2.0.0

  • Complete UI over-worked
  • Offline support for Google Analytics!
  • Settings renamed and rearranged
  • Manifest Icon is now the same as Site Icon
  • Added Workbox v3.4.1
  • Choose caching strategies for different request types
  • Future proof: Added support for the PWA feature plugin

1.3.2

  • Bugfix: Firebase Serverkey validation
  • Bugfix: upload images on settings page

1.3.1

  • messed up some SVN-deployment

1.3.0

  • added default settings on activate
  • Bugfix: Minifying JS threw an Uncaught SyntaxError

1.2.0

  • added default settings on activate
  • added UTM tracking for manifest starturl and push notification redirect url

1.1.2

  • required php Version is now 5.6

1.1.1

  • critical Bugfix: JavaScript error

1.1.0

  • Bugfix: better way to check if files have to be regenerated
  • Bugfix: PushPost not always registered
  • Improvement: new manifest icon sizes

1.0.2

  • Bugfix: CSS z-index for notification button

1.0.1

  • Bugfix: Pushpost labels
  • fixed spelling mistakes

1.0.0

  • Stable version 1.0.0
  • added multisite support
  • Pushpost: send push notifications right from the post edit screen
  • Added translation: de_DE
  • Added translation: de_CH
  • push button color input-type improvements
  • add JS vars as wp_add_inline_script

0.7.0

  • extended developer functionalities
  • added a latest push log
  • added a debug log
  • using WP_Filesystem API instead of php file_put_contents
  • Added "orientation" to manifest
  • Added colorpicker to settings
  • Fix: is_ssl() improvement

0.6.2

  • Bugfix: featured image could not be changed if push notifications are enabled

0.6.1

  • Bugfix: prohibit console error if sw not supported

0.6.0

  • Added offline content
  • select front page as offline Page
  • Improvement: better hex check for manifest colors

0.5.1

  • Bugfix: notification Button always visible

0.5.0

  • Added push notifications!
    • let the user manage their subscription
    • manage all registered deivces
    • send push notifications to all or specific devices
  • added ad status checks
  • force the browser to unregister all other serviceworkers
  • minor bugfixes and improvements

0.4.0

  • you can now change the manifest start_url
  • Bugfixes

0.3.0

  • changed offline indicator
  • added better instructions
  • codepattern improvements

0.2.0

  • added offline indicator
  • Grammatical changes by Mark Howells-Mead
  • "installable" is now optional
  • Manifest Icon has to be png and min. 144x144px.

0.1.0

  • Initial version from 2018

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

progressive-wordpress's People

Contributors

miina avatar nico-martin avatar westonruter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

progressive-wordpress's Issues

Push notifications broken?

Hi,

I can't get push notifications working. No button, no registered devices etc.

What am I missing?

Regards,
Y

Reload Data on App open

When you open the app it still shows old content untill an manual reload (native android behaviour).
Should be possible to reload after/before opening.

Adding parameter to start_url

Hi,

i tried to add parameters to the start_url like "/?ref=app" to know where the request comes from.
But it is not possible with your regexp restrictions in the function starturl_sanitize.

Is it really necessary to restrict this?

Thanks!

Not able to install the plugin with composer

There is no way to install the plugin via composer because there is no composer.json file.

Also the plugin does not seems to be updated on the wordpress.org website.

Thanks for the plugin it help a lot.

Push: de-/register

Push Manager im Frontend
Indicator ob man schon registriert ist
An-/Abmeldung
Button als Widget
Button als Menüpunkt
Button als Shortcode
Button als PHP Funktion

Push: send

Backend intervace über das Pushmessages gesendet werden können.

Manifest icon url generation not working properly when using an external media server

If you site is using a plugin like WP Offload Media and all the medias are store in a bucket S3 for example, the the URL generated for the icon in the manifest a not working properly.

I suggest using the default get_site_icon_url() function https://developer.wordpress.org/reference/functions/get_site_icon_url/ from wordpress to properly get the icons informations instead of generating the url of the different size yourself.

a2h banner on all devices

Find a solution to have mor ontrol over the add to homesreen banner. Also fo iOS and Desktop Browsers.

How to track users

I do not understand yet another thing about how to track users, not only with Google analytics, how to use other systems

PWA OneSignal error - scope not correct

Hi!

Just tried to use your PWP plugin, but it crashes OneSignal. Error says following:

The path of the provided scope ('/') is not under the max scope allowed ('/sdk_files/https://www.callofduty-infobase.de/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope. VM19237:37 [Service Worker Installation] Installing service worker failed SecurityError: Failed to register a ServiceWorker: The path of the provided scope ('/') is not under the max scope allowed ('/sdk_files/https://www.callofduty-infobase.de/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.

Should be fixed asap because it's not possible to send/receive push messages - even no new user can subscribe.

Does it support iOS

Hi there,

Managed to install for android but didn’t see it working for iOS?
Does it support. Appreciate ig

zipic based subscriptions

Is it possible to create buttons where users can decide to which topic they want to be notified? (i.e. based on a category,tag or a specific comment-thread)

Device could not be Register

I have to allow push notification. but some error throw. "Device could not be Register" what is the actual issue?

20191223_145727

HTTPS Problem

I have a website running on Cloudflare HTTPS but with the help of wordpress-https plugin to redirect all HTTP request to HTTPS but still, I am getting this error your plugin setting page.

Your site has to be served over https to use progressive web app features.

And on the about->status, it's showing a red cross mark on the HTTPS option but the website is already running on HTTPS.

screenshot_77

Status file

For debugging reasons a user should be able to create a status file he can send to get better support.
Should contain the status values, url, multisite, the settings and the active themes and plugins.

Service Worker Gone Rouge. Urgent

Hi all,

i am running plug in in my live site. However no matter what i do, changes i made on my website is not reflected in the user clients.

I tried deleting the plugin, reinstalling, changing to another PWA plugin, changing settings, everything in between.

Nothing changes.

I have a number of users already installed.. does it mean that they are now considered orphaned?

Anyone with any idea please let me know.

https://eorg.app.essentialsbymor.com/

Go-Back solution

On some devices if you open the PWA in standalone you won't have a "step-back" button any more.
Maybe we could use swipe left gesture?

Offline indicator

Warnhinweis so bald der Nutzer nicht mehr mit dem Internet verbunden ist

Do not cache wp-json requests

Requests to the WordPress API /wp-json should not be cached as they break gutenberg.
Hence the following addition to the pwp-serviceworker.js on line 2 should be made:
|| request.url.match(/wp-json/) { return }

error upload icon

Hello my friend, upload icon does not work

error:
admin.js?ver=1.2.0:429 Uncaught TypeError: Cannot read property 'url' of undefined
at e.Collection. (admin.js?ver=1.2.0:429)

if (attachment.type === 'image') {
preview = '<img src='' + attachment.sizes.thumbnail.url + '' />';
} else {
preview = '' + attachment.title + ' (' + attachment.mime + ')';
}

Not working on iOS

Hi!

Just tested PWP on iOS. Doesn't work as expected. If there are new blog entries, the app won't get them automatically. While this problem can be simply fixed on Android by pulling down the entire site to refresh, on iOS there is absolutely no chance to get new content.

You even cant change settings in PWP, iOS will not download the new manifest.

So PWP is actually not usable at this time because especially iOS users won't get and updates for the PWA.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.