Digital Sovereignty for everyone

Extending

Other plugins extend the manifest and the service worker through these hooks.

  • lh_web_application_manifest_json_filter filters the manifest array (LH Share Target adds share_target here). Do not change id: browsers identify an installed app by it.
  • lh_web_application_import_scripts_handle_filter (script handles) and lh_web_application_import_scripts_src_filter (URLs) choose the scripts the worker imports with importScripts(). LH Web Push Notifications and LH BuddyPress Live Content add their worker code this way.
  • lh_web_application_pass_variables_action prints variables into the worker before those imports, and lh_web_application_open_service_worker runs before anything is printed.
  • lh_web_application_precache_static_urls_filter filters the static URLs precached on install.
  • lh_web_application_static_max_age_days (default 180; 0 keeps files indefinitely) sets how long an unused static file stays cached, lh_web_application_images_max_entries (default 150) caps the images cache, and lh_web_application_pages_max_entries (default 300) caps the saved-pages cache. The start URL and the offline page are never dropped.
  • Imported worker scripts can listen for the periodicsync event with the tag update, which the main script registers to fire at most once a day where the browser supports it. Wrap the work in event.waitUntil(), or the browser may stop the worker before it finishes.
  • The worker turns on navigation preload, so page requests carry the Service-Worker-Navigation-Preload header. A worker script that adds its own fetch handler for navigations should use event.preloadResponse rather than fetching again.
  • Themes can style two body classes the main script sets. standalone is present when the site runs as an installed app. lh_web_application-navigating is set only in an installed app (standalone or fullscreen display mode, or an iOS home screen app), since a browser tab shows its own loading indicator. It is added when a link to another page here is tapped, a form is submitted or the Navigation API reports a navigation. It is removed when the load finishes or fails, when a page is restored from the back/forward cache, when only the anchor changes, or after 30 seconds. Use it for a loading indicator; the plugin draws nothing itself.
  • In an installed app on iPhone and iPad the plugin adds a floating Back button, #lh_web_application-back, in the bottom left corner. It shows only while the Navigation API says there is a page to go back to. It slides away (class lh_web_application-back_tucked) while the visitor scrolls down or types. The body gets lh_web_application-has_back while it shows. Its built-in styles use the id, so a theme’s general button rules do not reach it. Recolour it with --lh-web-application-back-background, --lh-web-application-back-color, --lh-web-application-back-border and --lh-web-application-back-size, or restyle it with a rule naming the id. The lh_web_application_back_button filter picks where it appears: ios (default; Android has a system back button), standalone (any installed app) or none.
  • The plugin prints the only viewport tag on the page (viewport-fit=cover) and removes the one core adds for block templates, so env(safe-area-inset-*) works in an installed app.
  • lh_web_application_return_ios_startup_id filters the iOS startup image attachment.
  • lh_web_application_apple_startup_sizes filters the iOS startup image sizes. Each entry has the image width and height in pixels and the media query that picks it, so a new iPhone can be added without a release.
  • lh_web_application_init_plugin: return false to stop the plugin loading without deactivating it.
  • The worker gets admin_ajax_return_wp_nonce, the URL of the return_wp_nonce admin-ajax action. It returns a wp_rest nonce for the visitor as a JSON string, which worker scripts send as X-WP-Nonce because a service worker has no page to read one from.
  • The install sheet, dialog#lh_web_application-install, is printed in the footer of every page and slides up from the bottom when opened. It is opened by the Install App menu item (with LH Javascript Menu Items active), by any element with a data-lh-web-application-install attribute (its value is reported as the trigger), and once by itself on a phone from the third visit for the audience chosen in the Install prompt setting. Its steps follow the device: the browser’s own install prompt where one is offered, Share then Add to Home Screen on iPhone and iPad, the browser menu on other Android browsers, File then Add to Dock in Safari on a Mac. Its styles use the id; recolour it with --lh-web-application-install-background, --lh-web-application-install-color, --lh-web-application-install-accent and --lh-web-application-install-accent-color.
  • Install sheet filters: lh_web_application_install_prompt_audience (members, everyone or none), lh_web_application_install_reason (the line under the heading), lh_web_application_install_prompt_visits (default 3), lh_web_application_install_prompt_snooze_days (default 30), lh_web_application_install_sheet_html and lh_web_application_install_sheet_css. Closing the sheet snoozes it in the browser and, for a signed-in member, in the user option lh_web_application-install_snoozed_until for that site; installing the app snoozes it for five years.
  • The sheet fires lh_web_application:install_shown, lh_web_application:install_dismissed, lh_web_application:install_accepted and lh_web_application:app_installed on window, with detail.trigger (menu, auto or the attribute’s value) and detail.platform, for analytics plugins to record. The plugin records nothing itself.
  • The shortcode shows its content only where the app can be installed (body class lh_web_application-prompt_stashed).

If you like this plugin please consider making a donation to further development

Install LHero.org

lhero.org

Open it straight from your home screen, full screen and quicker to load.

  1. Tap the Share button . If you cannot see it, tap ••• first.
  2. Scroll down and tap Add to Home Screen.
  3. Tap Add.
  1. Tap the browser menu â‹®.
  2. Tap Install app or Add to Home screen.
  1. In the menu bar, choose File, then Add to Dock.

Use your browser's menu to install this site or add it to your home screen.