From bfb489d01d507e57928b7463d82dad0f1e0a6a69 Mon Sep 17 00:00:00 2001 From: Marcin Pietrzak Date: Mon, 16 Sep 2024 11:40:59 +0200 Subject: [PATCH] improvements --- assets/scripts/frontend.js | 2 +- assets/scripts/frontend.min.js | 2 +- etc/options.php | 47 +++++++++++++++++++ includes/index.php | 1 + includes/iworks/class-iworks-pwa.php | 22 ++++++++- includes/iworks/index.php | 1 + .../iworks/pwa/class-iworks-pwa-apple.php | 2 +- .../iworks/pwa/class-iworks-pwa-manifest.php | 10 ++++ includes/iworks/pwa/index.php | 1 + index.php | 1 + package.json | 2 +- readme.txt | 5 ++ 12 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 includes/index.php create mode 100644 includes/iworks/index.php create mode 100644 includes/iworks/pwa/index.php create mode 100644 index.php diff --git a/assets/scripts/frontend.js b/assets/scripts/frontend.js index e146aa2..666561d 100644 --- a/assets/scripts/frontend.js +++ b/assets/scripts/frontend.js @@ -1,5 +1,5 @@ /** - * PWA — easy way to Progressive Web App - v1.6.2 + * PWA — easy way to Progressive Web App - v1.6.3 * https://github.com/iworks/iworks-pwa * Copyright (c) 2024; * Licensed GPLv3+ */ window.addEventListener('load', function(event) { diff --git a/assets/scripts/frontend.min.js b/assets/scripts/frontend.min.js index ea1f5ad..2692126 100644 --- a/assets/scripts/frontend.min.js +++ b/assets/scripts/frontend.min.js @@ -1,5 +1,5 @@ /** - * PWA — easy way to Progressive Web App - v1.6.2 + * PWA — easy way to Progressive Web App - v1.6.3 * https://github.com/iworks/iworks-pwa * Copyright (c) 2024; * Licensed GPL-3.0 */ window.addEventListener("load",function(a){var b;const c=document.querySelector("#iworks-pwa-add-button"),d=document.querySelector("#iworks-pwa-add-button-container");c&&window.addEventListener("beforeinstallprompt",function(a){a.preventDefault(),b=a,d.style.display="block",c.addEventListener("click",function(){d.style.display="none",b.prompt(),b.userChoice.then(function(a){"accepted"===a.outcome,b=null})})})}),"serviceWorker"in navigator&&navigator.serviceWorker.register(window.iworks_pwa.serviceWorkerUri).then(function(a){})["catch"](function(a){}); \ No newline at end of file diff --git a/etc/options.php b/etc/options.php index 35be0fb..b30628a 100644 --- a/etc/options.php +++ b/etc/options.php @@ -128,6 +128,53 @@ function iworks_pwa_options() { ), 'rows' => 10, ), + /** + * Section "Categories" + * + * @since 1.6.3 + */ + array( + 'type' => 'heading', + 'label' => __( 'Categories', 'iworks-pwa' ), + 'description' => esc_html__( + 'The categories member is an array of strings defining the names of categories that the application supposedly belongs to.', + 'iworks-pwa' + ), + ), + array( + 'name' => 'categories', + 'type' => 'checkbox_group', + 'options' => array( + 'books' => esc_html__( 'Books', 'iworks-pwa' ), + 'business' => esc_html__( 'Business', 'iworks-pwa' ), + 'education' => esc_html__( 'Education', 'iworks-pwa' ), + 'entertainment' => esc_html__( 'Entertainment', 'iworks-pwa' ), + 'finance' => esc_html__( 'Finance', 'iworks-pwa' ), + 'fitness' => esc_html__( 'Fitness', 'iworks-pwa' ), + 'food' => esc_html__( 'Food', 'iworks-pwa' ), + 'games' => esc_html__( 'Games', 'iworks-pwa' ), + 'government' => esc_html__( 'Government', 'iworks-pwa' ), + 'health' => esc_html__( 'Health', 'iworks-pwa' ), + 'kids' => esc_html__( 'Kids', 'iworks-pwa' ), + 'lifestyle' => esc_html__( 'Lifestyle', 'iworks-pwa' ), + 'magazines' => esc_html__( 'Magazines', 'iworks-pwa' ), + 'medical' => esc_html__( 'Medical', 'iworks-pwa' ), + 'music' => esc_html__( 'Music', 'iworks-pwa' ), + 'navigation' => esc_html__( 'Navigation', 'iworks-pwa' ), + 'news' => esc_html__( 'News', 'iworks-pwa' ), + 'personalization' => esc_html__( 'Personalization', 'iworks-pwa' ), + 'photo' => esc_html__( 'Photo', 'iworks-pwa' ), + 'politics' => esc_html__( 'Politics', 'iworks-pwa' ), + 'productivity' => esc_html__( 'Productivity', 'iworks-pwa' ), + 'security' => esc_html__( 'Security', 'iworks-pwa' ), + 'shopping' => esc_html__( 'Shopping', 'iworks-pwa' ), + 'social' => esc_html__( 'Social', 'iworks-pwa' ), + 'sports' => esc_html__( 'Sports', 'iworks-pwa' ), + 'travel' => esc_html__( 'Travel', 'iworks-pwa' ), + 'utilities' => esc_html__( 'Utilities', 'iworks-pwa' ), + 'weather' => esc_html__( 'Weather', 'iworks-pwa' ), + ), + ), /** * Section "Add to Home screen" * diff --git a/includes/index.php b/includes/index.php new file mode 100644 index 0000000..bacffcc --- /dev/null +++ b/includes/index.php @@ -0,0 +1 @@ +eol = $this->debug ? PHP_EOL : ''; + $this->eol = apply_filters( 'iworks/pwa/eol', $this->eol ); /** * set options */ @@ -168,6 +168,7 @@ private function _set_configuration() { ), 'splash_pages' => apply_filters( 'iworks_pwa_configuration_splash_pages', null ), 'icons' => $this->get_configuration_icons(), + 'categories' => $this->get_configuration_categories(), ) ); if ( ! is_admin() ) { @@ -698,5 +699,22 @@ protected function get_configuration_scope() { return apply_filters( 'iworks_pwa_configuration_scope', '/' ); } + /** + * get configuration categories + * + * @since 1.6.3 + */ + protected function get_configuration_categories() { + $value = $this->options->get_option( 'categories' ); + if ( is_array( $value ) ) { + $value = array_values( $value ); + } else { + $value = null; + } + return apply_filters( + 'iworks/pwa/configuration/categories', + $value + ); + } } diff --git a/includes/iworks/index.php b/includes/iworks/index.php new file mode 100644 index 0000000..bacffcc --- /dev/null +++ b/includes/iworks/index.php @@ -0,0 +1 @@ +%s', + '%s', $this->eol ); printf( diff --git a/includes/iworks/pwa/class-iworks-pwa-manifest.php b/includes/iworks/pwa/class-iworks-pwa-manifest.php index 34102c2..f32f4eb 100644 --- a/includes/iworks/pwa/class-iworks-pwa-manifest.php +++ b/includes/iworks/pwa/class-iworks-pwa-manifest.php @@ -214,6 +214,16 @@ private function print_manifest_json() { */ $data['id'] = $this->get_configuration_app_id(); header( 'Content-Type: application/json' ); + /** + * remove empty values + * + * @since 1.6.3 + */ + foreach ( $data as $key => $value ) { + if ( empty( $value ) ) { + unset( $data[ $key ] ); + } + } /** * filter manifest data */ diff --git a/includes/iworks/pwa/index.php b/includes/iworks/pwa/index.php new file mode 100644 index 0000000..bacffcc --- /dev/null +++ b/includes/iworks/pwa/index.php @@ -0,0 +1 @@ +