Advanced Sidebar Menu - Version 1.5

Version Description

Download this release

Release Info

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

Code changes from version 1.4.4 to 1.5

Files changed (2) hide show
  1. advanced-sidebar-menu.php +30 -20
  2. readme.txt +7 -6
advanced-sidebar-menu.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Advanced Sidebar Menu
4
  Plugin URI: http://www.vimm.com
5
  Description: Creates dynamic menu based on child/parent relationship.
6
  Author: Mat Lipe
7
- Version: 1.4.4
8
  Author URI: http://www.vimm.com
9
 
10
  email: mat@lipeimagination.info
@@ -62,9 +62,8 @@ class advanced_sidebar_menu extends WP_Widget {
62
  function widget($args, $instance) {
63
  global $wpdb;
64
  global $p;
65
- global $post;
66
 
67
- //makes the custom menu
68
 
69
  #-- if the post has parrents
70
  if($post->ancestors){
@@ -81,8 +80,12 @@ class advanced_sidebar_menu extends WP_Widget {
81
  $p = $post->ID;
82
  }
83
 
 
 
 
 
84
 
85
- $result = $wpdb->get_results( "SELECT ID FROM wp_posts WHERE post_parent = $p AND post_type='page' Order by menu_order" );
86
 
87
  #---- if there are no children do not display the parent unless it is check to do so
88
  if($result != false || $instance['include_childless_parent'] == 'checked' ){
@@ -90,41 +93,48 @@ class advanced_sidebar_menu extends WP_Widget {
90
  //Start the menu
91
  echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget">';
92
 
93
-
94
  echo '<ul class="parent-sidebar-menu" >';
95
  #-- if the checkbox to include parent is checked
96
  if( $instance['include_parent'] == 'checked' ){
97
  $parent_toggle = TRUE;
98
-
99
  #-- list the parent page
100
  wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$p);
101
- echo '<ul class="child-sidebar-menu">';
102
  }
103
  }
104
 
105
- //=----------------------------------- makes the link list -----------------------------------------
 
 
 
 
 
106
  foreach($result as $pID){
 
 
107
  #--echo the current page from the $result
108
  wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
109
 
110
  #-- if the link that was just listed is the current page we are on
111
- if($pID->ID == $post->ID or $pID->ID == $post->post_parent or in_array($pID->ID, $post->ancestors) ){
112
 
113
- #-- Create a new menu with all the children under it
114
- echo '<ul class="grandchild-sidebar-menu">';
 
 
 
115
 
116
- wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=3&child_of=".$pID->ID);
117
 
118
- echo '</ul>';
119
-
120
  }
121
-
122
- }
123
- #-- if the options above echoed the parent and therefore added another ul
124
- if( $parent_toggle == TRUE ){
125
- echo '</ul>';
126
- }
127
 
 
128
  #-- If there was a menu close it off
129
  if($result != false || $instance['include_childless_parent'] == 'checked' ){
130
 
4
  Plugin URI: http://www.vimm.com
5
  Description: Creates dynamic menu based on child/parent relationship.
6
  Author: Mat Lipe
7
+ Version: 1.5
8
  Author URI: http://www.vimm.com
9
 
10
  email: mat@lipeimagination.info
62
  function widget($args, $instance) {
63
  global $wpdb;
64
  global $p;
65
+ global $post;
66
 
 
67
 
68
  #-- if the post has parrents
69
  if($post->ancestors){
80
  $p = $post->ID;
81
  }
82
 
83
+ #-- Makes this work with all table prefixes
84
+ #-- Added 1/22/12
85
+ global $table_prefix;
86
+
87
 
88
+ $result = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = $p AND post_type='page' Order by menu_order" );
89
 
90
  #---- if there are no children do not display the parent unless it is check to do so
91
  if($result != false || $instance['include_childless_parent'] == 'checked' ){
93
  //Start the menu
94
  echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget">';
95
 
 
96
  echo '<ul class="parent-sidebar-menu" >';
97
  #-- if the checkbox to include parent is checked
98
  if( $instance['include_parent'] == 'checked' ){
99
  $parent_toggle = TRUE;
 
100
  #-- list the parent page
101
  wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$p);
102
+
103
  }
104
  }
105
 
106
+ //=----------------------------------- makes the Child Pages list -----------------------------------------
107
+
108
+ //If there are children start the Child Sidebar Menu
109
+ if( $result != FALSE ){
110
+ echo '<ul class="child-sidebar-menu">';
111
+
112
  foreach($result as $pID){
113
+
114
+
115
  #--echo the current page from the $result
116
  wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
117
 
118
  #-- if the link that was just listed is the current page we are on
119
+ if($pID->ID == $post->ID or $pID->ID == $post->post_parent or @in_array($pID->ID, $post->ancestors) ){
120
 
121
+ $kids = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID->ID." AND post_type='page' " );
122
+ if( $kids != FALSE ){
123
+
124
+ #-- Create a new menu with all the children under it
125
+ echo '<ul class="grandchild-sidebar-menu">';
126
 
127
+ wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=3&child_of=".$pID->ID);
128
 
129
+ echo '</ul>';
130
+ }
131
  }
132
+ }
133
+
134
+ #-- Close the First Level menu
135
+ echo '</ul><!-- End child-sidebar-menu -->';
 
 
136
 
137
+ }
138
  #-- If there was a menu close it off
139
  if($result != false || $instance['include_childless_parent'] == 'checked' ){
140
 
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: http://lipeimagination.info/contact/
4
  Tags: menus, sidebar menu, heirchy
5
  Requires at least: 3.1
6
  Tested up to: 3.2.1
7
- Stable tag: 1.4.4
8
- Version: 1.4.4
9
 
10
  == Description ==
11
 
@@ -37,13 +37,14 @@ Yes. Based on whatever parents and children pages you are on, the menu will chan
37
 
38
  As of version 1.1 this will automatically generate class names for each level for menu system. You can add classes to your theme's style.css file to style it accourdingly. You may want to use something like margins to set the levels apart.
39
 
40
- == Screenshots ==
41
-
42
- 1. The Simple to use widget
43
-
44
 
45
  == Changelog ==
46
 
 
 
 
 
 
47
  = 1.4.4 =
48
  * Cleaned up the way the plugin displays
49
  * Added class to match normal widgets
4
  Tags: menus, sidebar menu, heirchy
5
  Requires at least: 3.1
6
  Tested up to: 3.2.1
7
+ Stable tag: 1.4.5
8
+ Version: 1.4.5
9
 
10
  == Description ==
11
 
37
 
38
  As of version 1.1 this will automatically generate class names for each level for menu system. You can add classes to your theme's style.css file to style it accourdingly. You may want to use something like margins to set the levels apart.
39
 
 
 
 
 
40
 
41
  == Changelog ==
42
 
43
+ = 1.4.5 =
44
+ * Added compatibility for sites with non wp_ prefix tables
45
+ * Removed All traces of Each menu level if no pages to list
46
+ * Removed Error created by some search forms
47
+
48
  = 1.4.4 =
49
  * Cleaned up the way the plugin displays
50
  * Added class to match normal widgets