去除 The7主题 WPBakery 分类链接被自动标记为“激活(active)”状态时,如何去掉这个状态或者不让它显示“当前页高亮”。
/wp-content/themes/dt-the7/inc/widgets/custom-menu/widgets-custom-menu.class.php
‘act’ > ”
————————————————————————————————
dt_options = $options;
}
}
/**
* Traverse elements to create list from elements.
*
* Calls parent function in wp-includes/class-wp-walker.php
*/
function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
if ( !$element ) {
return;
}
//Add indicators for top level menu items with submenus
$id_field = $this->db_fields['id'];
if ( !empty( $children_elements[ $element->$id_field ] ) ) {
$this->dt_menu_parents[] = $element->$id_field;
}
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
function start_lvl( &$output, $depth = 0, $args = array() ) {
$output .= $args->dt_submenu_wrap_start;
$this->dt_is_first = true;
}
function end_lvl( &$output, $depth = 0, $args = array() ) {
$output .= $args->dt_submenu_wrap_end;
}
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
$first_class = '';
$act_class = '';
$if_parent_not_clickable = '';
// current element
if ( in_array( 'current-menu-item', $classes ) ||
in_array( 'current-menu-parent', $classes ) ||
in_array( 'current-menu-ancestor', $classes )
) {
$classes[] = 'act';
}
if ( $this->dt_is_first ) {
$classes[] = 'first';
$first_class = 'class="first"';
}
if ( in_array( 'current-menu-item', $classes ) ) {
$act_class = isset( $args->act_class ) ? $args->act_class : 'act';
}
$dt_is_parent = in_array( $item->ID, $this->dt_menu_parents );
// add parent class
if ( $dt_is_parent ) {
$classes[] = 'has-children';
}
// nonclicable parent menu items
$attributes = '';
$attributes .= !empty( $item->target ) ? '" target="'. esc_attr( $item->target ) : '';
$attributes .= !empty( $item->xfn ) ? '" rel="'. esc_attr( $item->xfn ) : '';
$before_link = $after_link = '';
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
$dt_title = apply_filters( 'the_title', $item->title, $item->ID );
$submenu_indicator = ( $dt_is_parent && isset( $args->dt_submenu_indicator ) ) ? $args->dt_submenu_indicator : '';
$output .= str_replace(
array(
'%ITEM_HREF%',
'%ITEM_TITLE%',
'%ESC_ITEM_TITLE%',
'%ITEM_CLASS%',
'%IS_FIRST%',
'%BEFORE_LINK%',
'%AFTER_LINK%',
'%DEPTH%',
'%ACT_CLASS%',
'%RAW_ITEM_HREF%',
'%IF_PARENT_NOT_CLICKABLE%',
'%SUBMENU_INDICATOR%',
),
array(
esc_attr( $item->url ) . $attributes,
$args->link_before . $dt_title . $args->link_after,
! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) . '"' : '',
esc_attr( $class_names ),
$first_class,
$before_link,
$after_link,
$depth + 1,
$act_class,
esc_attr( $item->url ),
$if_parent_not_clickable,
$submenu_indicator,
),
$args->dt_item_wrap_start
);
$this->dt_count++;
}
function end_el( &$output, $item, $depth = 0, $args = array() ) {
$output .= $args->dt_item_wrap_end;
$this->dt_is_first = false;
}
}