Advanced Sidebar Menu - Version 1.4.4

Version Description

  • Cleaned up the way the plugin displays
  • Added class to match normal widgets
  • Removed the
    completely when no menu present
Download this release

Release Info

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

Code changes from version 2.0 to 1.4.4

Files changed (3) hide show
  1. advanced-sidebar-menu.php +62 -58
  2. readme.txt +9 -3
  3. screenshot-1.PNG +0 -0
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
8
Author URI: http://www.vimm.com
9
10
email: mat@lipeimagination.info
@@ -60,73 +60,77 @@ class advanced_sidebar_menu extends WP_Widget {
60
61
// adds the output to the widget area on the page
62
function widget($args, $instance) {
63
- ?>
64
- <div id="<?php echo $args['widget_id']; ?>" class="advanced-sidebar-menu"><ul class="parent-sidebar-menu" >
65
- <?php
66
-
67
- global $wpdb;
68
- global $p;
69
- global $post;
70
-
71
-
72
- //makes the custom menu
73
74
- #-- if the post has parrents
75
- if($post->ancestors){
76
- $parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$post->ID );
77
78
- //--- If there is a parent of the post set $p to it and check if there is a parent as well
79
- while($parent != FALSE){
80
- $p = $parent;
81
- $parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$parent);
82
- }
83
84
- } else {
85
- #--------- If this is the parent ------------------------------------------------
86
- $p = $post->ID;
87
- }
88
-
89
- $result = $wpdb->get_results( "SELECT ID FROM wp_posts WHERE post_parent = $p AND post_type='page' Order by menu_order" );
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' ){
92
93
- #-- if the checkbox to include parent is checked
94
- if( $instance['include_parent'] == 'checked' ){
95
- $parent_toggle = TRUE;
96
97
- #-- list the parent page
98
- wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$p);
99
- echo '<ul class="child-sidebar-menu">';
100
- }
101
- }
102
103
//=----------------------------------- makes the link list -----------------------------------------
104
- foreach($result as $pID){
105
- #--echo the current page from the $result
106
- wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
107
108
- #-- if the link that was just listed is the current page we are on
109
- if($pID->ID == $post->ID or $pID->ID == $post->post_parent or in_array($pID->ID, $post->ancestors) ){
110
111
- #-- Create a new menu with all the children under it
112
- echo '<ul class="grandchild-sidebar-menu">';
113
-
114
- wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=3&child_of=".$pID->ID);
115
116
- echo '</ul>';
117
118
- }
119
120
-
121
- }
122
- #-- if the options above echoed the parent and therefore added another ul
123
if( $parent_toggle == TRUE ){
124
- echo '</ul>';
125
- }
126
- ?>
127
- </ul></div>
128
- <!-- end of very-custom-menu -->
129
- <?php
130
- }
131
- }
132
- ?>
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
60
61
// adds the output to the widget area on the page
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){
71
+ $parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$post->ID );
72
73
+ //--- If there is a parent of the post set $p to it and check if there is a parent as well
74
+ while($parent != FALSE){
75
+ $p = $parent;
76
+ $parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$parent);
77
+ }
78
79
+ } else {
80
+ #--------- If this is the parent ------------------------------------------------
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' ){
89
+
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
+
131
+ echo '</ul></div><!-- end of very-custom-menu -->';
132
+ }
133
+
134
+ } #== /widget()
135
+
136
+ } #== /Class
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
8
- Version: 1.4
9
10
== Description ==
11
@@ -39,11 +39,17 @@ As of version 1.1 this will automatically generate class names for each level fo
39
40
== Screenshots ==
41
42
- screenshot-1.PNG
43
44
45
== Changelog ==
46
47
= 1.4 =
48
* Removed Menu from pages with no children
49
* Added a checkbox for including menu on page with no children
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
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
50
+ * Removed the <div> completely when no menu present
51
+
52
+
53
= 1.4 =
54
* Removed Menu from pages with no children
55
* Added a checkbox for including menu on page with no children
screenshot-1.PNG CHANGED
Binary file