Dropdown Menu Widget - Version 1.6.3

Version Description

  • Fixed: Supplied arguments for the menu overwritten in the menu function.
  • Added: Now you can easily add menus using menu names & ids and even locations.
Download this release

Release Info

Developer mattsay
Plugin Icon wp plugin Dropdown Menu Widget
Version 1.6.3
Comparing to
See all releases

Code changes from version 1.6.2 to 1.6.3

Files changed (3) hide show
  1. css/shailan-dropdown.css +1 -1
  2. readme.txt +5 -1
  3. shailan.DropDownMenu.php +70 -28
css/shailan-dropdown.css CHANGED
@@ -39,4 +39,4 @@ ul.dropdown ul ul ul ul ul ul { display: none !important; }
39
  /* Vertical menu support */
40
  ul.dropdown-vertical { /*width: 240px;*/ }
41
  ul.dropdown-vertical ul { top: 1px; left: 99%; }
42
- ul.dropdown-vertical li { float: none; }
39
  /* Vertical menu support */
40
  ul.dropdown-vertical { /*width: 240px;*/ }
41
  ul.dropdown-vertical ul { top: 1px; left: 99%; }
42
+ ul.dropdown-vertical li { float: none; display:block; }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://shailan.com/donate
4
  Tags: css, dropdown, menu, widget, pages, categories, multi, jquery, navigation, category list, themes, custom-styles, options-page, animations, effects
5
  Requires at least: 2.8
6
  Tested up to: 3.1
7
- Stable tag: 1.6.2
8
 
9
  This widget adds a beatiful vertical/horizontal CSS only dropdown menu of Pages, Categories or Custom navigation menus of your blog.
10
 
@@ -47,6 +47,10 @@ You can submit errors and bugs using the [online form](http://shailan.com/contac
47
 
48
  == Changelog ==
49
 
 
 
 
 
50
  = 1.6.2 =
51
  * Fixed: Stylesheet causing widgets go behind widget containers. (Thanks to Antonio Capone for reporting the issue)
52
 
4
  Tags: css, dropdown, menu, widget, pages, categories, multi, jquery, navigation, category list, themes, custom-styles, options-page, animations, effects
5
  Requires at least: 2.8
6
  Tested up to: 3.1
7
+ Stable tag: 1.6.3
8
 
9
  This widget adds a beatiful vertical/horizontal CSS only dropdown menu of Pages, Categories or Custom navigation menus of your blog.
10
 
47
 
48
  == Changelog ==
49
 
50
+ = 1.6.3 =
51
+ * Fixed: Supplied arguments for the menu overwritten in the menu function.
52
+ * Added: Now you can easily add menus using menu names & ids and even locations.
53
+
54
  = 1.6.2 =
55
  * Fixed: Stylesheet causing widgets go behind widget containers. (Thanks to Antonio Capone for reporting the issue)
56
 
shailan.DropDownMenu.php CHANGED
@@ -4,13 +4,13 @@ Plugin Name: Dropdown Menu Widget
4
  Plugin URI: http://shailan.com/wordpress/plugins/dropdown-menu
5
  Description: A multi widget to generate drop-down menus from your pages, categories & navigation menus. You can find more widgets, plugins and themes at <a href="http://shailan.com">shailan.com</a>.
6
  Tags: dropdown, menu, css, css-dropdown, navigation, widget, dropdown-menu, customization, theme
7
- Version: 1.6.2
8
  Author: Matt Say
9
  Author URI: http://shailan.com
10
  Text Domain: shailan-dropdown-menu
11
  */
12
 
13
- define('SHAILAN_DM_VERSION','1.6.2');
14
  define('SHAILAN_DM_TITLE', 'Dropdown Menu');
15
  define('SHAILAN_DM_FOLDER', 'dropdown-menu-widget');
16
 
@@ -23,7 +23,7 @@ class shailan_DropdownWidget extends WP_Widget {
23
  function shailan_DropdownWidget(){
24
  global $pluginname, $pluginshortname, $pluginoptions;
25
 
26
- $widget_ops = array('classname' => 'shailan-dropdown-menu', 'description' => __( 'Dropdown page/category menu', 'shailan-dropdown-menu' ) );
27
  $this->WP_Widget('dropdown-menu', __('Dropdown Menu', 'shailan-dropdown-menu'), $widget_ops);
28
  $this->alt_option_name = 'widget_dropdown_menu';
29
 
@@ -64,8 +64,6 @@ class shailan_DropdownWidget extends WP_Widget {
64
  $available_themes['Dropdown.css (theme)'] = get_template_directory_uri() . '/dropdown.css';
65
  }
66
 
67
- // ksort($available_themes);
68
-
69
  // Swap array for options page
70
  $themes = array();
71
  while(list($Key,$Val) = each($available_themes))
@@ -84,13 +82,15 @@ class shailan_DropdownWidget extends WP_Widget {
84
  $effects = array('fade'=>'Fade In/Out', 'slide'=>'Slide Up/Down'/*, 'fade2'=>'Fade In/Out Moving Up'*/);
85
  $speed = array('400'=>'Normal', 'fast'=>'Fast', 'slow'=>'Slow');
86
 
87
- if(function_exists('wp_nav_menu')){
88
  // Get available menus
89
  $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
 
90
  $navmenus = array();
 
91
  if($menus){
92
- foreach($menus as $menu){
93
- $navmenus['navmenu_' . $menu->term_id] = $menu->name;
94
  }
95
  }
96
 
@@ -395,6 +395,7 @@ class shailan_DropdownWidget extends WP_Widget {
395
 
396
  echo $nl . "<!-- Dropdown Menu Widget by shailan (http://shailan.com) v".SHAILAN_DM_VERSION." on wp".get_bloginfo( 'version' )." -->";
397
  echo $nl . "<!-- Menu Type : " . $type . " -->";
 
398
 
399
  $dropdown_wrapper_open = $nl . '<div id="shailan-dropdown-wrapper-' . $this->number . '" >';
400
 
@@ -482,10 +483,29 @@ class shailan_DropdownWidget extends WP_Widget {
482
 
483
  /** WP3 Nav menu */
484
  default:
485
- $menu_id = substr($type, 8, 3);
486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  $menu_args = array(
488
- 'menu' => $menu_id,
489
  'container' => false,
490
  'container_class' => '',
491
  'container_id' => '',
@@ -499,7 +519,7 @@ class shailan_DropdownWidget extends WP_Widget {
499
  'link_after' => '',
500
  'depth' => 0,
501
  'walker' => '',
502
- 'theme_location' => '');
503
 
504
  if($custom_walkers){
505
  $page_walker = new shailan_PageWalker();
@@ -515,6 +535,7 @@ class shailan_DropdownWidget extends WP_Widget {
515
 
516
  } // switch ($type)
517
 
 
518
  echo "\n\n<!--/ Dropdown Menu Widget -->"; ?>
519
 
520
  <?php echo $after_widget; ?>
@@ -724,54 +745,72 @@ class shailan_DropdownWidget extends WP_Widget {
724
 
725
  echo "\n\n<!-- Dropdown Menu Widget Effects by shailan (http://shailan.com) v".SHAILAN_DM_VERSION." on wp".get_bloginfo( 'version' )." -->"; // For debug
726
  echo "\n<script type=\"text/javascript\">/* <![CDATA[ */";
727
- echo "\njQuery(document).ready(function(){ \n";
728
 
729
  // Remove title attributes from links
730
  if($remove_title_attributes){
731
  ?>
732
- jQuery('ul.dropdown li a').removeAttr('title');
733
  <?php
734
  }
735
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
736
  // Remove links from top-level elements
737
  if($remove_top_level_links){
738
  ?>
739
- jQuery('ul.children').parent().find('a:first').removeAttr('href');
740
  <?php
741
  }
742
 
743
  // Dropdown FX
744
  if( 'fade' == $effect ){
745
  ?>
746
- jQuery(".dropdown li").hover(function(){
747
- jQuery(this).find("ul:first").fadeIn('<?php echo $speed; ?>');
748
  },
749
  function(){
750
- jQuery(this).find("ul:first").fadeOut('<?php echo $speed; ?>');
751
  });
752
  <?php
753
  } elseif( 'slide' == $effect ) { ?>
754
- jQuery(".dropdown li").hover(function(){
755
- jQuery(this).find("ul:first").slideDown('<?php echo $speed; ?>');
756
  },
757
  function(){
758
- jQuery(this).find("ul:first").slideUp('<?php echo $speed; ?>');
759
  });
760
  <?php
761
  } elseif( 'fade2' == $effect ) { ?>
762
 
763
- jQuery(".dropdown li").hover(function(){
764
- h = jQuery(this).height() + 'px';
765
- jQuery(this).find("ul:first").animate( {opacity:'show', top:h}, '<?php echo $speed; ?>');
766
  },
767
  function(){
768
- h = jQuery(this).height() + 5 + 'px';
769
- jQuery(this).find("ul:first").animate( {opacity:'hide', top:h}, '<?php echo $speed; ?>');
770
  });
771
 
772
  <?php }
773
 
774
- echo "\n});";
775
  echo "\n/* ]]> */</script>";
776
  echo "\n<!-- /Dropdown Menu Widget Styles -->";
777
  echo "\n\n ";
@@ -802,6 +841,7 @@ include('shailan-multi-dropdown.php'); // Load multi-dropdown widget
802
 
803
  // Template tag support
804
  function shailan_dropdown_menu( $args = array() ){
 
805
  $type = get_option('shailan_dm_type');
806
  $exclude = get_option('shailan_dm_exclude');
807
  $inline_style = get_option('shailan_dm_style');
@@ -822,9 +862,11 @@ function shailan_dropdown_menu( $args = array() ){
822
  'align' => $align
823
  );
824
 
825
- $args = array_merge( $args, $opts );
 
 
826
 
827
- the_widget('shailan_DropdownWidget', $args);
828
  }
829
 
830
  function get_latest_tweet($username){
4
  Plugin URI: http://shailan.com/wordpress/plugins/dropdown-menu
5
  Description: A multi widget to generate drop-down menus from your pages, categories & navigation menus. You can find more widgets, plugins and themes at <a href="http://shailan.com">shailan.com</a>.
6
  Tags: dropdown, menu, css, css-dropdown, navigation, widget, dropdown-menu, customization, theme
7
+ Version: 1.6.3
8
  Author: Matt Say
9
  Author URI: http://shailan.com
10
  Text Domain: shailan-dropdown-menu
11
  */
12
 
13
+ define('SHAILAN_DM_VERSION', '1.6.3');
14
  define('SHAILAN_DM_TITLE', 'Dropdown Menu');
15
  define('SHAILAN_DM_FOLDER', 'dropdown-menu-widget');
16
 
23
  function shailan_DropdownWidget(){
24
  global $pluginname, $pluginshortname, $pluginoptions;
25
 
26
+ $widget_ops = array('classname' => 'shailan-dropdown-menu-widget', 'description' => __( 'Dropdown page/category menu', 'shailan-dropdown-menu' ) );
27
  $this->WP_Widget('dropdown-menu', __('Dropdown Menu', 'shailan-dropdown-menu'), $widget_ops);
28
  $this->alt_option_name = 'widget_dropdown_menu';
29
 
64
  $available_themes['Dropdown.css (theme)'] = get_template_directory_uri() . '/dropdown.css';
65
  }
66
 
 
 
67
  // Swap array for options page
68
  $themes = array();
69
  while(list($Key,$Val) = each($available_themes))
82
  $effects = array('fade'=>'Fade In/Out', 'slide'=>'Slide Up/Down'/*, 'fade2'=>'Fade In/Out Moving Up'*/);
83
  $speed = array('400'=>'Normal', 'fast'=>'Fast', 'slow'=>'Slow');
84
 
85
+ if( function_exists('wp_nav_menu') ){
86
  // Get available menus
87
  $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
88
+
89
  $navmenus = array();
90
+
91
  if($menus){
92
+ foreach( $menus as $menu ){
93
+ $navmenus[ 'navmenu_' . $menu->term_id ] = $menu->name;
94
  }
95
  }
96
 
395
 
396
  echo $nl . "<!-- Dropdown Menu Widget by shailan (http://shailan.com) v".SHAILAN_DM_VERSION." on wp".get_bloginfo( 'version' )." -->";
397
  echo $nl . "<!-- Menu Type : " . $type . " -->";
398
+ echo $nl . "<div class=\"shailan-dropdown-menu\">";
399
 
400
  $dropdown_wrapper_open = $nl . '<div id="shailan-dropdown-wrapper-' . $this->number . '" >';
401
 
483
 
484
  /** WP3 Nav menu */
485
  default:
 
486
 
487
+ $location = '';
488
+ $menu = '';
489
+
490
+ // Replace navmenu_
491
+ if( FALSE !== strpos( $type, 'navmenu_' ) ){
492
+ $type = str_replace( 'navmenu_', '', $type );
493
+ }
494
+
495
+ $menu_id = $type;
496
+
497
+ // Check if a menu exists with this id
498
+ $menu = wp_get_nav_menu_object( $menu_id );
499
+ if( $menu ){ $menu = $menu_id; }
500
+
501
+ // Is that a location?
502
+ if ( ! $menu && ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_id ] ) ){
503
+ $location = $menu_id;
504
+ $menu = '';
505
+ }
506
+
507
  $menu_args = array(
508
+ 'menu' => $menu,
509
  'container' => false,
510
  'container_class' => '',
511
  'container_id' => '',
519
  'link_after' => '',
520
  'depth' => 0,
521
  'walker' => '',
522
+ 'theme_location' => $location );
523
 
524
  if($custom_walkers){
525
  $page_walker = new shailan_PageWalker();
535
 
536
  } // switch ($type)
537
 
538
+ echo $nl . "</div>";
539
  echo "\n\n<!--/ Dropdown Menu Widget -->"; ?>
540
 
541
  <?php echo $after_widget; ?>
745
 
746
  echo "\n\n<!-- Dropdown Menu Widget Effects by shailan (http://shailan.com) v".SHAILAN_DM_VERSION." on wp".get_bloginfo( 'version' )." -->"; // For debug
747
  echo "\n<script type=\"text/javascript\">/* <![CDATA[ */";
748
+ echo "\n(function($){ \n";
749
 
750
  // Remove title attributes from links
751
  if($remove_title_attributes){
752
  ?>
753
+ $('ul.dropdown li a').removeAttr('title');
754
  <?php
755
  }
756
 
757
+ ?>
758
+ /*
759
+
760
+
761
+ jQuery.fn.alignSubs = function ( args ) {
762
+ return this.each(function(){
763
+ var $this = jQuery(this);
764
+ oleft = ( $this.parent().width() - $this.width() ) / 2;
765
+ $this.css('left', oleft);
766
+ });
767
+ };
768
+
769
+ jQuery('ul.dropdown li ul:first').alignSubs();
770
+
771
+ */
772
+
773
+ <?php
774
+
775
  // Remove links from top-level elements
776
  if($remove_top_level_links){
777
  ?>
778
+ $('ul.children').parent().find('a:first').removeAttr('href');
779
  <?php
780
  }
781
 
782
  // Dropdown FX
783
  if( 'fade' == $effect ){
784
  ?>
785
+ $(".dropdown li").hover(function(){
786
+ $(this).find("ul:first").fadeIn('<?php echo $speed; ?>');
787
  },
788
  function(){
789
+ $(this).find("ul:first").fadeOut('<?php echo $speed; ?>');
790
  });
791
  <?php
792
  } elseif( 'slide' == $effect ) { ?>
793
+ $(".dropdown li").hover(function(){
794
+ $(this).find("ul:first").slideDown('<?php echo $speed; ?>');
795
  },
796
  function(){
797
+ $(this).find("ul:first").slideUp('<?php echo $speed; ?>');
798
  });
799
  <?php
800
  } elseif( 'fade2' == $effect ) { ?>
801
 
802
+ $(".dropdown li").hover(function(){
803
+ h = $(this).height() + 'px';
804
+ $(this).find("ul:first").animate( {opacity:'show', top:h}, '<?php echo $speed; ?>');
805
  },
806
  function(){
807
+ h = $(this).height() + 5 + 'px';
808
+ $(this).find("ul:first").animate( {opacity:'hide', top:h}, '<?php echo $speed; ?>');
809
  });
810
 
811
  <?php }
812
 
813
+ echo "\n})(jQuery);";
814
  echo "\n/* ]]> */</script>";
815
  echo "\n<!-- /Dropdown Menu Widget Styles -->";
816
  echo "\n\n ";
841
 
842
  // Template tag support
843
  function shailan_dropdown_menu( $args = array() ){
844
+
845
  $type = get_option('shailan_dm_type');
846
  $exclude = get_option('shailan_dm_exclude');
847
  $inline_style = get_option('shailan_dm_style');
862
  'align' => $align
863
  );
864
 
865
+ $options = wp_parse_args( $args, $opts );
866
+
867
+ if(!empty( $args['menu'] )){ $options['type'] = $args['menu']; }
868
 
869
+ the_widget( 'shailan_DropdownWidget', $options );
870
  }
871
 
872
  function get_latest_tweet($username){