Advanced Sidebar Menu - Version 3.2.3

Version Description

  • Fix a bug that caused multiple category list to display of more than one category the single post was in shared the same parent
Download this release

Release Info

Developer Mat Lipe
Plugin Icon 128x128 Advanced Sidebar Menu
Version 3.2.3
Comparing to
See all releases

Code changes from version 3.2.1 to 3.2.3

advanced-sidebar-menu.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /*
3
  Plugin Name: Advanced Sidebar Menu
4
- Plugin URI: http://lipeimagination.info
5
  Description: Creates dynamic menu based on child/parent relationship.
6
  Author: Mat Lipe
7
- Version: 3.2.1
8
  Author URI: http://lipeimagination.info
9
  Since: 6/4/12
10
  Email: mat@lipeimagination.info
1
  <?php
2
  /*
3
  Plugin Name: Advanced Sidebar Menu
4
+ Plugin URI: http://lipeimagination.info/wordpress/advanced-sidebar-menu/
5
  Description: Creates dynamic menu based on child/parent relationship.
6
  Author: Mat Lipe
7
+ Version: 3.2.3
8
  Author URI: http://lipeimagination.info
9
  Since: 6/4/12
10
  Email: mat@lipeimagination.info
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypa
4
  Tags: menus, sidebar menu, heirchy, category menu, pages menu
5
  Requires at least: 3.1
6
  Tested up to: 3.3.2
7
- Stable tag: 3.2.1
8
- Version: 3.2.1
9
 
10
  == Description ==
11
 
@@ -65,6 +65,9 @@ You may want to use something like margins to set the levels apart.
65
 
66
  == Changelog ==
67
 
 
 
 
68
  = 3.2.1 =
69
  * Fix a possible bug that may display a * Notice * error if there is nothing to display and the error reporting is set to strict when using the categories widget.
70
 
@@ -121,7 +124,7 @@ You may want to use something like margins to set the levels apart.
121
 
122
  == Upgrade Notice ==
123
 
124
- = 3.2 =
125
  This will add the ability to display the categories on single post pages.
126
  If you are using the category_list.php view you will most likely get an error message to remove a couple lines.
127
  These lines are no longer needed for the structure in this new version.
4
  Tags: menus, sidebar menu, heirchy, category menu, pages menu
5
  Requires at least: 3.1
6
  Tested up to: 3.3.2
7
+ Stable tag: 3.2.3
8
+ Version: 3.2.3
9
 
10
  == Description ==
11
 
65
 
66
  == Changelog ==
67
 
68
+ = 3.2.3 =
69
+ * Fix a bug that caused multiple category list to display of more than one category the single post was in shared the same parent
70
+
71
  = 3.2.1 =
72
  * Fix a possible bug that may display a * Notice * error if there is nothing to display and the error reporting is set to strict when using the categories widget.
73
 
124
 
125
  == Upgrade Notice ==
126
 
127
+ = 3.2.3 =
128
  This will add the ability to display the categories on single post pages.
129
  If you are using the category_list.php view you will most likely get an error message to remove a couple lines.
130
  These lines are no longer needed for the structure in this new version.
widgets/category.widget.php CHANGED
@@ -5,7 +5,7 @@
5
  * Creates a Widget of parent Child Categories
6
  *
7
  * @author mat lipe
8
- * @since 6/3/12
9
  * @package Advanced Sidebar Menu
10
  *
11
  */
@@ -126,7 +126,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
126
  function widget($args, $instance) {
127
  #-- Create a usable array of the excluded pages
128
  $exclude = explode(',', $instance['exclude']);
129
- $cat_ids = array();
130
  $asm_once = $asm_cat_widget_count = false; //keeps track of how many widgets this created
131
  $count = null;
132
 
@@ -138,6 +138,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
138
  foreach( get_the_category() as $id => $cat ){
139
  $cat_ids[] = $cat->term_id;
140
  }
 
141
  //IF on a category page get the id of the category
142
  } elseif( is_category() ){
143
  $cat_ids[] = get_query_var('cat');
@@ -166,8 +167,18 @@ class advanced_sidebar_menu_category extends WP_Widget {
166
  while ($cat_id );
167
 
168
 
 
169
  $cat_ancestors = array_reverse( $cat_ancestors );
170
- $top_cat = $cat_ancestors [1];
 
 
 
 
 
 
 
 
 
171
 
172
  //Check for children
173
  $all = get_categories( array( 'child_of' => $top_cat ) );
5
  * Creates a Widget of parent Child Categories
6
  *
7
  * @author mat lipe
8
+ * @since 6/4/12
9
  * @package Advanced Sidebar Menu
10
  *
11
  */
126
  function widget($args, $instance) {
127
  #-- Create a usable array of the excluded pages
128
  $exclude = explode(',', $instance['exclude']);
129
+ $cat_ids = $already_top = array();
130
  $asm_once = $asm_cat_widget_count = false; //keeps track of how many widgets this created
131
  $count = null;
132
 
138
  foreach( get_the_category() as $id => $cat ){
139
  $cat_ids[] = $cat->term_id;
140
  }
141
+
142
  //IF on a category page get the id of the category
143
  } elseif( is_category() ){
144
  $cat_ids[] = get_query_var('cat');
167
  while ($cat_id );
168
 
169
 
170
+ //Reverse the array to start at the last
171
  $cat_ancestors = array_reverse( $cat_ancestors );
172
+ //forget the [0] because the parent of top parent is always 0
173
+ $top_cat = $cat_ancestors[1];
174
+
175
+
176
+ //Keeps track or already used top levels so this won't double up
177
+ if( in_array( $top_cat, $already_top ) ){
178
+ continue;
179
+ }
180
+ $already_top[] = $top_cat;
181
+
182
 
183
  //Check for children
184
  $all = get_categories( array( 'child_of' => $top_cat ) );