3.2.27: 评论嵌套引导线按层变色(1层浅蓝/2层深蓝/3层点赞色/更深扩展色轮换,深层线恢复绘制);导航多级下拉修复(depth=2 截断改 0,深层父项 dropdown-submenu + hover 右侧弹出,移动端平铺)
This commit is contained in:
+20
-2
@@ -184,7 +184,14 @@ if (!class_exists('WP_Bootstrap_Navwalker')) {
|
||||
$id = $id ? ' id="' . esc_attr($id) . '"' : '';
|
||||
|
||||
if ($args->has_children) {
|
||||
$output .= $indent . '<li' . $id . ' class="nav-item dropdown" ' . '>';
|
||||
/* 3.2.27:深层(第二级起)的父项加 dropdown-submenu ——
|
||||
Bootstrap 4 原生不支持嵌套下拉,主题用这个类 + CSS
|
||||
(hover 时子菜单 left:100% 从右侧弹出)补上。 */
|
||||
if (0 === $depth) {
|
||||
$output .= $indent . '<li' . $id . ' class="nav-item dropdown" ' . '>';
|
||||
} else {
|
||||
$output .= $indent . '<li' . $id . ' class="nav-item dropdown dropdown-submenu" ' . '>';
|
||||
}
|
||||
} else {
|
||||
$output .= $indent . '<li' . $id . ' class="nav-item" ' . '>';
|
||||
}
|
||||
@@ -205,13 +212,24 @@ if (!class_exists('WP_Bootstrap_Navwalker')) {
|
||||
$atts['target'] = !empty($item->target) ? $item->target : '';
|
||||
$atts['rel'] = !empty($item->xfn) ? $item->xfn : '';
|
||||
// If the item has children, add atts to the <a>.
|
||||
if (isset($args->has_children) && $args->has_children && 0 === $depth && $args->depth > 1) {
|
||||
// 3.2.27:$args->depth > 1 → !== 1。原来 depth=0(不限层数)时
|
||||
// 这个条件为假,顶层父项会失去 data-toggle,一级下拉都开不了。
|
||||
// depth===1 表示"菜单只要一层",那才真的不该有下拉。
|
||||
if (isset($args->has_children) && $args->has_children && 0 === $depth && $args->depth !== 1) {
|
||||
$atts['href'] = '#';
|
||||
$atts['data-toggle'] = 'dropdown';
|
||||
$atts['aria-haspopup'] = 'true';
|
||||
$atts['aria-expanded'] = 'false';
|
||||
$atts['class'] = 'dropdown-toggle nav-link';
|
||||
$atts['id'] = 'menu-item-dropdown-' . $item->ID;
|
||||
} elseif (isset($args->has_children) && $args->has_children && $depth > 0) {
|
||||
/* 3.2.27:深层父项 —— 保留真实链接(点它进分类页),
|
||||
只补 dropdown-toggle 让箭头出现;**不加 data-toggle**,
|
||||
开合交给 CSS hover(.dropdown-submenu:hover > .dropdown-menu),
|
||||
避免 Bootstrap 的 dropdown JS 用 Popper 把子菜单位置
|
||||
重算到父项下方、和"从右侧弹出"打架。 */
|
||||
$atts['href'] = !empty($item->url) ? $item->url : '#';
|
||||
$atts['class'] = 'dropdown-item dropdown-toggle';
|
||||
} else {
|
||||
$atts['href'] = !empty($item->url) ? $item->url : '#';
|
||||
// For items in dropdowns use .dropdown-item instead of .nav-link.
|
||||
|
||||
Reference in New Issue
Block a user