Version Description
- Added a categories menu widget with the same functionality as the pages widget
- Added the ability to edit "views" files through your child theme to edit output and css
- Cleanedup the output
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Advanced Sidebar Menu |
Version | 3.0 |
Comparing to | |
See all releases |
Code changes from version 2.1 to 3.0
- advanced-sidebar-menu.php +10 -184
- functions.php +25 -0
- readme.txt +26 -6
- views/category_list.php +77 -0
- views/page_list.php +92 -0
- views/sidebar-menu.css +34 -0
- widgets/category.widget.php +142 -0
- widgets/init.php +24 -0
- widgets/page.widget.php +149 -0
advanced-sidebar-menu.php
CHANGED
@@ -4,204 +4,30 @@ 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:
|
8 |
Author URI: http://lipeimagination.info
|
9 |
-
Since:
|
10 |
Email: mat@lipeimagination.info
|
11 |
|
12 |
*/
|
13 |
|
14 |
-
#-- Register the 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 |
-
|
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 |
|
67 |
-
#------------------------------------------------------------------------------------------------------------------------------
|
68 |
-
// this allows more than one instance
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
$instance['include_childless_parent'] = strip_tags($new_instance['include_childless_parent']);
|
73 |
-
$instance['include_parent'] = strip_tags($new_instance['include_parent']);
|
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 |
|
81 |
-
#-------------------------------------------------------------------------------------------------------------------------
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
|
88 |
|
89 |
-
/* Create the widget. */
|
90 |
-
$this->WP_Widget( 'advanced_sidebar_menu', 'Sidebar Menu', $widget_ops, $control_ops );
|
91 |
-
}
|
92 |
|
93 |
|
94 |
-
#---------------------------------------------------------------------------------------------------------------------------
|
95 |
|
96 |
-
// adds the output to the widget area on the page
|
97 |
-
function widget($args, $instance) {
|
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
|
4 |
Plugin URI: http://lipeimagination.info
|
5 |
Description: Creates dynamic menu based on child/parent relationship.
|
6 |
Author: Mat Lipe
|
7 |
+
Version: 3.0
|
8 |
Author URI: http://lipeimagination.info
|
9 |
+
Since: 4/13/12
|
10 |
Email: mat@lipeimagination.info
|
11 |
|
12 |
*/
|
13 |
|
|
|
|
|
14 |
|
|
|
15 |
|
16 |
+
#-- Bring in the functions
|
17 |
+
require( 'functions.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
|
|
|
|
19 |
|
20 |
+
#-- Bring in the Widgets
|
21 |
+
require( 'widgets/init.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
|
|
23 |
|
24 |
+
#-- Define Constants
|
25 |
+
define( 'ADVANCED_SIDEBAR_WIDGETS_DIR', plugin_dir_path(__FILE__) . 'widgets/' );
|
26 |
+
define( 'ADVANCED_SIDEBAR_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
27 |
+
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path(__FILE__) );
|
28 |
|
29 |
|
|
|
|
|
|
|
30 |
|
31 |
|
|
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
functions.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* These Functions are Specific to the Advanced Sidebar Menu
|
6 |
+
* @author Mat Lipe
|
7 |
+
* @since 4/13/12
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Allows for Overwritting files in the child theme
|
13 |
+
* @since 4/13/12
|
14 |
+
*/
|
15 |
+
|
16 |
+
function advanced_sidebar_menu_file_hyercy( $file ){
|
17 |
+
|
18 |
+
if ( $theme_file = locate_template(array('advanced-sidebar-menu/'.$file)) ) {
|
19 |
+
$file = $theme_file;
|
20 |
+
} else {
|
21 |
+
$file = ADVANCED_SIDEBAR_VIEWS_DIR . $file;
|
22 |
+
}
|
23 |
+
return $file;
|
24 |
+
|
25 |
+
}
|
readme.txt
CHANGED
@@ -1,21 +1,24 @@
|
|
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.3.1
|
7 |
-
Stable tag:
|
8 |
-
Version:
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
Creates a widget that
|
13 |
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
|
14 |
are children of the current page. Keeps the sidebar menu clean and usable.
|
15 |
|
|
|
|
|
16 |
Has the ability to exclude page from the menu.
|
17 |
As of 2.0 it also allows for display of all the child pages always.
|
18 |
-
You may also select the level of pages to display with this option
|
|
|
19 |
|
20 |
|
21 |
|
@@ -27,10 +30,17 @@ e.g.
|
|
27 |
|
28 |
1. Upload the `advanced-sidbebar-menu` folder to the `/wp-content/plugins/` directory
|
29 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
30 |
-
1. Drag the Sidebar Menu widget into a sidebar.
|
31 |
|
32 |
== Frequently Asked Questions ==
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
= Does this support multiple instances? =
|
35 |
|
36 |
Yes.
|
@@ -48,6 +58,11 @@ You may want to use something like margins to set the levels apart.
|
|
48 |
|
49 |
== Changelog ==
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
= 2.1 =
|
52 |
* Added default syling.
|
53 |
|
@@ -86,6 +101,11 @@ You may want to use something like margins to set the levels apart.
|
|
86 |
|
87 |
== Upgrade Notice ==
|
88 |
|
|
|
|
|
|
|
|
|
|
|
89 |
= 2.0 =
|
90 |
This Version will give you better control over the menu and styling ability.
|
91 |
Added new options and more stable code.
|
1 |
=== Plugin Name ===
|
2 |
Contributors: Mat Lipe
|
3 |
Donate link: http://lipeimagination.info/contact/
|
4 |
+
Tags: menus, sidebar menu, heirchy, category menu, pages menu
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.3.1
|
7 |
+
Stable tag: 3.0
|
8 |
+
Version: 3.0
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
Creates a widget that automatically generates a menu based on the parent/child relationship of pages.
|
13 |
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
|
14 |
are children of the current page. Keeps the sidebar menu clean and usable.
|
15 |
|
16 |
+
As of Version 3.0 it also creates a widget that does the same functionality for Categories as well.
|
17 |
+
|
18 |
Has the ability to exclude page from the menu.
|
19 |
As of 2.0 it also allows for display of all the child pages always.
|
20 |
+
You may also select the level of pages to display with this option.
|
21 |
+
|
22 |
|
23 |
|
24 |
|
30 |
|
31 |
1. Upload the `advanced-sidbebar-menu` folder to the `/wp-content/plugins/` directory
|
32 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
33 |
+
1. Drag the "Advanced Sidebar Pages Menu" widget Or the "Advanced Sidebar Categories Menu" widget into a sidebar.
|
34 |
|
35 |
== Frequently Asked Questions ==
|
36 |
|
37 |
+
= How do you edit the output or built in css? =
|
38 |
+
|
39 |
+
Create a folder in your child theme named "advanced-sidebar-menu" copy any of the files from the "views" folder into
|
40 |
+
the folder you just created. You may edit the files at will to change the output or css?
|
41 |
+
You must have the option checked to use the built in CSS (in the widget) to be able to edit the css file in this way.
|
42 |
+
The Others will work always.
|
43 |
+
|
44 |
= Does this support multiple instances? =
|
45 |
|
46 |
Yes.
|
58 |
|
59 |
== Changelog ==
|
60 |
|
61 |
+
= 3.0 =
|
62 |
+
* Added a categories menu widget with the same functionality as the pages widget
|
63 |
+
* Added the ability to edit "views" files through your child theme to edit output and css
|
64 |
+
* Cleanedup the output
|
65 |
+
|
66 |
= 2.1 =
|
67 |
* Added default syling.
|
68 |
|
101 |
|
102 |
== Upgrade Notice ==
|
103 |
|
104 |
+
= 3.0 =
|
105 |
+
This Version will add a widget for displaying categories as well,
|
106 |
+
better functionality, a cleaner output, and the ability to customize the output/css
|
107 |
+
through your child theme.
|
108 |
+
|
109 |
= 2.0 =
|
110 |
This Version will give you better control over the menu and styling ability.
|
111 |
Added new options and more stable code.
|
views/category_list.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The Ouput of tad Advanced Sidebar Categories Widget
|
5 |
+
* @author Mat Lipe
|
6 |
+
* @since 4/13/12
|
7 |
+
*
|
8 |
+
*
|
9 |
+
* @uses to edit create a file named category_list.php and put in a folder in the your child theme called 'advanced-sidebar-menu
|
10 |
+
* @uses copy the contents of the file into that file and edit at will
|
11 |
+
* @param Do not edit this file or it will break on upgrade
|
12 |
+
*/
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget advanced-sidebar-category">
|
17 |
+
<div class="widget-wrap">';
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
#-- if the checkbox to include parent is checked
|
22 |
+
if( $instance['include_parent'] == 'checked' && !in_array($top_cat, $exclude) ){
|
23 |
+
|
24 |
+
echo '<ul class="parent-sidebar-menu">';
|
25 |
+
wp_list_categories( 'title_li=&include=' . $top_cat);
|
26 |
+
|
27 |
+
$parent = true;
|
28 |
+
}
|
29 |
+
|
30 |
+
if( !empty($all) ){
|
31 |
+
|
32 |
+
echo '<ul class="child-sidebar-menu">';
|
33 |
+
|
34 |
+
#-- If they want all the child categories displayed always
|
35 |
+
if( $instance['display_all'] == 'checked' ){
|
36 |
+
wp_list_categories('title_li=&child_of=' . $top_cat .'&depth=' .$instance['levels'] );
|
37 |
+
echo '</ul><!-- End #child-sidebar-menu -->';
|
38 |
+
} else {
|
39 |
+
|
40 |
+
foreach( $all as $child_cat ){
|
41 |
+
|
42 |
+
if( !in_array($child_cat->cat_ID, $exclude) && $child_cat->parent == $top_cat){
|
43 |
+
|
44 |
+
//List the child category and the children if it is the current one
|
45 |
+
wp_list_categories('title_li=&include=' . $child_cat->cat_ID . '&depth=1' );
|
46 |
+
|
47 |
+
if( $child_cat->cat_ID == get_query_var('cat' ) || in_array( $child_cat->cat_ID, $cat_ancestors ) ){
|
48 |
+
|
49 |
+
$all_children = array();
|
50 |
+
$all_children = get_categories( array( 'child_of' => $child_cat->cat_ID ) );
|
51 |
+
|
52 |
+
if( !empty( $all_children ) ){
|
53 |
+
#-- Create a new menu with all the children under it
|
54 |
+
echo '<ul class="grandchild-sidebar-menu">';
|
55 |
+
|
56 |
+
wp_list_categories("title_li=&exclude=".$instance['exclude']."&depth=3&child_of=" .$child_cat->cat_ID );
|
57 |
+
|
58 |
+
echo '</ul>';
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
} //End foreach
|
63 |
+
|
64 |
+
echo '</ul><!-- End #child-sidebar-menu -->';
|
65 |
+
|
66 |
+
} //End if display all is not checked
|
67 |
+
|
68 |
+
#-- if a parent category was displayed
|
69 |
+
if( isset($parent) ){
|
70 |
+
echo '</ul><!-- End #parent-sidebar-menu -->';
|
71 |
+
}
|
72 |
+
|
73 |
+
} //End if the are child categories
|
74 |
+
|
75 |
+
//End the Widget Area
|
76 |
+
echo '</div></div><!-- END #advanced-sidebar-cat-menu -->';
|
77 |
+
|
views/page_list.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
/**
|
6 |
+
* The Ouput of tad Advanced Sidebar Page Widget
|
7 |
+
* @author Mat Lipe
|
8 |
+
* @since 4/13/12
|
9 |
+
*
|
10 |
+
*
|
11 |
+
* @uses to edit create a file named page_list.php and put in a folder in the your child theme called 'advanced-sidebar-menu
|
12 |
+
* @uses copy the contents of the file into that file and edit at will
|
13 |
+
* @param Do not edit this file or it will break on upgrade
|
14 |
+
*/
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
//Start the menu
|
22 |
+
echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget advanced-sidebar-page">
|
23 |
+
<div class="widget-wrap">';
|
24 |
+
|
25 |
+
|
26 |
+
#-- if the checkbox to include parent is checked
|
27 |
+
if( $instance['include_parent'] == 'checked' ){
|
28 |
+
echo '<ul class="parent-sidebar-menu" >';
|
29 |
+
|
30 |
+
$parent_toggle = TRUE;
|
31 |
+
|
32 |
+
#-- If the page is not excluded from the menu
|
33 |
+
if( !in_array($p, $exclude) ){
|
34 |
+
#-- list the parent page
|
35 |
+
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$p);
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
//If there are children start the Child Sidebar Menu
|
44 |
+
if( $result != FALSE ){
|
45 |
+
echo '<ul class="child-sidebar-menu">';
|
46 |
+
|
47 |
+
#-- If they want all the pages displayed always
|
48 |
+
if( $instance['display_all'] == 'checked' ){
|
49 |
+
wp_list_pages("sort_column=menu_order&title_li=&echo=1&child_of=".$p."&depth=".$instance['levels']."&exclude=".$instance['exclude']);
|
50 |
+
} else {
|
51 |
+
|
52 |
+
#-- Display children of current page's parent only
|
53 |
+
foreach($result as $pID){
|
54 |
+
|
55 |
+
#-- If the page is not in the excluded ones
|
56 |
+
if( !in_array($pID->ID, $exclude) ){
|
57 |
+
#--echo the current page from the $result
|
58 |
+
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
|
59 |
+
}
|
60 |
+
|
61 |
+
#-- if the link that was just listed is the current page we are on
|
62 |
+
if($pID->ID == $post->ID or $pID->ID == $post->post_parent or @in_array($pID->ID, $post->ancestors) ){
|
63 |
+
|
64 |
+
$kids = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID->ID." AND post_type='page' " );
|
65 |
+
if( $kids != FALSE ){
|
66 |
+
|
67 |
+
#-- Create a new menu with all the children under it
|
68 |
+
echo '<ul class="grandchild-sidebar-menu">';
|
69 |
+
|
70 |
+
wp_list_pages("sort_column=menu_order&title_li=&echo=1&exclude=".$instance['exclude']."&depth=3&child_of=".$pID->ID);
|
71 |
+
|
72 |
+
echo '</ul>';
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
#-- Close the First Level menu
|
79 |
+
echo '</ul><!-- End child-sidebar-menu -->';
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
#-- If there was a menu close it off
|
85 |
+
if($result != false || $instance['include_childless_parent'] == 'checked' ){
|
86 |
+
|
87 |
+
if( $instance['include_parent'] == 'checked' ) {
|
88 |
+
echo '<ul>';
|
89 |
+
}
|
90 |
+
echo '</div></div><!-- end of very-custom-menu -->';
|
91 |
+
}
|
92 |
+
|
views/sidebar-menu.css
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.advanced-sidebar-menu ul li a{
|
2 |
+
font-weight: bold;
|
3 |
+
font-size: 130%;
|
4 |
+
text-decoration: none;
|
5 |
+
}
|
6 |
+
|
7 |
+
.advanced-sidebar-menu ul li a:hover{
|
8 |
+
text-decoration: underline;
|
9 |
+
}
|
10 |
+
|
11 |
+
.advanced-sidebar-menu ul ul li a{
|
12 |
+
font-weight: normal;
|
13 |
+
font-size: 100%;
|
14 |
+
}
|
15 |
+
|
16 |
+
.advanced-sidebar-menu ul{
|
17 |
+
margin: 0 0 0 18px;
|
18 |
+
list-style: none;
|
19 |
+
list-style-type: none;
|
20 |
+
}
|
21 |
+
|
22 |
+
.advanced-sidebar-menu ul li{
|
23 |
+
list-style:none;
|
24 |
+
list-style-type: none;
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
.advanced-sidebar-menu li.current_page_item{
|
29 |
+
list-style-type: disc;
|
30 |
+
}
|
31 |
+
|
32 |
+
.advanced-sidebar-menu li.current_page_item a{
|
33 |
+
font-weight: bold;
|
34 |
+
}
|
widgets/category.widget.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Creates a Widget of parent Child Categories
|
6 |
+
*
|
7 |
+
* @author mat lipe
|
8 |
+
* @since 4/13/12
|
9 |
+
* @package Advanced Sidebar Menu
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
class advanced_sidebar_menu_category extends WP_Widget {
|
17 |
+
|
18 |
+
#-----------------------------------------------------------------------------------------------------------------------------------
|
19 |
+
// this creates the widget form for the dashboard
|
20 |
+
function form( $instance ) {
|
21 |
+
require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
22 |
+
?>
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
<p> Include Parent Category <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
27 |
+
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
28 |
+
<?php echo $instance['include_parent']; ?>/></p>
|
29 |
+
|
30 |
+
|
31 |
+
<p> Include Parent Even With No Children<input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
32 |
+
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
33 |
+
<?php echo $instance['include_childless_parent']; ?>/></p>
|
34 |
+
|
35 |
+
<p> Use Built in Styling <input id="<?php echo $this->get_field_name('css'); ?>"
|
36 |
+
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
37 |
+
<?php echo $instance['css']; ?>/></p>
|
38 |
+
|
39 |
+
<p> Categories to Exclude, Comma Separated:<input id="<?php echo $this->get_field_name('exclude'); ?>"
|
40 |
+
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
41 |
+
|
42 |
+
<p> Always Display Child Categories <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
43 |
+
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
44 |
+
onclick="javascript:reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
45 |
+
<?php echo $instance['display_all']; ?>/></p>
|
46 |
+
|
47 |
+
<span id="levels-<?php echo $this->get_field_name('levels'); ?>" style="<?php
|
48 |
+
if( $instance['display_all'] == checked ){
|
49 |
+
echo 'display:block';
|
50 |
+
} else {
|
51 |
+
echo 'display:none';
|
52 |
+
} ?>">
|
53 |
+
<p> Levels to Display <select id="<?php echo $this->get_field_name('levels'); ?>"
|
54 |
+
name="<?php echo $this->get_field_name('levels'); ?>">
|
55 |
+
<?php
|
56 |
+
for( $i= 1; $i<6; $i++ ){
|
57 |
+
if( $i == $instance['levels'] ){
|
58 |
+
echo '<option value="'.$i.'" selected>'.$i.'</option>';
|
59 |
+
} else {
|
60 |
+
echo '<option value="'.$i.'">'.$i.'</option>';
|
61 |
+
}
|
62 |
+
}
|
63 |
+
echo '</select></p></span>';
|
64 |
+
}
|
65 |
+
|
66 |
+
#------------------------------------------------------------------------------------------------------------------------------
|
67 |
+
// this allows more than one instance
|
68 |
+
|
69 |
+
function update( $new_instance, $old_instance ) {
|
70 |
+
$instance = $old_instance;
|
71 |
+
$instance['include_childless_parent'] = strip_tags($new_instance['include_childless_parent']);
|
72 |
+
$instance['include_parent'] = strip_tags($new_instance['include_parent']);
|
73 |
+
$instance['exclude'] = strip_tags($new_instance['exclude']);
|
74 |
+
$instance['display_all'] = strip_tags($new_instance['display_all']);
|
75 |
+
$instance['levels'] = strip_tags($new_instance['levels']);
|
76 |
+
$instance['css'] = strip_tags($new_instance['css']);
|
77 |
+
return $instance;
|
78 |
+
}
|
79 |
+
|
80 |
+
#-------------------------------------------------------------------------------------------------------------------------
|
81 |
+
|
82 |
+
// This decides the name of the widget
|
83 |
+
function advanced_sidebar_menu_category( ) {
|
84 |
+
/* Widget settings. */
|
85 |
+
$widget_ops = array( 'classname' => 'sidebar-menu-category', 'description' => 'Creates a menu of all the Categories using the child/parent relationship' );
|
86 |
+
|
87 |
+
|
88 |
+
/* Create the widget. */
|
89 |
+
$this->WP_Widget( 'advanced_sidebar_menu_category', 'Advanced Sidebar Categories Menu', $widget_ops, $control_ops );
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
#---------------------------------------------------------------------------------------------------------------------------
|
94 |
+
|
95 |
+
// adds the output to the widget area on the page
|
96 |
+
function widget($args, $instance) {
|
97 |
+
if( is_category() ){
|
98 |
+
|
99 |
+
|
100 |
+
#-- Create a usable array of the excluded pages
|
101 |
+
$exclude = explode(',', $instance['exclude']);
|
102 |
+
|
103 |
+
$cat_id = get_query_var('cat' );
|
104 |
+
$cat_ancestors = array ();
|
105 |
+
$cat_ancestors[] = $cat_id ;
|
106 |
+
|
107 |
+
do {
|
108 |
+
$cat_id = get_category($cat_id );
|
109 |
+
$cat_id = $cat_id->parent;
|
110 |
+
$cat_ancestors[] = $cat_id ; }
|
111 |
+
while ($cat_id );
|
112 |
+
|
113 |
+
|
114 |
+
$cat_ancestors = array_reverse( $cat_ancestors );
|
115 |
+
$top_cat = $cat_ancestors [1];
|
116 |
+
|
117 |
+
//Check for children
|
118 |
+
$all = get_categories( array( 'child_of' => $top_cat ) );
|
119 |
+
|
120 |
+
|
121 |
+
//If there are any child categories or the include childless parent is checked
|
122 |
+
if( !empty($all ) || ($instance['include_childless_parent'] == 'checked' && !in_array($top_cat, $exclude)) ){
|
123 |
+
|
124 |
+
//Start the menu
|
125 |
+
if( $instance['css'] == 'checked' ){
|
126 |
+
echo '<style type="text/css">';
|
127 |
+
include( advanced_sidebar_menu_file_hyercy( 'sidebar-menu.css' ) );
|
128 |
+
echo '</style>';
|
129 |
+
}
|
130 |
+
|
131 |
+
#!! Bring in the output from either the child theme or this folder
|
132 |
+
require( advanced_sidebar_menu_file_hyercy( 'category_list.php' ) );
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
} //End if any children or include childless parent
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
} #== /widget()
|
141 |
+
|
142 |
+
} #== /Clas
|
widgets/init.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Registers the widgets
|
5 |
+
* @author Mat Lipe
|
6 |
+
* @since 4/13/12
|
7 |
+
* @package Advanced Sidebar Menu
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
//The list of widgets
|
12 |
+
|
13 |
+
require( 'page.widget.php' );
|
14 |
+
require( 'category.widget.php' );
|
15 |
+
|
16 |
+
add_action( 'widgets_init', 'advanced_sidebar_menu_widgets' );
|
17 |
+
|
18 |
+
function advanced_sidebar_menu_widgets(){
|
19 |
+
|
20 |
+
register_widget( "advanced_sidebar_menu_page" );
|
21 |
+
register_widget( "advanced_sidebar_menu_category" );
|
22 |
+
|
23 |
+
}
|
24 |
+
|
widgets/page.widget.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Creates a Widget of parent Child Pages
|
6 |
+
*
|
7 |
+
* @author mat lipe
|
8 |
+
* @since 4/13/12
|
9 |
+
* @package Advanced Sidebar Menu
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class advanced_sidebar_menu_page extends WP_Widget {
|
15 |
+
|
16 |
+
#-----------------------------------------------------------------------------------------------------------------------------------
|
17 |
+
// this creates the widget form for the dashboard
|
18 |
+
function form( $instance ) {
|
19 |
+
require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
20 |
+
?>
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
<p> Include Parent Page <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
25 |
+
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
26 |
+
<?php echo $instance['include_parent']; ?>/></p>
|
27 |
+
|
28 |
+
|
29 |
+
<p> Include Parent Even With No Children<input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
30 |
+
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
31 |
+
<?php echo $instance['include_childless_parent']; ?>/></p>
|
32 |
+
|
33 |
+
<p> Use Built in Styling <input id="<?php echo $this->get_field_name('css'); ?>"
|
34 |
+
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
35 |
+
<?php echo $instance['css']; ?>/></p>
|
36 |
+
|
37 |
+
<p> Pages to Exclude, Comma Separated:<input id="<?php echo $this->get_field_name('exclude'); ?>"
|
38 |
+
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
39 |
+
|
40 |
+
<p> Always Display Child Pages <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
41 |
+
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
42 |
+
onclick="javascript:reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
43 |
+
<?php echo $instance['display_all']; ?>/></p>
|
44 |
+
|
45 |
+
<span id="levels-<?php echo $this->get_field_name('levels'); ?>" style="<?php
|
46 |
+
if( $instance['display_all'] == checked ){
|
47 |
+
echo 'display:block';
|
48 |
+
} else {
|
49 |
+
echo 'display:none';
|
50 |
+
} ?>">
|
51 |
+
<p> Levels to Display <select id="<?php echo $this->get_field_name('levels'); ?>"
|
52 |
+
name="<?php echo $this->get_field_name('levels'); ?>">
|
53 |
+
<?php
|
54 |
+
for( $i= 1; $i<6; $i++ ){
|
55 |
+
if( $i == $instance['levels'] ){
|
56 |
+
echo '<option value="'.$i.'" selected>'.$i.'</option>';
|
57 |
+
} else {
|
58 |
+
echo '<option value="'.$i.'">'.$i.'</option>';
|
59 |
+
}
|
60 |
+
}
|
61 |
+
echo '</select></p></span>';
|
62 |
+
}
|
63 |
+
|
64 |
+
#------------------------------------------------------------------------------------------------------------------------------
|
65 |
+
// this allows more than one instance
|
66 |
+
|
67 |
+
function update( $new_instance, $old_instance ) {
|
68 |
+
$instance = $old_instance;
|
69 |
+
$instance['include_childless_parent'] = strip_tags($new_instance['include_childless_parent']);
|
70 |
+
$instance['include_parent'] = strip_tags($new_instance['include_parent']);
|
71 |
+
$instance['exclude'] = strip_tags($new_instance['exclude']);
|
72 |
+
$instance['display_all'] = strip_tags($new_instance['display_all']);
|
73 |
+
$instance['levels'] = strip_tags($new_instance['levels']);
|
74 |
+
$instance['css'] = strip_tags($new_instance['css']);
|
75 |
+
return $instance;
|
76 |
+
}
|
77 |
+
|
78 |
+
#-------------------------------------------------------------------------------------------------------------------------
|
79 |
+
|
80 |
+
// This decides the name of the widget
|
81 |
+
function advanced_sidebar_menu_page( ) {
|
82 |
+
/* Widget settings. */
|
83 |
+
$widget_ops = array( 'classname' => 'sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' );
|
84 |
+
|
85 |
+
|
86 |
+
/* Create the widget. */
|
87 |
+
$this->WP_Widget( 'advanced_sidebar_menu', 'Advanced Sidebar Pages Menu', $widget_ops, $control_ops );
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
#---------------------------------------------------------------------------------------------------------------------------
|
92 |
+
|
93 |
+
// adds the output to the widget area on the page
|
94 |
+
function widget($args, $instance) {
|
95 |
+
|
96 |
+
if( is_page() ){
|
97 |
+
|
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' && !in_array($p, $exclude) ) ){
|
131 |
+
|
132 |
+
if( $instance['css'] == 'checked' ){
|
133 |
+
echo '<style type="text/css">';
|
134 |
+
include( advanced_sidebar_menu_file_hyercy( 'sidebar-menu.css' ) );
|
135 |
+
|
136 |
+
echo '</style>';
|
137 |
+
|
138 |
+
|
139 |
+
}
|
140 |
+
|
141 |
+
|
142 |
+
#-- Bring in the output
|
143 |
+
require( advanced_sidebar_menu_file_hyercy( 'page_list.php' ) );
|
144 |
+
|
145 |
+
}
|
146 |
+
}
|
147 |
+
} #== /widget()
|
148 |
+
|
149 |
+
} #== /Clas
|