Dropdown Menu Widget - Version 1.2.0

Version Description

  • Removed title attributes for the categories dropdown menu items.
Download this release

Release Info

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

Code changes from version 1.1.0 to 1.2.0

readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://shailan.com/donate
4
  Tags: css, dropdown, menu, widget, pages, categories
5
  Requires at least: 2.5
6
  Tested up to: 2.8.6
7
- Stable tag: 1.1.0
8
 
9
  This widget adds a beatiful vertical/horizontal CSS only dropdown menu of pages OR categories of your blog.
10
 
@@ -31,6 +31,9 @@ This widget is intented for *wide header widget areas*, not regular sidebars. Yo
31
 
32
  == Changelog ==
33
 
 
 
 
34
  = 1.1.0 =
35
  * Added custom walker class to disable title attributes on menu items.
36
  * Renamed class and style files.
4
  Tags: css, dropdown, menu, widget, pages, categories
5
  Requires at least: 2.5
6
  Tested up to: 2.8.6
7
+ Stable tag: 1.2.0
8
 
9
  This widget adds a beatiful vertical/horizontal CSS only dropdown menu of pages OR categories of your blog.
10
 
31
 
32
  == Changelog ==
33
 
34
+ = 1.2.0 =
35
+ * Removed title attributes for the categories dropdown menu items.
36
+
37
  = 1.1.0 =
38
  * Added custom walker class to disable title attributes on menu items.
39
  * Renamed class and style files.
shailan-category-walker.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php // is the love
2
+
3
+ /**
4
+ * Create HTML list of categories.
5
+ *
6
+ * @package WordPress
7
+ * @since 2.1.0
8
+ * @uses Walker
9
+ */
10
+ class shailan_CategoryWalker extends Walker {
11
+ /**
12
+ * @see Walker::$tree_type
13
+ * @since 2.1.0
14
+ * @var string
15
+ */
16
+ var $tree_type = 'category';
17
+
18
+ /**
19
+ * @see Walker::$db_fields
20
+ * @since 2.1.0
21
+ * @todo Decouple this
22
+ * @var array
23
+ */
24
+ var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
25
+
26
+ /**
27
+ * @see Walker::start_lvl()
28
+ * @since 2.1.0
29
+ *
30
+ * @param string $output Passed by reference. Used to append additional content.
31
+ * @param int $depth Depth of category. Used for tab indentation.
32
+ * @param array $args Will only append content if style argument value is 'list'.
33
+ */
34
+ function start_lvl(&$output, $depth, $args) {
35
+ if ( 'list' != $args['style'] )
36
+ return;
37
+
38
+ $indent = str_repeat("\t", $depth);
39
+ $output .= "$indent<ul class='children'>\n";
40
+ }
41
+
42
+ /**
43
+ * @see Walker::end_lvl()
44
+ * @since 2.1.0
45
+ *
46
+ * @param string $output Passed by reference. Used to append additional content.
47
+ * @param int $depth Depth of category. Used for tab indentation.
48
+ * @param array $args Will only append content if style argument value is 'list'.
49
+ */
50
+ function end_lvl(&$output, $depth, $args) {
51
+ if ( 'list' != $args['style'] )
52
+ return;
53
+
54
+ $indent = str_repeat("\t", $depth);
55
+ $output .= "$indent</ul>\n";
56
+ }
57
+
58
+ /**
59
+ * @see Walker::start_el()
60
+ * @since 2.1.0
61
+ *
62
+ * @param string $output Passed by reference. Used to append additional content.
63
+ * @param object $category Category data object.
64
+ * @param int $depth Depth of category in reference to parents.
65
+ * @param array $args
66
+ */
67
+ function start_el(&$output, $category, $depth, $args) {
68
+ extract($args);
69
+
70
+ $cat_name = esc_attr( $category->name);
71
+ $cat_name = apply_filters( 'list_cats', $cat_name, $category );
72
+ $link = '<a href="' . get_category_link( $category->term_id ) . '" ';
73
+ /*
74
+
75
+ @shailan: Disabled titles for dropdown menu.
76
+
77
+ if ( $use_desc_for_title == 0 || empty($category->description) )
78
+ $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"';
79
+ else
80
+ $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
81
+
82
+ */
83
+ $link .= '>';
84
+ $link .= $cat_name . '</a>';
85
+
86
+ if ( (! empty($feed_image)) || (! empty($feed)) ) {
87
+ $link .= ' ';
88
+
89
+ if ( empty($feed_image) )
90
+ $link .= '(';
91
+
92
+ $link .= '<a href="' . get_category_feed_link($category->term_id, $feed_type) . '"';
93
+
94
+ if ( empty($feed) )
95
+ $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"';
96
+ else {
97
+ $title = ' title="' . $feed . '"';
98
+ $alt = ' alt="' . $feed . '"';
99
+ $name = $feed;
100
+ //$link .= $title; // @shailan: removed title
101
+ }
102
+
103
+ $link .= '>';
104
+
105
+ if ( empty($feed_image) )
106
+ $link .= $name;
107
+ else
108
+ $link .= "<img src='$feed_image'$alt" . ' />'; // @shailan: removed title
109
+ $link .= '</a>';
110
+ if ( empty($feed_image) )
111
+ $link .= ')';
112
+ }
113
+
114
+ if ( isset($show_count) && $show_count )
115
+ $link .= ' (' . intval($category->count) . ')';
116
+
117
+ if ( isset($show_date) && $show_date ) {
118
+ $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
119
+ }
120
+
121
+ if ( isset($current_category) && $current_category )
122
+ $_current_category = get_category( $current_category );
123
+
124
+ if ( 'list' == $args['style'] ) {
125
+ $output .= "\t<li";
126
+ $class = 'cat-item cat-item-'.$category->term_id;
127
+ if ( isset($current_category) && $current_category && ($category->term_id == $current_category) )
128
+ $class .= ' current-cat';
129
+ elseif ( isset($_current_category) && $_current_category && ($category->term_id == $_current_category->parent) )
130
+ $class .= ' current-cat-parent';
131
+ $output .= ' class="'.$class.'"';
132
+ $output .= ">$link\n";
133
+ } else {
134
+ $output .= "\t$link<br />\n";
135
+ }
136
+ }
137
+
138
+ /**
139
+ * @see Walker::end_el()
140
+ * @since 2.1.0
141
+ *
142
+ * @param string $output Passed by reference. Used to append additional content.
143
+ * @param object $page Not used.
144
+ * @param int $depth Depth of category. Not used.
145
+ * @param array $args Only uses 'list' for whether should append to output.
146
+ */
147
+ function end_el(&$output, $page, $depth, $args) {
148
+ if ( 'list' != $args['style'] )
149
+ return;
150
+
151
+ $output .= "</li>\n";
152
+ }
153
+
154
+ }
shailan.DropDownMenu.php CHANGED
@@ -209,7 +209,15 @@ Here you can set template tag options:
209
  'exclude'=>$exclude
210
  )); ?>
211
  <?php } else { ?>
212
- <?php wp_list_categories('order_by=name&depth=4&title_li=&exclude='.$exclude); ?>
 
 
 
 
 
 
 
 
213
  <?php } ?>
214
  <?php if($admin){ wp_register('<li class="admintab">','</li>'); } if($login){ ?><li class="page_item"><?php wp_loginout(); ?><?php } ?>
215
  </ul></td>
@@ -287,6 +295,7 @@ add_action('widgets_init', create_function('', 'return register_widget("shailan_
287
  add_action('admin_menu', array('shailan_DropdownWidget', 'adminMenu'));
288
 
289
  include('shailan-page-walker.php'); // Load custom page walker
 
290
 
291
  function shailan_dropdown_menu(){
292
  $type = get_option('shailan_dm_type');
209
  'exclude'=>$exclude
210
  )); ?>
211
  <?php } else { ?>
212
+ <?php
213
+ $cat_walker = new shailan_CategoryWalker();
214
+ wp_list_categories(array(
215
+ 'walker'=>$cat_walker,
216
+ 'order_by'=>'name',
217
+ 'depth'=>'4'
218
+ 'title_li'=>'',
219
+ 'exclude'=>$exclude
220
+ )); ?>
221
  <?php } ?>
222
  <?php if($admin){ wp_register('<li class="admintab">','</li>'); } if($login){ ?><li class="page_item"><?php wp_loginout(); ?><?php } ?>
223
  </ul></td>
295
  add_action('admin_menu', array('shailan_DropdownWidget', 'adminMenu'));
296
 
297
  include('shailan-page-walker.php'); // Load custom page walker
298
+ include('shailan-category-walker.php'); // Load custom category walker
299
 
300
  function shailan_dropdown_menu(){
301
  $type = get_option('shailan_dm_type');