Здравствуйте. Есть сайт на WP и мне очень нужна ваша помощь(
Вот боковое меню
http://cryptoland.by/shop/. Как можно сделать так, чтобы при нажатии например на Оборудование для майнинга подкатеории открывались/ закрывались? На данный момент оно просто переходит по ссылке.
$( '.yit_toggle_menu ul.menu.open_first > li:first-child, .yit_toggle_menu ul.menu.open_all > li' ).addClass( 'opened' );
$( '.yit_toggle_menu ul.menu.open_active li.current-menu-ancestor, .yit_toggle_menu ul.menu.open_active li.current-menu-parent' ).addClass( 'opened' );
$( '.yit_toggle_menu ul li.dropdown > a' ).on('click'function( e ) {
e.preventDefault();
e.stopPropagation(); // Prevent issues on mobile.
var dropdown = $( this ).next( 'ul' );
var dropdown_parent = dropdown.parent( '.dropdown' );
dropdown.width( dropdown_parent.width() );
dropdown_parent.width( dropdown_parent.parent().width() );
if( dropdown_parent.hasClass( 'opened' ) )
{ dropdown_parent.removeClass( 'opened' ); }
else
{ dropdown_parent.addClass( 'opened' ); }
dropdown.slideToggle();
});
});
if( !class_exists( 'yit_toggle_menu' ) ) :
class yit_toggle_menu extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => 'yit_toggle_menu',
'description' => __( 'Print a custom menu in a sidebar with a fancy toggle jQuery effect. Create an apposite menu for this widget in Appearance -> Menus.', 'yit' )
);
$control_ops = array( 'id_base' => 'yit_toggle_menu' );
WP_Widget::__construct( 'yit_toggle_menu', __( 'Toggle Menu', 'yit' ), $widget_ops, $control_ops );
}
public function form( $instance ) {
$defaults = array(
'title' => '',
'menu' => '',
'open_dropdowns' => 'first',
);
$instance = wp_parse_args( ( array ) $instance, $defaults ); ?>
<p>
<label>
<strong><?php _e( 'Title', 'yit' ) ?></strong>
<input class="widefat" type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'menu' ); ?>"><?php _e( 'Menu', 'yit' ) ?>:
<select id="<?php echo $this->get_field_id( 'menu' ); ?>" name="<?php echo $this->get_field_name( 'menu' ); ?>">
<option value=""></option>
<?php foreach( yit_get_registered_nav_menus() as $menu ): ?>
<option value="<?php echo $menu ?>" <?php selected( $menu, $instance['menu'] ) ?>><?php echo $menu ?></option>
<?php endforeach ?>
</select>
</label>
</p>
<p>
<input type="radio" name="<?php echo $this->get_field_name( 'open_dropdowns' ); ?>" value="first" <?php checked( 'first' , $instance['open_dropdowns'] ) ?> />
<label><?php _e( 'Open the first dropdown', 'yit' ) ?></label><br />
<input type="radio" name="<?php echo $this->get_field_name( 'open_dropdowns' ); ?>" value="all" <?php checked( 'all', $instance['open_dropdowns'] ) ?> />
<label><?php _e( 'Open all dropdowns', 'yit' ) ?></label><br />
<input type="radio" name="<?php echo $this->get_field_name( 'open_dropdowns' ); ?>" value="active" <?php checked( 'active', $instance['open_dropdowns'] ) ?> />
<label><?php _e( 'Open active dropdown', 'yit' ) ?></label><br />
<input type="radio" name="<?php echo $this->get_field_name( 'open_dropdowns' ); ?>" value="none" <?php checked( 'none', $instance['open_dropdowns'] ) ?> />
<label><?php _e( 'Close all dropdowns', 'yit' ) ?></label><br />
</p>
<?php
}
public function widget( $args, $instance ) {
extract( $args );
$title = apply_filters('widget_title', $instance['title'] );
echo $before_widget;
if ( $title ) echo $before_title . $title . $after_title;
$args = array(
'menu' => $instance['menu'],
'menu_class' => 'menu',
'depth' => apply_filters( 'yit_toggle_menu_depth', 3 ),
);
if( $instance['open_dropdowns'] )
{ $args['menu_class'] .= ' open_' . $instance['open_dropdowns']; }
wp_nav_menu( $args );
echo $after_widget;
}
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = esc_html( $new_instance['title'] );
$instance['menu'] = $new_instance['menu'];
$instance['open_dropdowns'] = $new_instance['open_dropdowns'];
return $instance;
}
}
endif;