From b17962e99e399ba01b9e5cc6b51dd0596c990aab Mon Sep 17 00:00:00 2001 From: Seaton Jiang Date: Wed, 17 Jan 2024 01:41:31 +0800 Subject: [PATCH] feat: add page lightgallery (#600) --- assets/js/kratos.js | 2 +- inc/theme-core.php | 5 ++--- inc/theme-options.php | 11 +++++++++-- page-full.php | 6 +++--- page.php | 6 +++--- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/assets/js/kratos.js b/assets/js/kratos.js index c70de31..ee7b0df 100644 --- a/assets/js/kratos.js +++ b/assets/js/kratos.js @@ -157,7 +157,7 @@ }; var lightGalleryConfig = function () { - if (kratos.lightgallery === "1" && window.lightGallery !== undefined) { + if (typeof lightGallery !== 'undefined') { lightGallery(document.getElementById("lightgallery"), { selector: 'a[href$=".jpg"], a[href$=".jpeg"], a[href$=".png"], a[href$=".gif"], a[href$=".bmp"], a[href$=".webp"]', diff --git a/inc/theme-core.php b/inc/theme-core.php index 344c5da..0f28bd4 100644 --- a/inc/theme-core.php +++ b/inc/theme-core.php @@ -4,7 +4,7 @@ * 核心函数 * @author Seaton Jiang * @license GPL-3.0 License - * @version 2023.04.04 + * @version 2024.01.17 */ use YahnisElsts\PluginUpdateChecker\v5\PucFactory; @@ -43,7 +43,7 @@ function theme_autoload() wp_enqueue_style('bootstrap', ASSET_PATH . '/assets/css/bootstrap.min.css', array(), '4.5.0'); wp_enqueue_style('kicon', ASSET_PATH . '/assets/css/iconfont.min.css', array(), THEME_VERSION); wp_enqueue_style('layer', ASSET_PATH . '/assets/css/layer.min.css', array(), '3.1.1'); - if (kratos_option('g_lightgallery', true)) { + if ((kratos_option('g_article_lightgallery', true) && is_single()) || (kratos_option('g_page_lightgallery', true) && is_page())) { wp_enqueue_script('lightgallery', ASSET_PATH . '/assets/js/lightgallery.min.js', array(), '1.4.0', true); wp_enqueue_style('lightgallery', ASSET_PATH . '/assets/css/lightgallery.min.css', array(), '1.4.0'); } @@ -106,7 +106,6 @@ function theme_autoload() 'directory' => ASSET_PATH, 'alipay' => kratos_option('g_donate_fieldset')['g_donate_alipay'] ?? '', 'wechat' => kratos_option('g_donate_fieldset')['g_donate_wechat'] ?? '', - 'lightgallery' => kratos_option('g_lightgallery', true), 'repeat' => __('您已经赞过了', 'kratos'), 'thanks' => __('感谢您的支持', 'kratos'), 'donate' => __('打赏作者', 'kratos'), diff --git a/inc/theme-options.php b/inc/theme-options.php index eee082f..2f21baa 100644 --- a/inc/theme-options.php +++ b/inc/theme-options.php @@ -4,7 +4,7 @@ * 主题选项 * @author Seaton Jiang * @license GPL-3.0 License - * @version 2023.08.25 + * @version 2024.01.17 */ defined('ABSPATH') || exit; @@ -148,6 +148,13 @@ CSF::createSection($prefix, array( 'subtitle' => __('启用/禁用 Gutenberg 编辑器', 'kratos'), 'default' => false, ), + array( + 'id' => 'g_page_lightgallery', + 'type' => 'switcher', + 'title' => __('页面图片灯箱', 'kratos'), + 'subtitle' => __('启用/禁用页面图片灯箱功能', 'kratos'), + 'default' => true, + ), array( 'id' => 'g_excerpt_length', 'type' => 'text', @@ -682,7 +689,7 @@ CSF::createSection($prefix, array( 'default' => true, ), array( - 'id' => 'g_lightgallery', + 'id' => 'g_article_lightgallery', 'type' => 'switcher', 'title' => __('文章图片灯箱', 'kratos'), 'subtitle' => __('启用/禁用文章图片灯箱功能', 'kratos'), diff --git a/page-full.php b/page-full.php index 3d14634..ea8d9cb 100644 --- a/page-full.php +++ b/page-full.php @@ -4,7 +4,7 @@ * Template Name: 单页样式 * @author Seaton Jiang * @license GPL-3.0 License - * @version 2022.11.27 + * @version 2024.01.17 */ get_header(); ?> @@ -18,7 +18,7 @@ get_header(); ?>

-
+
- + \ No newline at end of file diff --git a/page.php b/page.php index ef65b97..af89bcf 100644 --- a/page.php +++ b/page.php @@ -4,7 +4,7 @@ * 页面模板 * @author Seaton Jiang * @license GPL-3.0 License - * @version 2022.01.26 + * @version 2024.01.17 */ get_header(); ?> @@ -18,7 +18,7 @@ get_header(); ?>

-
+
- + \ No newline at end of file