From fdd494070e2b7798639f7442eecc0cc2befa56bf Mon Sep 17 00:00:00 2001 From: Seaton Jiang Date: Sun, 27 Nov 2022 20:12:55 +0800 Subject: [PATCH] feat: add lightgallery switch (#507) --- assets/js/kratos.js | 8 +++++--- inc/theme-core.php | 7 +++++-- inc/theme-options.php | 7 +++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/assets/js/kratos.js b/assets/js/kratos.js index 440f98d..2da253a 100644 --- a/assets/js/kratos.js +++ b/assets/js/kratos.js @@ -149,9 +149,11 @@ } var lightGalleryConfig = function () { - lightGallery(document.getElementById('lightgallery'), { - selector: 'a[href$=".jpg"], a[href$=".jpeg"], a[href$=".png"], a[href$=".gif"], a[href$=".bmp"], a[href$=".webp"]' - }) + if(kratos.lightgallery){ + lightGallery(document.getElementById('lightgallery'), { + selector: 'a[href$=".jpg"], a[href$=".jpeg"], a[href$=".png"], a[href$=".gif"], a[href$=".bmp"], a[href$=".webp"]' + }) + } } document.addEventListener('DOMContentLoaded', function () { diff --git a/inc/theme-core.php b/inc/theme-core.php index 7a64b43..6d072af 100644 --- a/inc/theme-core.php +++ b/inc/theme-core.php @@ -4,7 +4,7 @@ * 核心函数 * @author Seaton Jiang * @license GPL-3.0 License - * @version 2022.05.27 + * @version 2022.11.27 */ // CDN 资源地址 @@ -41,7 +41,9 @@ 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'); - wp_enqueue_style('lightgallery', ASSET_PATH . '/assets/css/lightgallery.min.css', array(), '1.4.0'); + if (kratos_option('g_lightgallery', true)) { + wp_enqueue_style('lightgallery', ASSET_PATH . '/assets/css/lightgallery.min.css', array(), '1.4.0'); + } if (kratos_option('g_animate', false)) { wp_enqueue_style('animate', ASSET_PATH . '/assets/css/animate.min.css', array(), '4.1.1'); } @@ -104,6 +106,7 @@ 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 20beffc..992c0ce 100644 --- a/inc/theme-options.php +++ b/inc/theme-options.php @@ -681,6 +681,13 @@ CSF::createSection($prefix, array( 'subtitle' => __('启用/禁用按类型筛选媒体库功能功能', 'kratos'), 'default' => true, ), + array( + 'id' => 'g_lightgallery', + 'type' => 'switcher', + 'title' => __('文章图片灯箱', 'kratos'), + 'subtitle' => __('启用/禁用文章图片灯箱功能', 'kratos'), + 'default' => true, + ), array( 'id' => 'g_article_widgets', 'type' => 'image_select',