Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb36fe07f1 | ||
|
|
b7a7f173e3 | ||
|
|
7b6f2ca6d7 |
@@ -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
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|||||||
@@ -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 = [
|
||||||
|
|||||||
30
kgv-pwa.php
30
kgv-pwa.php
@@ -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.3
|
||||||
* 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.3';
|
||||||
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' ),
|
||||||
|
|||||||
11
readme.txt
11
readme.txt
@@ -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.3
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user