Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b6f2ca6d7 |
@@ -9,6 +9,10 @@
|
||||
var swUrl = cfg.swUrl || '/sw.js';
|
||||
var scope = cfg.scope || '/';
|
||||
|
||||
if ( cfg.requireLogin && ! cfg.isLoggedIn ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Service Worker registrieren
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const CACHE_NAME = 'kgv-pwa-v1';
|
||||
const CACHE_NAME = 'kgv-pwa-v1-0-1';
|
||||
const OFFLINE_PAGE = '/';
|
||||
|
||||
const PRECACHE_URLS = [
|
||||
|
||||
28
kgv-pwa.php
28
kgv-pwa.php
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: KGV PWA
|
||||
* Plugin URI: https://apex-project.de/
|
||||
* Description: Progressive Web App Unterstützung fuer KGV-Webseiten – Web App Manifest, Service Worker und Install-Banner.
|
||||
* Version: 1.0.0
|
||||
* Version: 1.0.1
|
||||
* Author: Ronny Grobel
|
||||
* Author URI: https://apex-project.de/
|
||||
* Text Domain: kgv-pwa
|
||||
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
||||
final class KGV_PWA_Plugin {
|
||||
|
||||
const VERSION = '1.0.0';
|
||||
const VERSION = '1.0.1';
|
||||
const OPTION_KEY = 'kgv_pwa_settings';
|
||||
const REWRITE_VERSION_OPTION = 'kgv_pwa_rewrite_version';
|
||||
|
||||
@@ -99,6 +99,11 @@ final class KGV_PWA_Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! is_user_logged_in() ) {
|
||||
status_header( 403 );
|
||||
exit;
|
||||
}
|
||||
|
||||
$settings = $this->get_settings();
|
||||
|
||||
$manifest = array(
|
||||
@@ -172,6 +177,11 @@ final class KGV_PWA_Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! is_user_logged_in() ) {
|
||||
status_header( 403 );
|
||||
exit;
|
||||
}
|
||||
|
||||
$sw_file = plugin_dir_path( __FILE__ ) . 'assets/js/service-worker.js';
|
||||
|
||||
if ( ! file_exists( $sw_file ) ) {
|
||||
@@ -193,6 +203,10 @@ final class KGV_PWA_Plugin {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public function output_head_tags() {
|
||||
if ( ! is_user_logged_in() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = $this->get_settings();
|
||||
$app_name = esc_attr( $settings['app_name'] );
|
||||
$theme_hex = esc_attr( $settings['theme_color'] );
|
||||
@@ -221,6 +235,10 @@ final class KGV_PWA_Plugin {
|
||||
}
|
||||
|
||||
public function enqueue_assets() {
|
||||
if ( ! is_user_logged_in() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sw_url = $this->get_service_worker_url();
|
||||
$scope = trailingslashit( home_url( '/' ) );
|
||||
|
||||
@@ -245,6 +263,8 @@ final class KGV_PWA_Plugin {
|
||||
array(
|
||||
'swUrl' => esc_url_raw( $sw_url ),
|
||||
'scope' => esc_url_raw( $scope ),
|
||||
'requireLogin' => true,
|
||||
'isLoggedIn' => is_user_logged_in(),
|
||||
'iosInstallNotice' => __( 'Auf iPhone/iPad: Im Browser auf Teilen tippen und dann "Zum Home-Bildschirm" waehlen.', 'kgv-pwa' ),
|
||||
)
|
||||
);
|
||||
@@ -259,6 +279,10 @@ final class KGV_PWA_Plugin {
|
||||
* class – Zusätzliche CSS-Klassen
|
||||
*/
|
||||
public function render_install_button( $atts ) {
|
||||
if ( ! is_user_logged_in() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
'label' => __( 'App installieren', 'kgv-pwa' ),
|
||||
|
||||
@@ -3,7 +3,7 @@ Contributors: ronnygrobel
|
||||
Tags: pwa, progressive web app, manifest, service worker, offline
|
||||
Requires at least: 6.0
|
||||
Tested up to: 6.7
|
||||
Stable tag: 1.0.0
|
||||
Stable tag: 1.0.1
|
||||
Requires PHP: 7.4
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
@@ -43,5 +43,10 @@ Werden keine Icons angegeben, wird automatisch das WordPress-Site-Icon verwendet
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0.1 =
|
||||
* PWA-Installation auf eingeloggte Benutzer begrenzt
|
||||
* Manifest und Service Worker geben fuer Gaeste HTTP 403 zurueck
|
||||
* Frontend-Assets und Install-Button nur fuer eingeloggte Benutzer aktiv
|
||||
|
||||
= 1.0.0 =
|
||||
* Erstveröffentlichung
|
||||
|
||||
Reference in New Issue
Block a user