2 Commits
v1.0.0 ... main

Author SHA1 Message Date
Ronny Grobel
b7a7f173e3 release: 1.0.2 2026-04-20 23:00:42 +02:00
Ronny Grobel
7b6f2ca6d7 Release 1.0.1: restrict PWA install to logged-in users 2026-04-20 21:46:45 +02:00
4 changed files with 42 additions and 5 deletions

View File

@@ -9,6 +9,10 @@
var swUrl = cfg.swUrl || '/sw.js'; var swUrl = cfg.swUrl || '/sw.js';
var scope = cfg.scope || '/'; var scope = cfg.scope || '/';
if ( cfg.requireLogin && ! cfg.isLoggedIn ) {
return;
}
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Service Worker registrieren // Service Worker registrieren
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@@ -8,7 +8,7 @@
'use strict'; 'use strict';
const CACHE_NAME = 'kgv-pwa-v1'; const CACHE_NAME = 'kgv-pwa-v1-0-1';
const OFFLINE_PAGE = '/'; const OFFLINE_PAGE = '/';
const PRECACHE_URLS = [ const PRECACHE_URLS = [

View File

@@ -1,9 +1,9 @@
<?php <?php
/** /**
* Plugin Name: KGV PWA * Plugin Name: KGV PWA
* Plugin URI: https://apex-project.de/ * Plugin URI: https://wordpress.apex-project.de/
* Description: Progressive Web App Unterstützung fuer KGV-Webseiten Web App Manifest, Service Worker und Install-Banner. * Description: Progressive Web App Unterstützung fuer KGV-Webseiten Web App Manifest, Service Worker und Install-Banner.
* Version: 1.0.0 * Version: 1.0.2
* Author: Ronny Grobel * Author: Ronny Grobel
* Author URI: https://apex-project.de/ * Author URI: https://apex-project.de/
* Text Domain: kgv-pwa * Text Domain: kgv-pwa
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
final class KGV_PWA_Plugin { final class KGV_PWA_Plugin {
const VERSION = '1.0.0'; const VERSION = '1.0.2';
const OPTION_KEY = 'kgv_pwa_settings'; const OPTION_KEY = 'kgv_pwa_settings';
const REWRITE_VERSION_OPTION = 'kgv_pwa_rewrite_version'; const REWRITE_VERSION_OPTION = 'kgv_pwa_rewrite_version';
@@ -99,6 +99,11 @@ final class KGV_PWA_Plugin {
return; return;
} }
if ( ! is_user_logged_in() ) {
status_header( 403 );
exit;
}
$settings = $this->get_settings(); $settings = $this->get_settings();
$manifest = array( $manifest = array(
@@ -172,6 +177,11 @@ final class KGV_PWA_Plugin {
return; return;
} }
if ( ! is_user_logged_in() ) {
status_header( 403 );
exit;
}
$sw_file = plugin_dir_path( __FILE__ ) . 'assets/js/service-worker.js'; $sw_file = plugin_dir_path( __FILE__ ) . 'assets/js/service-worker.js';
if ( ! file_exists( $sw_file ) ) { if ( ! file_exists( $sw_file ) ) {
@@ -193,6 +203,10 @@ final class KGV_PWA_Plugin {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
public function output_head_tags() { public function output_head_tags() {
if ( ! is_user_logged_in() ) {
return;
}
$settings = $this->get_settings(); $settings = $this->get_settings();
$app_name = esc_attr( $settings['app_name'] ); $app_name = esc_attr( $settings['app_name'] );
$theme_hex = esc_attr( $settings['theme_color'] ); $theme_hex = esc_attr( $settings['theme_color'] );
@@ -221,6 +235,10 @@ final class KGV_PWA_Plugin {
} }
public function enqueue_assets() { public function enqueue_assets() {
if ( ! is_user_logged_in() ) {
return;
}
$sw_url = $this->get_service_worker_url(); $sw_url = $this->get_service_worker_url();
$scope = trailingslashit( home_url( '/' ) ); $scope = trailingslashit( home_url( '/' ) );
@@ -245,6 +263,8 @@ final class KGV_PWA_Plugin {
array( array(
'swUrl' => esc_url_raw( $sw_url ), 'swUrl' => esc_url_raw( $sw_url ),
'scope' => esc_url_raw( $scope ), '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' ), '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 * class Zusätzliche CSS-Klassen
*/ */
public function render_install_button( $atts ) { public function render_install_button( $atts ) {
if ( ! is_user_logged_in() ) {
return '';
}
$atts = shortcode_atts( $atts = shortcode_atts(
array( array(
'label' => __( 'App installieren', 'kgv-pwa' ), 'label' => __( 'App installieren', 'kgv-pwa' ),

View File

@@ -3,7 +3,7 @@ Contributors: ronnygrobel
Tags: pwa, progressive web app, manifest, service worker, offline Tags: pwa, progressive web app, manifest, service worker, offline
Requires at least: 6.0 Requires at least: 6.0
Tested up to: 6.7 Tested up to: 6.7
Stable tag: 1.0.0 Stable tag: 1.0.2
Requires PHP: 7.4 Requires PHP: 7.4
License: GPLv2 or later License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -43,5 +43,14 @@ Werden keine Icons angegeben, wird automatisch das WordPress-Site-Icon verwendet
== Changelog == == Changelog ==
= 1.0.2 =
* Release 1.0.2 erstellt.
* Versionsnummer in Plugin-Datei, Konstante und Readme erhoeht.
= 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 = = 1.0.0 =
* Erstveröffentlichung * Erstveröffentlichung