Version Description
- Added default syling.
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Advanced Sidebar Menu |
Version | 2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.1
- advanced-sidebar-menu.php +66 -52
- readme.txt +7 -4
- screenshot-1.PNG +0 -0
- sidebar-menu.css +39 -0
advanced-sidebar-menu.php
CHANGED
@@ -4,9 +4,9 @@ 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: 2.
|
8 |
Author URI: http://lipeimagination.info
|
9 |
-
Since: 1/
|
10 |
Email: mat@lipeimagination.info
|
11 |
|
12 |
*/
|
@@ -21,42 +21,46 @@ class advanced_sidebar_menu extends WP_Widget {
|
|
21 |
function form( $instance ) {
|
22 |
require( 'advanced-sidebar-menu.js' );
|
23 |
?>
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
<p> Include Parent Page <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
28 |
-
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
29 |
<?php echo $instance['include_parent']; ?>/></p>
|
30 |
-
|
31 |
-
|
32 |
<p> Include Parent Even With No Children<input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
33 |
-
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
34 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
35 |
-
|
36 |
-
<p>
|
|
|
|
|
|
|
|
|
37 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
38 |
-
|
39 |
-
<p> Always Display Child Pages <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
40 |
-
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
41 |
onclick="javascript:reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
42 |
<?php echo $instance['display_all']; ?>/></p>
|
43 |
-
|
44 |
-
<span id="levels-<?php echo $this->get_field_name('levels'); ?>" style="<?php
|
45 |
if( $instance['display_all'] == checked ){
|
46 |
echo 'display:block';
|
47 |
} else {
|
48 |
echo 'display:none';
|
49 |
-
} ?>">
|
50 |
-
<p> Levels to Display <select id="<?php echo $this->get_field_name('levels'); ?>"
|
51 |
name="<?php echo $this->get_field_name('levels'); ?>">
|
52 |
-
<?php
|
53 |
for( $i= 1; $i<6; $i++ ){
|
54 |
if( $i == $instance['levels'] ){
|
55 |
echo '<option value="'.$i.'" selected>'.$i.'</option>';
|
56 |
} else {
|
57 |
echo '<option value="'.$i.'">'.$i.'</option>';
|
58 |
}
|
59 |
-
}
|
60 |
echo '</select></p></span>';
|
61 |
}
|
62 |
|
@@ -70,6 +74,7 @@ class advanced_sidebar_menu extends WP_Widget {
|
|
70 |
$instance['exclude'] = strip_tags($new_instance['exclude']);
|
71 |
$instance['display_all'] = strip_tags($new_instance['display_all']);
|
72 |
$instance['levels'] = strip_tags($new_instance['levels']);
|
|
|
73 |
return $instance;
|
74 |
}
|
75 |
|
@@ -93,101 +98,110 @@ class advanced_sidebar_menu extends WP_Widget {
|
|
93 |
global $wpdb;
|
94 |
global $p;
|
95 |
global $post;
|
96 |
-
|
97 |
#-- Create a usable array of the excluded pages
|
98 |
$exclude = explode(',', $instance['exclude']);
|
99 |
-
|
100 |
-
|
101 |
#-- if the post has parrents
|
102 |
if($post->ancestors){
|
103 |
-
|
104 |
$parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$post->ID );
|
105 |
-
|
106 |
//--- If there is a parent of the post set $p to it and check if there is a parent as well
|
107 |
while($parent != FALSE){
|
108 |
$p = $parent;
|
109 |
$parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$parent);
|
110 |
}
|
111 |
-
|
112 |
} else {
|
113 |
#--------- If this is the parent ------------------------------------------------
|
114 |
$p = $post->ID;
|
115 |
}
|
116 |
-
|
117 |
#-- Makes this work with all table prefixes
|
118 |
#-- Added 1/22/12
|
119 |
global $table_prefix;
|
120 |
-
|
121 |
|
122 |
$result = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = $p AND post_type='page' Order by menu_order" );
|
123 |
-
|
124 |
#---- if there are no children do not display the parent unless it is check to do so
|
125 |
if($result != false || $instance['include_childless_parent'] == 'checked' ){
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
128 |
echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget">';
|
129 |
-
|
130 |
-
|
131 |
#-- if the checkbox to include parent is checked
|
132 |
if( $instance['include_parent'] == 'checked' ){
|
|
|
|
|
133 |
$parent_toggle = TRUE;
|
134 |
-
|
135 |
-
#-- If the page is not excluded from the menu
|
136 |
-
if( !in_array($p, $exclude) ){
|
137 |
#-- list the parent page
|
138 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$p);
|
139 |
}
|
140 |
-
|
141 |
}
|
142 |
}
|
143 |
|
144 |
//=----------------------------------- makes the Child Pages list -----------------------------------------
|
145 |
-
|
146 |
//If there are children start the Child Sidebar Menu
|
147 |
if( $result != FALSE ){
|
148 |
echo '<ul class="child-sidebar-menu">';
|
149 |
-
|
150 |
#-- If they want all the pages displayed always
|
151 |
if( $instance['display_all'] == 'checked' ){
|
152 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&child_of=".$p."&depth=".$instance['levels']."&exclude=".$instance['exclude']);
|
153 |
} else {
|
154 |
-
|
155 |
#-- Display children of current page's parent only
|
156 |
foreach($result as $pID){
|
157 |
-
|
158 |
#-- If the page is not in the excluded ones
|
159 |
if( !in_array($pID->ID, $exclude) ){
|
160 |
#--echo the current page from the $result
|
161 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
|
162 |
}
|
163 |
-
|
164 |
#-- if the link that was just listed is the current page we are on
|
165 |
if($pID->ID == $post->ID or $pID->ID == $post->post_parent or @in_array($pID->ID, $post->ancestors) ){
|
166 |
-
|
167 |
$kids = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID->ID." AND post_type='page' " );
|
168 |
if( $kids != FALSE ){
|
169 |
-
|
170 |
#-- Create a new menu with all the children under it
|
171 |
echo '<ul class="grandchild-sidebar-menu">';
|
172 |
|
173 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&exclude=".$instance['exclude']."&depth=3&child_of=".$pID->ID);
|
174 |
-
|
175 |
echo '</ul>';
|
176 |
}
|
177 |
}
|
178 |
}
|
179 |
}
|
180 |
-
|
181 |
#-- Close the First Level menu
|
182 |
echo '</ul><!-- End child-sidebar-menu -->';
|
183 |
-
|
184 |
}
|
185 |
#-- If there was a menu close it off
|
186 |
if($result != false || $instance['include_childless_parent'] == 'checked' ){
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
189 |
}
|
190 |
-
|
191 |
} #== /widget()
|
192 |
-
|
193 |
} #== /Class
|
4 |
Plugin URI: http://lipeimagination.info
|
5 |
Description: Creates dynamic menu based on child/parent relationship.
|
6 |
Author: Mat Lipe
|
7 |
+
Version: 2.1
|
8 |
Author URI: http://lipeimagination.info
|
9 |
+
Since: 1/26/12
|
10 |
Email: mat@lipeimagination.info
|
11 |
|
12 |
*/
|
21 |
function form( $instance ) {
|
22 |
require( 'advanced-sidebar-menu.js' );
|
23 |
?>
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
<p> Include Parent Page <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
28 |
+
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
29 |
<?php echo $instance['include_parent']; ?>/></p>
|
30 |
+
|
31 |
+
|
32 |
<p> Include Parent Even With No Children<input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
33 |
+
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
34 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
35 |
+
|
36 |
+
<p> Use Built in Styling <input id="<?php echo $this->get_field_name('css'); ?>"
|
37 |
+
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
38 |
+
<?php echo $instance['css']; ?>/></p>
|
39 |
+
|
40 |
+
<p> Pages to Exclude, Comma Separated:<input id="<?php echo $this->get_field_name('exclude'); ?>"
|
41 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
42 |
+
|
43 |
+
<p> Always Display Child Pages <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
44 |
+
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
45 |
onclick="javascript:reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
46 |
<?php echo $instance['display_all']; ?>/></p>
|
47 |
+
|
48 |
+
<span id="levels-<?php echo $this->get_field_name('levels'); ?>" style="<?php
|
49 |
if( $instance['display_all'] == checked ){
|
50 |
echo 'display:block';
|
51 |
} else {
|
52 |
echo 'display:none';
|
53 |
+
} ?>">
|
54 |
+
<p> Levels to Display <select id="<?php echo $this->get_field_name('levels'); ?>"
|
55 |
name="<?php echo $this->get_field_name('levels'); ?>">
|
56 |
+
<?php
|
57 |
for( $i= 1; $i<6; $i++ ){
|
58 |
if( $i == $instance['levels'] ){
|
59 |
echo '<option value="'.$i.'" selected>'.$i.'</option>';
|
60 |
} else {
|
61 |
echo '<option value="'.$i.'">'.$i.'</option>';
|
62 |
}
|
63 |
+
}
|
64 |
echo '</select></p></span>';
|
65 |
}
|
66 |
|
74 |
$instance['exclude'] = strip_tags($new_instance['exclude']);
|
75 |
$instance['display_all'] = strip_tags($new_instance['display_all']);
|
76 |
$instance['levels'] = strip_tags($new_instance['levels']);
|
77 |
+
$instance['css'] = strip_tags($new_instance['css']);
|
78 |
return $instance;
|
79 |
}
|
80 |
|
98 |
global $wpdb;
|
99 |
global $p;
|
100 |
global $post;
|
101 |
+
|
102 |
#-- Create a usable array of the excluded pages
|
103 |
$exclude = explode(',', $instance['exclude']);
|
104 |
+
|
105 |
+
|
106 |
#-- if the post has parrents
|
107 |
if($post->ancestors){
|
108 |
+
|
109 |
$parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$post->ID );
|
110 |
+
|
111 |
//--- If there is a parent of the post set $p to it and check if there is a parent as well
|
112 |
while($parent != FALSE){
|
113 |
$p = $parent;
|
114 |
$parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$parent);
|
115 |
}
|
116 |
+
|
117 |
} else {
|
118 |
#--------- If this is the parent ------------------------------------------------
|
119 |
$p = $post->ID;
|
120 |
}
|
121 |
+
|
122 |
#-- Makes this work with all table prefixes
|
123 |
#-- Added 1/22/12
|
124 |
global $table_prefix;
|
125 |
+
|
126 |
|
127 |
$result = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = $p AND post_type='page' Order by menu_order" );
|
128 |
+
|
129 |
#---- if there are no children do not display the parent unless it is check to do so
|
130 |
if($result != false || $instance['include_childless_parent'] == 'checked' ){
|
131 |
+
|
132 |
+
if( $instance['css'] == 'checked' ){
|
133 |
+
include( plugin_dir_path(__FILE__).'sidebar-menu.css' );
|
134 |
+
}
|
135 |
+
|
136 |
+
//Start the menu
|
137 |
echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget">';
|
138 |
+
|
139 |
+
|
140 |
#-- if the checkbox to include parent is checked
|
141 |
if( $instance['include_parent'] == 'checked' ){
|
142 |
+
echo '<ul class="parent-sidebar-menu" >';
|
143 |
+
|
144 |
$parent_toggle = TRUE;
|
145 |
+
|
146 |
+
#-- If the page is not excluded from the menu
|
147 |
+
if( !in_array($p, $exclude) ){
|
148 |
#-- list the parent page
|
149 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$p);
|
150 |
}
|
151 |
+
|
152 |
}
|
153 |
}
|
154 |
|
155 |
//=----------------------------------- makes the Child Pages list -----------------------------------------
|
156 |
+
|
157 |
//If there are children start the Child Sidebar Menu
|
158 |
if( $result != FALSE ){
|
159 |
echo '<ul class="child-sidebar-menu">';
|
160 |
+
|
161 |
#-- If they want all the pages displayed always
|
162 |
if( $instance['display_all'] == 'checked' ){
|
163 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&child_of=".$p."&depth=".$instance['levels']."&exclude=".$instance['exclude']);
|
164 |
} else {
|
165 |
+
|
166 |
#-- Display children of current page's parent only
|
167 |
foreach($result as $pID){
|
168 |
+
|
169 |
#-- If the page is not in the excluded ones
|
170 |
if( !in_array($pID->ID, $exclude) ){
|
171 |
#--echo the current page from the $result
|
172 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
|
173 |
}
|
174 |
+
|
175 |
#-- if the link that was just listed is the current page we are on
|
176 |
if($pID->ID == $post->ID or $pID->ID == $post->post_parent or @in_array($pID->ID, $post->ancestors) ){
|
177 |
+
|
178 |
$kids = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID->ID." AND post_type='page' " );
|
179 |
if( $kids != FALSE ){
|
180 |
+
|
181 |
#-- Create a new menu with all the children under it
|
182 |
echo '<ul class="grandchild-sidebar-menu">';
|
183 |
|
184 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&exclude=".$instance['exclude']."&depth=3&child_of=".$pID->ID);
|
185 |
+
|
186 |
echo '</ul>';
|
187 |
}
|
188 |
}
|
189 |
}
|
190 |
}
|
191 |
+
|
192 |
#-- Close the First Level menu
|
193 |
echo '</ul><!-- End child-sidebar-menu -->';
|
194 |
+
|
195 |
}
|
196 |
#-- If there was a menu close it off
|
197 |
if($result != false || $instance['include_childless_parent'] == 'checked' ){
|
198 |
+
|
199 |
+
if( $instance['include_parent'] == 'checked' ) {
|
200 |
+
echo '<ul>';
|
201 |
+
}
|
202 |
+
echo '</div><!-- end of very-custom-menu -->';
|
203 |
}
|
204 |
+
|
205 |
} #== /widget()
|
206 |
+
|
207 |
} #== /Class
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ 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.
|
7 |
-
Stable tag: 2.
|
8 |
-
Version: 2.
|
9 |
|
10 |
== Description ==
|
11 |
|
@@ -48,6 +48,9 @@ You may want to use something like margins to set the levels apart.
|
|
48 |
|
49 |
== Changelog ==
|
50 |
|
|
|
|
|
|
|
51 |
= 2.0 =
|
52 |
* Brought back the ability to exclude pages with support for excluding single pages from the menu.
|
53 |
* Added the ability to display all levels of child pages always.
|
@@ -79,7 +82,7 @@ You may want to use something like margins to set the levels apart.
|
|
79 |
|
80 |
|
81 |
== Screenshots ==
|
82 |
-
1. The widget Menu as of 2.0
|
83 |
|
84 |
== Upgrade Notice ==
|
85 |
|
3 |
Donate link: http://lipeimagination.info/contact/
|
4 |
Tags: menus, sidebar menu, heirchy
|
5 |
Requires at least: 3.1
|
6 |
+
Tested up to: 3.3.1
|
7 |
+
Stable tag: 2.1
|
8 |
+
Version: 2.1
|
9 |
|
10 |
== Description ==
|
11 |
|
48 |
|
49 |
== Changelog ==
|
50 |
|
51 |
+
= 2.1 =
|
52 |
+
* Added default syling.
|
53 |
+
|
54 |
= 2.0 =
|
55 |
* Brought back the ability to exclude pages with support for excluding single pages from the menu.
|
56 |
* Added the ability to display all levels of child pages always.
|
82 |
|
83 |
|
84 |
== Screenshots ==
|
85 |
+
1. The widget Menu as of 2.0.
|
86 |
|
87 |
== Upgrade Notice ==
|
88 |
|
screenshot-1.PNG
CHANGED
Binary file
|
sidebar-menu.css
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<style type="text/css" >
|
2 |
+
|
3 |
+
.advanced-sidebar-menu ul li a{
|
4 |
+
font-weight: bold;
|
5 |
+
font-size: 130%;
|
6 |
+
text-decoration: none;
|
7 |
+
}
|
8 |
+
|
9 |
+
.advanced-sidebar-menu ul li a:hover{
|
10 |
+
text-decoration: underline;
|
11 |
+
}
|
12 |
+
|
13 |
+
.advanced-sidebar-menu ul ul li a{
|
14 |
+
font-weight: normal;
|
15 |
+
font-size: 100%;
|
16 |
+
}
|
17 |
+
|
18 |
+
.advanced-sidebar-menu ul{
|
19 |
+
margin: 0 0 0 18px;
|
20 |
+
list-style: none;
|
21 |
+
list-style-type: none;
|
22 |
+
}
|
23 |
+
|
24 |
+
.advanced-sidebar-menu ul li{
|
25 |
+
list-style:none;
|
26 |
+
list-style-type: none;
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
.advanced-sidebar-menu li.current_page_item{
|
31 |
+
list-style-type: disc;
|
32 |
+
}
|
33 |
+
|
34 |
+
.advanced-sidebar-menu li.current_page_item a{
|
35 |
+
font-weight: bold;
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
</style>
|