From f8dd319524919278f309d4f42f19ad4aac94ed05 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Aug 2026 12:39:37 +0800 Subject: [PATCH] fix(widgets): render article sidebar by viewport CSS --- inc/helpers/aksrt-single-aside.php | 2 +- inc/helpers/aksrt-single.php | 6 ++++-- inc/helpers/aksrt-template-tags.php | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/inc/helpers/aksrt-single-aside.php b/inc/helpers/aksrt-single-aside.php index add6934b..2e4e454b 100644 --- a/inc/helpers/aksrt-single-aside.php +++ b/inc/helpers/aksrt-single-aside.php @@ -52,7 +52,7 @@ if (!function_exists('aksrt_single_render_aside')) : * @param array $ctx Single context. */ function aksrt_single_render_aside(array $ctx): void { - if (empty($ctx['show_aside']) || wp_is_mobile()) { + if (empty($ctx['show_aside'])) { return; } diff --git a/inc/helpers/aksrt-single.php b/inc/helpers/aksrt-single.php index 24bdd27c..c237572d 100644 --- a/inc/helpers/aksrt-single.php +++ b/inc/helpers/aksrt-single.php @@ -106,8 +106,10 @@ if (!function_exists('aksrt_single_build_context')) : $has_article_widgets = is_active_sidebar('all_sidebar_top') || is_active_sidebar('sidebar-article') || is_active_sidebar('all_sidebar_bottom'); - $show_aside = !wp_is_mobile() - && get_post_type($post_id) === 'post' + // Do not use wp_is_mobile() as a layout gate. It is User-Agent based and + // can disagree with the actual viewport (for example, desktop-mode mobile + // browsers). The responsive stylesheet owns narrow-screen hiding. + $show_aside = get_post_type($post_id) === 'post' && $layout !== 'no_sidebar' && $has_article_widgets; diff --git a/inc/helpers/aksrt-template-tags.php b/inc/helpers/aksrt-template-tags.php index 209d7802..936dfcb2 100644 --- a/inc/helpers/aksrt-template-tags.php +++ b/inc/helpers/aksrt-template-tags.php @@ -212,7 +212,10 @@ function aksrt_get_site_layout(): int { $has_article_widgets = is_active_sidebar('all_sidebar_top') || is_active_sidebar('sidebar-article') || is_active_sidebar('all_sidebar_bottom'); - if (get_post_type($post_id) !== 'post' || wp_is_mobile() || $layout === 'no_sidebar' || !$has_article_widgets) { + // Keep the sidebar in the document whenever it is configured. CSS handles + // narrow viewports; wp_is_mobile() is User-Agent based and can otherwise + // suppress widgets on a desktop-sized page. + if (get_post_type($post_id) !== 'post' || $layout === 'no_sidebar' || !$has_article_widgets) { return 1; }