fix: 修复移动端目录和顶栏链接显示问题

- 移动端抽屉栏新增顶栏自定义链接显示(argon_toolbar_links_left/right)
- 优化 have_catalog() 函数,增加对 Gutenberg 标题块和 Markdown 标题的检测
- 自定义链接显示在导航菜单和侧边栏菜单之间
This commit is contained in:
2026-01-15 15:35:40 +08:00
parent 564223599e
commit d86b57684f
2 changed files with 59 additions and 3 deletions

View File

@@ -631,11 +631,19 @@ function have_catalog(){
return true; return true;
} }
$content = get_post(get_the_ID()) -> post_content; $content = get_post(get_the_ID()) -> post_content;
if (preg_match('/<h[1-6](.*?)>/',$content)){ // 检查 HTML 标题标签
if (preg_match('/<h[1-6](.*?)>/i', $content)){
return true; return true;
}else{
return false;
} }
// 检查 Gutenberg 标题块
if (preg_match('/<!-- wp:heading/', $content)){
return true;
}
// 检查 Markdown 格式标题(如果启用了 Markdown
if (preg_match('/^#{1,6}\s+/m', $content)){
return true;
}
return false;
} }
//获取文章 Meta //获取文章 Meta
function get_article_meta($type){ function get_article_meta($type){

View File

@@ -117,6 +117,54 @@ $author_desc = get_option('argon_sidebar_author_description');
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- 顶栏自定义链接 -->
<?php
$toolbar_links_left = get_option('argon_toolbar_links_left', '');
$toolbar_links_right = get_option('argon_toolbar_links_right', '');
$has_custom_links = !empty(trim($toolbar_links_left)) || !empty(trim($toolbar_links_right));
if ($has_custom_links) :
?>
<div class="leftbar-mobile-menu-section">
<div class="leftbar-mobile-section-title"><?php _e('链接', 'argon'); ?></div>
<ul class="leftbar-mobile-menu">
<?php
// 输出左侧自定义链接
if (!empty(trim($toolbar_links_left))) {
foreach (explode("\n", $toolbar_links_left) as $line) {
$line = trim($line);
if (empty($line)) continue;
$parts = array_map('trim', explode('|', $line));
if (!empty($parts[0])) {
$url = isset($parts[1]) ? $parts[1] : '#';
$icon = isset($parts[2]) ? '<i class="' . esc_attr($parts[2]) . '"></i> ' : '';
echo '<li class="leftbar-mobile-menu-item">';
echo '<a href="' . esc_url($url) . '">';
echo $icon . '<span class="menu-text">' . esc_html($parts[0]) . '</span>';
echo '</a></li>';
}
}
}
// 输出右侧自定义链接
if (!empty(trim($toolbar_links_right))) {
foreach (explode("\n", $toolbar_links_right) as $line) {
$line = trim($line);
if (empty($line)) continue;
$parts = array_map('trim', explode('|', $line));
if (!empty($parts[0])) {
$url = isset($parts[1]) ? $parts[1] : '#';
$icon = isset($parts[2]) ? '<i class="' . esc_attr($parts[2]) . '"></i> ' : '';
echo '<li class="leftbar-mobile-menu-item">';
echo '<a href="' . esc_url($url) . '">';
echo $icon . '<span class="menu-text">' . esc_html($parts[0]) . '</span>';
echo '</a></li>';
}
}
}
?>
</ul>
</div>
<?php endif; ?>
<!-- 侧边栏菜单 --> <!-- 侧边栏菜单 -->
<?php if ( has_nav_menu('leftbar_menu') ) : ?> <?php if ( has_nav_menu('leftbar_menu') ) : ?>
<div class="leftbar-mobile-menu-section"> <div class="leftbar-mobile-menu-section">