__('A customizable accordion menu.', 'accordeon-menu-ck') ); parent::__construct( 'accordeon-menu-ck', 'Accordeon Menu CK', $widget_opts ); } function getInst($name, $default = '') { $settings = $this->getSettings(); $default = isset($settings[$name]) ? $settings[$name] : $default; return isset($this->inst[$name]) ? $this->inst[$name] : $default; } function getSettings() { return \Accordeonmenuck\Helper::getSettings(); } function widget($args, $instance) { $this->inst = $instance; $menuID = 'accordeconck' . $this->number; // Set the vars to create the menu $walker = new Accordeonmenuck_Walker_Nav_Menu; // $strict_sub = $instance['only_related'] == 3 ? 1 : 0; // $only_related = $instance['only_related'] == 2 || $instance['only_related'] == 3 ? 1 : 0; $depth = $this->getInst('depth'); $style = $this->getInst('style'); // $container = $this->getInst('container'); // $container_id = $this->getInst('container_id'); $menu_class = $this->getInst('menu_class'); $showactive = $this->getInst('showactive'); $showactivesubmenu = $this->getInst('showactivesubmenu'); // $transition = $this->getInst('menu_class'); // $before = $this->getInst('before'); // $after = $this->getInst('after'); // $link_before = $this->getInst('link_before'); // $link_after = $this->getInst('link_after'); // $filter = ! empty( $instance['filter'] ) ? $instance['filter'] : 0; // $filter_selection = $instance['filter_selection'] ? $instance['filter_selection'] : 0; // $include_parent = ! empty( $instance['include_parent'] ) ? 1 : 0; // $post_parent = ! empty( $instance['post_parent'] ) ? 1 : 0; $description = ! empty( $instance['description'] ) ? 1 : 0; $hide_title = ! empty( $instance['hide_title'] ) ? 1 : 0; // effect settings $transition = $this->getInst('transition'); $duration = $this->getInst('duration'); $eventtype = $this->getInst('eventtype'); wp_enqueue_script('jquery'); wp_enqueue_script('accordeonmenuck_easing', ACCORDEONMENUCK_MEDIA_URL . '/assets/jquery.easing.1.3.js'); wp_enqueue_script('accordeonmenuck', ACCORDEONMENUCK_MEDIA_URL . '/assets/accordeonmenuck.js'); // wp_enqueue_style('accordeonmenuck' . $menuID, plugins_url() . '/accordeon-menu-ck/themes/default/accordeonmenuck_css.php?cssid=' . $menuID); // load the styles $css = ''; if ((int) $style > 0) { global $wpdb; $css = $wpdb->get_var('SELECT layoutcss FROM ' . $wpdb->prefix . 'accordeonmenuck_styles WHERE id=' . (int) $style); $css = str_replace('|ID|', '#' . $menuID, $css); $css = str_replace('|qq|', '"', $css); } // Get the menu $menu = wp_get_nav_menu_object( $instance['nav_menu'] ); if ( ! $menu || is_wp_error($menu) ) return; $menu_args = array( 'echo' => false, 'items_wrap' => '', 'fallback_cb' => '', 'menu' => $menu, 'walker' => $walker, // this is the main part to render the menu html 'depth' => $depth, // 'only_related' => $only_related, // 'strict_sub' => $strict_sub, // 'filter_selection' => $filter_selection, 'container' => false, // 'container_id' => $container_id, 'menu_class' => $menu_class, 'showactive' => $showactive, 'showactivesubmenu' => $showactivesubmenu, // 'before' => $before, // before the tag // 'after' => $after, // 'link_before' => $link_before, // inside the tag, before the text // 'link_after' => $link_after, // 'filter' => $filter, // 'include_parent' => $include_parent, // 'post_parent' => $post_parent, 'description' => $description ); $nav_menu = wp_nav_menu($menu_args ); if ( !$nav_menu && $hide_title ) return; // inject the css style if ($css) { ?> id_base); if ( !empty($instance['title']) ) echo $args['before_title'] . $instance['title'] . $args['after_title']; if ( $nav_menu ) { static $menu_id_slugs = array(); // Attributes if ( ! empty( $menu_id ) ) { $wrap_id = $menu_id; } else { $wrap_id = 'menu-' . $menu->slug; while ( in_array( $wrap_id, $menu_id_slugs ) ) { if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) $wrap_id = preg_replace('#-(\d+)$#', '-' . ++$matches[1], $wrap_id ); else $wrap_id = $wrap_id . '-1'; } } $menu_id_slugs[] = $wrap_id; $wrap_class = $menu_class ? $menu_class : ''; // outputs the menu html echo $nav_menu; $js = " jQuery(document).ready(function(){ jQuery('#" . $menuID . "').accordeonmenuck({" . "eventtype : '" . $eventtype . "'," . "transition : '" . $transition . "'," . "showactive : '" . $showactive . "'," . "showactivesubmenu : '" . $showactivesubmenu . "'," // . "defaultopenedid : '" . $params->get('defaultopenedid') . "'," // . "activeeffect : '" . (bool) $params->get('activeeffect') . "'," . "duree : " . (int)$duration . "}); }); " ?> site_url(), 'adminurl' => admin_url() )); // initialize the instance $this->inst = $instance; $title = $this->getInst('title'); $nav_menu = $this->getInst('nav_menu'); // $only_related = $this->getInst('only_related'); $depth = $this->getInst('depth'); // $container = $this->getInst('container'); // $container_id = $this->getInst('container_id'); $menu_class = $this->getInst('menu_class'); $showactive = $this->getInst('showactive'); $showactivesubmenu = $this->getInst('showactivesubmenu'); // $before = $this->getInst('before'); // $after = $this->getInst('after'); // $link_before = $this->getInst('link_before'); // $link_after = $this->getInst('link_after'); // $filter_selection = $this->getInst('filter_selection'); // $filter = isset($instance['filter']) ? absint($instance['filter']) : 0; $style = $this->getInst('style'); $transition = $this->getInst('transition'); $duration = $this->getInst('duration'); $eventtype = $this->getInst('eventtype'); // Get menus $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); // If no menus exists, direct the user to go and create some. if ( !$menus ) { echo '

'. sprintf( __('No menus have been created yet. Create some.', 'accordeon-menu-ck'), admin_url('nav-menus.php') ) .'

'; return; } // Get styles global $wpdb; // -- Preparing the query -- $query = "SELECT id,name FROM " . $wpdb->prefix . "accordeonmenuck_styles ORDER BY name ASC"; $styles = $wpdb->get_results($query, OBJECT); ?>

/> 

/> 


ms