Merge pull request 'fix(widgets): render article sidebar by viewport CSS' (#13) from worktree/fix-tool-posts into main
Reviewed-on: #13
This commit is contained in:
commit
ae8d89ae60
3 files changed
+9
-4
No files matched your search
@@ -52,7 +52,7 @@ if (!function_exists('aksrt_single_render_aside')) :
|
|||||||
* @param array<string,mixed> $ctx Single context.
|
* @param array<string,mixed> $ctx Single context.
|
||||||
*/
|
*/
|
||||||
function aksrt_single_render_aside(array $ctx): void {
|
function aksrt_single_render_aside(array $ctx): void {
|
||||||
if (empty($ctx['show_aside']) || wp_is_mobile()) {
|
if (empty($ctx['show_aside'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,8 +106,10 @@ if (!function_exists('aksrt_single_build_context')) :
|
|||||||
$has_article_widgets = is_active_sidebar('all_sidebar_top')
|
$has_article_widgets = is_active_sidebar('all_sidebar_top')
|
||||||
|| is_active_sidebar('sidebar-article')
|
|| is_active_sidebar('sidebar-article')
|
||||||
|| is_active_sidebar('all_sidebar_bottom');
|
|| is_active_sidebar('all_sidebar_bottom');
|
||||||
$show_aside = !wp_is_mobile()
|
// Do not use wp_is_mobile() as a layout gate. It is User-Agent based and
|
||||||
&& get_post_type($post_id) === 'post'
|
// 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'
|
&& $layout !== 'no_sidebar'
|
||||||
&& $has_article_widgets;
|
&& $has_article_widgets;
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,10 @@ function aksrt_get_site_layout(): int {
|
|||||||
$has_article_widgets = is_active_sidebar('all_sidebar_top')
|
$has_article_widgets = is_active_sidebar('all_sidebar_top')
|
||||||
|| is_active_sidebar('sidebar-article')
|
|| is_active_sidebar('sidebar-article')
|
||||||
|| is_active_sidebar('all_sidebar_bottom');
|
|| 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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user