Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add offline browsing option in Reading settings #365

Merged
merged 8 commits into from
Dec 15, 2020

Conversation

westonruter
Copy link
Collaborator

@westonruter westonruter commented Dec 12, 2020

Fixes #344.

This adds a new Offline browsing toggle to the Reading Settings screen:

image

It is disabled by default. When disabled, by default only the offline page and server error page templates will be served to the user (or any other custom rules that the user may have registered such as via the obsolete Basic Site Caching plugin). When enabled, then the new default caching strategies are employed which were introduced in #338.

When someone updates to this version of a plugin, an admin pointer is displayed displayed to let them know about this feature:

image

@westonruter westonruter added this to the 0.6 milestone Dec 12, 2020
@codecov-io
Copy link

codecov-io commented Dec 12, 2020

Codecov Report

Merging #365 (2f30d84) into develop (e6d8d54) will decrease coverage by 1.13%.
The diff coverage is 6.09%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #365      +/-   ##
=============================================
- Coverage      25.54%   24.40%   -1.14%     
- Complexity       362      364       +2     
=============================================
  Files             54       55       +1     
  Lines           1785     1856      +71     
=============================================
- Hits             456      453       -3     
- Misses          1329     1403      +74     
Flag Coverage Δ Complexity Δ
php 24.40% <6.09%> (-1.14%) 0.00 <0.00> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
pwa.php 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
wp-admin/options-reading-offline-browsing.php 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...wp-service-worker-navigation-routing-component.php 1.48% <0.00%> (-0.03%) 34.00 <0.00> (+1.00) ⬇️
wp-includes/class-wp-service-workers.php 76.92% <45.45%> (-10.84%) 11.00 <0.00> (+1.00) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e6d8d54...2f30d84. Read the comment docs.


?>
<script type="text/javascript">
jQuery( function( $ ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the jQuery dependency necessary or could this be written in vanilla JS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could yes, but the wp-pointer JS API is itself based on jQuery, so that's why I'm using it here.

Co-authored-by: Derek Herman <derek.herman@xwp.co>
@google-cla

This comment has been minimized.

…/offline-browsing-option

* 'develop' of github.com:GoogleChromeLabs/pwa-wp:
  Indicate function to be used in place of deprecated one
  Fix subpackage phpdoc tags
  Add offline template for twentytwentyone
  Exclude deprecated functions from code coverage
  Make all classes final since not intended to be extended
  Deprecate wp_service_worker_json_encode() in favor of wp_json_encode()
@derekherman
Copy link
Contributor

@googlebot I consent.

Copy link
Collaborator

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

target.pointer( options ).pointer( 'open' );
} );
</script>
<?php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A shame we can't use this code from WP core and have to copy it here. But okay 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide means of opting-in to offline browsing
4 participants