From 08e63c07f4452b147a071c3ab76f1d4c62a6a6f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jul 2026 08:35:59 +0800 Subject: [PATCH 1/3] feat(widgets): VideoPlayer data-aksrt-video shared player shell Route non-embed videos through video-player.js with poster/type/autoplay loop/muted attrs; keep platform iframe embeds; admin empty warning. --- assets/js/video-player.js | 6 +++- src/AKSRT/Widgets/WidgetVideoPlayer.php | 48 +++++++++++++++---------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/assets/js/video-player.js b/assets/js/video-player.js index fe52c533..8f0e461f 100644 --- a/assets/js/video-player.js +++ b/assets/js/video-player.js @@ -65,6 +65,8 @@ this.poster = this.el.dataset.poster || ''; this.type = this.el.dataset.type || detectType(this.src); this.autoplay = this.el.dataset.autoplay === 'true'; + this.loop = this.el.dataset.loop === 'true'; + this.muted = this.el.dataset.muted === 'true' || this.autoplay; this.init(); } @@ -76,8 +78,10 @@ this.video.controls = true; this.video.playsInline = true; this.video.preload = this.autoplay ? 'auto' : 'metadata'; + if (this.loop) this.video.loop = true; + if (this.muted) this.video.muted = true; if (this.poster) this.video.poster = this.poster; - this.video.style.cssText = 'display:block;width:100%;height:auto;max-height:70vh;'; + this.video.style.cssText = 'display:block;width:100%;height:100%;object-fit:contain;max-height:none;'; // Play overlay this.overlay = document.createElement('div'); diff --git a/src/AKSRT/Widgets/WidgetVideoPlayer.php b/src/AKSRT/Widgets/WidgetVideoPlayer.php index d20a2d0f..fde4bf8c 100644 --- a/src/AKSRT/Widgets/WidgetVideoPlayer.php +++ b/src/AKSRT/Widgets/WidgetVideoPlayer.php @@ -1,6 +1,6 @@ __('侧栏/流体区嵌入视频播放器。', 'aksrt')] + [ + 'description' => __('侧栏/流体区嵌入视频(共享 aksrt-video 播放器)。', 'aksrt'), + 'classname' => 'widget_aksrt_video_player', + ] ); } @@ -31,6 +34,12 @@ class WidgetVideoPlayer extends \WP_Widget { $aspect = (string) ($instance['aspect_ratio'] ?? ''); if ($video_url === '') { + if (current_user_can('manage_options')) { + echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo '
' . esc_html__('视频播放器:', 'aksrt') . '' . + esc_html__('请配置视频 URL 或移出该模块', 'aksrt') . '
'; + echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } return; } @@ -47,29 +56,32 @@ class WidgetVideoPlayer extends \WP_Widget { } $embed = $this->get_embed_url($video_url); - $cls = 'aksrt-video-widget' . ($hide_controller ? ' controller-hide' : ''); + $cls = 'aksrt-video-widget relative-h radius8' . ($hide_controller ? ' controller-hide' : ''); echo '
'; + if ($embed !== '') { $src = $embed; if ($autoplay) { $src = add_query_arg(['autoplay' => '1', 'mute' => '1'], $src); } - echo ''; + echo ''; } else { - $attrs = ' controls playsinline'; - if ($autoplay) { - $attrs .= ' autoplay'; + // Shared player stack (assets/js/video-player.js). + $type = 'mp4'; + if (preg_match('/\.m3u8(\?|$)/i', $video_url)) { + $type = 'hls'; + } elseif (preg_match('/\.flv(\?|$)/i', $video_url)) { + $type = 'flv'; } - if ($loop) { - $attrs .= ' loop'; - } - if ($muted) { - $attrs .= ' muted'; - } - if ($poster !== '') { - $attrs .= ' poster="' . esc_url($poster) . '"'; - } - echo ''; + printf( + '
', + esc_url($video_url), + esc_attr($type), + $poster !== '' ? ' data-poster="' . esc_url($poster) . '"' : '', + $autoplay ? ' data-autoplay="true"' : '', + $loop ? ' data-loop="true"' : '', + $muted ? ' data-muted="true"' : '' + ); } echo '
'; @@ -97,7 +109,7 @@ class WidgetVideoPlayer extends \WP_Widget {

-

From af8f97ad3c39ffe85bbd1ebbe706461aa70e675b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jul 2026 08:36:00 +0800 Subject: [PATCH 2/3] feat(widgets): BookmarkLinks via aksrt_links_box bigcard/popover Delegate render to shared links helper for card/bigcard/image/simple styles, popover data attrs, empty admin guidance. --- src/AKSRT/Widgets/WidgetBookmarkLinks.php | 67 +++++++++++------------ 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/src/AKSRT/Widgets/WidgetBookmarkLinks.php b/src/AKSRT/Widgets/WidgetBookmarkLinks.php index e3d900e0..ad69399c 100644 --- a/src/AKSRT/Widgets/WidgetBookmarkLinks.php +++ b/src/AKSRT/Widgets/WidgetBookmarkLinks.php @@ -1,6 +1,6 @@ esc_html__('WordPress 链接(书签)列表,适合友链/导航。', 'aksrt'), + 'description' => esc_html__('WordPress 链接(书签)列表:card / bigcard / image / simple。', 'aksrt'), 'classname' => 'widget_aksrt_bookmark_links', ] ); @@ -30,12 +30,12 @@ class WidgetBookmarkLinks extends \WP_Widget { } $order = strtoupper((string) ($instance['links_order'] ?? 'ASC')) === 'DESC' ? 'DESC' : 'ASC'; $type = sanitize_key((string) ($instance['type'] ?? 'card')); - if (!in_array($type, ['card', 'image', 'simple'], true)) { + if (!in_array($type, ['card', 'bigcard', 'image', 'simple'], true)) { $type = 'card'; } $go_link = !empty($instance['go_link']); $blank = !isset($instance['blank']) || !empty($instance['blank']); - $nofollow = !empty($instance['nofollow']); + $nofollow = !isset($instance['nofollow']) || !empty($instance['nofollow']); $show_box = !empty($instance['show_box']); $bm_args = [ @@ -49,6 +49,13 @@ class WidgetBookmarkLinks extends \WP_Widget { } $bookmarks = get_bookmarks($bm_args); if (!$bookmarks) { + if (current_user_can('manage_options')) { + echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo function_exists('aksrt_get_widget_null') + ? aksrt_get_widget_null(__('暂无链接,请在「链接」中添加', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + : '

' . esc_html__('暂无链接', 'aksrt') . '

'; + echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } return; } @@ -58,37 +65,22 @@ class WidgetBookmarkLinks extends \WP_Widget { echo $args['before_title'] . esc_html($title) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } - $wrap = 'aksrt-bookmark-links style-' . $type . ($show_box ? ' has-box' : ''); + $wrap = 'aksrt-bookmark-links links-box style-' . $type . ($show_box ? ' has-box' : ''); echo '
'; - foreach ($bookmarks as $b) { - $url = (string) $b->link_url; - if ($url !== '' && $go_link && function_exists('aksrt_go_link')) { - $url = aksrt_go_link($url, true); + if (function_exists('aksrt_links_box')) { + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo aksrt_links_box($bookmarks, $type, $nofollow, $go_link, $blank); + } else { + // Minimal fallback. + foreach ($bookmarks as $b) { + $url = (string) $b->link_url; + if ($url !== '' && $go_link && function_exists('aksrt_go_link')) { + $url = aksrt_go_link($url, true); + } + echo ''; + echo esc_html((string) $b->link_name); + echo ''; } - $rel = []; - if ($nofollow) { - $rel[] = 'nofollow'; - } - if ($blank) { - $rel[] = 'noopener'; - $rel[] = 'noreferrer'; - } - $rel_attr = $rel ? ' rel="' . esc_attr(implode(' ', $rel)) . '"' : ''; - $tgt = $blank ? ' target="_blank"' : ''; - $img = (string) $b->link_image; - $name = (string) $b->link_name; - $desc = (string) $b->link_description; - - echo ''; - if ($type !== 'simple' && $img !== '') { - echo ''; - } - echo ''; - echo '' . esc_html($name) . ''; - if ($type === 'card' && $desc !== '') { - echo '' . esc_html($desc) . ''; - } - echo ''; } echo '
'; @@ -116,6 +108,7 @@ class WidgetBookmarkLinks extends \WP_Widget {