Advanced Sidebar Menu - Version 1.2

Version Description

  • Added support for the built in page ordering.
Download this release

Release Info

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

Version 1.2

Files changed (3) hide show
  1. advanced-sidebar-menu.php +129 -0
  2. readme.txt +64 -0
  3. screenshot-1.PNG +0 -0
advanced-sidebar-menu.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ 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.2
8
+ Author URI: http://www.vimm.com
9
+
10
+ email: mat@lipeimagination.info
11
+
12
+ */
13
+
14
+ // register FooWidget widget
15
+ add_action( 'widgets_init', create_function( '', 'return register_widget("advanced_sidebar_menu");' ) );
16
+
17
+ class advanced_sidebar_menu extends WP_Widget {
18
+
19
+ #-----------------------------------------------------------------------------------------------------------------------------------
20
+ // this creates the widget form for the dashboard
21
+ function form( $instance ) {
22
+ if ( $instance ) {
23
+ $exclude = esc_attr( $instance[ 'exclude' ] );
24
+ }
25
+ else {
26
+ $exclude = '';
27
+ }
28
+ ?>
29
+ <p>
30
+ <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e('Pages To Be Excluded From Parents. "If a page is excluded from Parents the child pages will become the parents and not be shown in this menu. Make sure to add commas between IDs e.g. 4,11,6"'); ?></label>
31
+ <input class="widefat" id="<?php echo $this->get_field_id('exclude'); ?>" name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $exclude; ?>" />
32
+ </p>
33
+ <p> Include Parent Page <input id="<?php echo $this->get_field_name('include_parent'); ?>" name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked" <?php echo $instance['include_parent']; ?>/></p>
34
+ <?php
35
+ }
36
+
37
+ #------------------------------------------------------------------------------------------------------------------------------
38
+ // this allows more than one instance
39
+
40
+ function update( $new_instance, $old_instance ) {
41
+ $instance = $old_instance;
42
+ $instance['exclude'] = strip_tags($new_instance['exclude']);
43
+ $instance['include_parent'] = strip_tags($new_instance['include_parent']);
44
+ return $instance;
45
+ }
46
+
47
+ #-------------------------------------------------------------------------------------------------------------------------
48
+
49
+ // This decides the name of the widget
50
+ function advanced_sidebar_menu( ) {
51
+ parent::WP_Widget( 'advanced_sidebar_menu', $name = 'Advanced Sidebar Menu' );
52
+ }
53
+
54
+
55
+ #---------------------------------------------------------------------------------------------------------------------------
56
+
57
+ // adds the output to the widget area on the page
58
+ function widget($args, $instance) {
59
+ ?>
60
+ <div id="<?php echo $args['widget_id']; ?>" class="advanced-sidebar-menu"><ul class="parent-sidebar-menu" >
61
+ <?php
62
+
63
+ global $wpdb;
64
+ global $p;
65
+ global $post;
66
+
67
+ if( $instance['exclude'] != '' ){
68
+ $exclude = explode( ',', $instance['exclude'] );
69
+ }
70
+
71
+
72
+ //makes the custom menu
73
+
74
+ if($post->ancestors){
75
+ $parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$post->ID );
76
+
77
+ while($parent != FALSE){
78
+ //----------------------------------- make the pages listed in the exludes menu not show ---------------------------------
79
+ if(isset($exclude)){
80
+ foreach( $exclude as $e ){
81
+ if( $parent == $e ){
82
+ $toggle = 'yes';
83
+ }
84
+ }}
85
+ if( $toggle == 'yes' ){
86
+ $toggle = '';
87
+ } else {
88
+ //--------------------------------------------------------------------------------------------------------------------
89
+ $p = $parent;
90
+ }
91
+ $parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$parent);
92
+ }
93
+
94
+ } else {
95
+ #--------- If this is the parent ------------------------------------------------
96
+ $p = $post->ID;
97
+ }
98
+
99
+ $result = $wpdb->get_results( "SELECT ID FROM wp_posts WHERE post_parent = $p AND post_type='page' Order by menu_order" );
100
+
101
+ if( $instance['include_parent'] == 'checked' ){
102
+
103
+ wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$p);
104
+ echo '<ul class="child-sidebar-menu">';
105
+ }
106
+
107
+ //=----------------------------------- makes the link list -----------------------------------------
108
+ foreach($result as $pageID){
109
+
110
+ wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pageID->ID);
111
+
112
+ if($pageID->ID == $post->ID or $pageID->ID == $post->post_parent or in_array($pageID->ID, $post->ancestors) ):
113
+ echo '<ul class="grandchild-sidebar-menu">';
114
+ wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=3&child_of=".$pageID->ID);
115
+ echo '</ul>';
116
+ endif;
117
+
118
+
119
+ }
120
+ if( $instance['include_parent'] == 'checked' ){
121
+ echo '</ul>';
122
+ }
123
+ ?>
124
+ </ul></div>
125
+ <!-- end of very-custom-menu -->
126
+ <?php
127
+ }
128
+ }
129
+ ?>
readme.txt ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: Mat Lipe
3
+ 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.2
8
+
9
+ == Description ==
10
+
11
+ Creates a widget that can be dragged into a sidebar which automatically generates a menu based on the parent/child relationship of the pages. When on a top level page it displays a menu of the all of the top level pages and a menu of all of the pages that are children of the current page. Keep the sidebar menu clean and usable.
12
+ Has a checkbox for including the top level of pages (good for sites that have 3 or more page levels) and a box to exclude pages and children of excluded page.
13
+
14
+ Creates a widget that can be dragged into a sidebar which automatically generates a menu based on the parent/child relationship of the pages. When on a top level page it displays a menu of the all of the top level pages and a menu of all of the pages that are children of the current page. Keep the sidebar menu clean and usable.
15
+ Has a checkbox for including the top level of pages (good for sites that have 3 or more page levels) and a box to exclude pages and children of excluded page.
16
+
17
+
18
+
19
+
20
+ == Installation ==
21
+
22
+ This section describes how to install the plugin and get it working.
23
+
24
+ e.g.
25
+
26
+ 1. Upload the `advanced-sidbebar-menu` folder to the `/wp-content/plugins/` directory
27
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
28
+ 1. Drag the Advanced Sidebar Menu widget into a sidebar.
29
+
30
+ == Frequently Asked Questions ==
31
+
32
+ = Does this support multiple instances? =
33
+
34
+ Yes.
35
+
36
+ = Does the menu change for each page you are on? =
37
+
38
+ Yes. Based on whatever parents and children pages you are on, the menu will change automatically.
39
+
40
+ = How does this work with styling the page? =
41
+
42
+ 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.
43
+
44
+ == Screenshots ==
45
+
46
+ 1. This screenshot shows what the widget looks like
47
+
48
+
49
+ == Changelog ==
50
+
51
+ = 1.2 =
52
+ * Added support for the built in page ordering.
53
+
54
+ = 1.1 =
55
+ * Added support for separate css classes on each level of the menu.
56
+
57
+ == Upgrade Notice ==
58
+
59
+ = 1.2 =
60
+ This Version will allow you to order the pages in the menu using the page order section of the editor.
61
+
62
+ = 1.1 =
63
+ This version will allow simlier css styling.
64
+
screenshot-1.PNG ADDED
Binary file