Version Description
- Bugfixes
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Advanced Sidebar Menu |
Version | 3.2.5 |
Comparing to | |
See all releases |
Code changes from version 3.3.0 to 3.2.5
- advanced-sidebar-menu.php +7 -3
- functions.php +45 -164
- views/category_list.php +41 -29
- views/page_list.php +34 -17
- widgets/category.widget.php +6 -14
- widgets/page.widget.php +13 -23
advanced-sidebar-menu.php
CHANGED
@@ -4,23 +4,27 @@ Plugin Name: Advanced Sidebar Menu
|
|
4 |
Plugin URI: http://lipeimagination.info/wordpress/advanced-sidebar-menu/
|
5 |
Description: Creates dynamic menu based on child/parent relationship.
|
6 |
Author: Mat Lipe
|
7 |
-
Version: 3.
|
8 |
Author URI: http://lipeimagination.info
|
9 |
Since: 7/16/12
|
10 |
Email: mat@lipeimagination.info
|
|
|
11 |
*/
|
12 |
|
|
|
13 |
#-- Bring in the functions
|
14 |
require( 'functions.php' );
|
15 |
$asm = new advanced_sidebar_menu_functions();
|
16 |
|
17 |
-
|
18 |
-
add_action( 'init', array( $asm, '
|
|
|
19 |
|
20 |
|
21 |
#-- Bring in the Widgets
|
22 |
require( 'widgets/init.php' );
|
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/' );
|
4 |
Plugin URI: http://lipeimagination.info/wordpress/advanced-sidebar-menu/
|
5 |
Description: Creates dynamic menu based on child/parent relationship.
|
6 |
Author: Mat Lipe
|
7 |
+
Version: 3.2.5
|
8 |
Author URI: http://lipeimagination.info
|
9 |
Since: 7/16/12
|
10 |
Email: mat@lipeimagination.info
|
11 |
+
|
12 |
*/
|
13 |
|
14 |
+
|
15 |
#-- Bring in the functions
|
16 |
require( 'functions.php' );
|
17 |
$asm = new advanced_sidebar_menu_functions();
|
18 |
|
19 |
+
#-- Version 3.2 notice
|
20 |
+
add_action( 'init', array( $asm, 'validate_3_2' ) );
|
21 |
+
|
22 |
|
23 |
|
24 |
#-- Bring in the Widgets
|
25 |
require( 'widgets/init.php' );
|
26 |
|
27 |
+
|
28 |
#-- Define Constants
|
29 |
define( 'ADVANCED_SIDEBAR_WIDGETS_DIR', plugin_dir_path(__FILE__) . 'widgets/' );
|
30 |
define( 'ADVANCED_SIDEBAR_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
functions.php
CHANGED
@@ -4,53 +4,68 @@
|
|
4 |
/**
|
5 |
* These Functions are Specific to the Advanced Sidebar Menu
|
6 |
* @author Mat Lipe
|
7 |
-
* @since
|
8 |
*/
|
9 |
|
10 |
|
11 |
|
12 |
class advanced_sidebar_menu_functions{
|
13 |
-
protected $bad = array(); //for 3.
|
14 |
-
protected $
|
15 |
|
16 |
|
17 |
/**
|
18 |
* Validate the views for the new structure
|
19 |
-
* @since
|
20 |
*/
|
21 |
-
function
|
|
|
|
|
22 |
/** Note to self -- Remove this at the new version **/
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
foreach( $data as $line => $content ){
|
|
|
26 |
$line++;
|
27 |
-
|
|
|
28 |
$bad[$line] = htmlentities( $content );
|
29 |
}
|
30 |
-
|
|
|
31 |
$bad[$line] = htmlentities( $content );
|
32 |
}
|
33 |
-
|
|
|
|
|
34 |
|
35 |
$bad[$line] = htmlentities( $content );
|
36 |
}
|
|
|
37 |
}
|
|
|
38 |
if( !empty( $bad ) ){
|
39 |
$this->bad = $bad;
|
40 |
-
$this->
|
41 |
-
add_action( 'admin_notices', array( $this, '
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
}
|
45 |
|
46 |
|
47 |
/**
|
48 |
* Adds an admin notice if there are issues with the view
|
49 |
-
* @since
|
50 |
*/
|
51 |
-
function
|
52 |
echo '<div class="error">';
|
53 |
-
echo 'To use version 3.
|
54 |
|
55 |
foreach( $this->bad as $line => $content ){
|
56 |
echo '<b>line' . $line . ': </b> '. $content . '<br>';
|
@@ -59,160 +74,26 @@ function notice_3_3( ){
|
|
59 |
echo '</div>';
|
60 |
|
61 |
}
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
private $instance; //The widget instance
|
68 |
-
private $top_id; //Either the top cat or page
|
69 |
-
private $exclude;
|
70 |
-
private $ancestors; //For the category ancestors
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Sets the instance of this widget to this class
|
74 |
-
* @param array $instance the widgets instance
|
75 |
-
* @since 7/16/12
|
76 |
-
*/
|
77 |
-
function set_widget_vars( $instance, $top_id, $exclude, $ancestors = array() ){
|
78 |
-
$this->instance = $instance;
|
79 |
-
$this->top_id = $top_id;
|
80 |
-
$this->exclude = $exclude;
|
81 |
-
$this->ancestors = $ancestors;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
*
|
86 |
-
* IF this is a top level category
|
87 |
-
* @param obj $cat the cat object
|
88 |
-
*/
|
89 |
-
function first_level_category( $cat ){
|
90 |
-
if( !in_array($cat->cat_ID, $this->exclude) && $cat->parent == $this->top_id){
|
91 |
-
return true;
|
92 |
-
} else {
|
93 |
-
return false;
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* If the cat is a second level cat
|
99 |
-
* @param obj $cat the cat
|
100 |
-
* @since 7/16/12
|
101 |
-
*/
|
102 |
-
function second_level_cat( $cat ){
|
103 |
-
//if this is the currrent cat or a parent of the current cat
|
104 |
-
if( $cat->cat_ID == get_query_var('cat' ) || in_array( $cat->cat_ID, $this->ancestors )){
|
105 |
-
$all_children = array();
|
106 |
-
$all_children = get_categories( array( 'child_of' => $child_cat->cat_ID ) );
|
107 |
-
if( !empty( $all_children ) ){
|
108 |
-
return true;
|
109 |
-
} else {
|
110 |
-
return false;
|
111 |
-
}
|
112 |
-
|
113 |
-
} else {
|
114 |
-
return false;
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Determines if all the children should be included
|
120 |
-
* @since 7/16/12
|
121 |
-
* @return bool
|
122 |
-
*/
|
123 |
-
function display_all(){
|
124 |
-
if( $this->instance['display_all'] == 'checked' ){
|
125 |
-
return true;
|
126 |
-
} else {
|
127 |
-
return false;
|
128 |
-
}
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
*
|
133 |
-
* Returns and array of all the children of a page
|
134 |
-
* @param int $pID the id of the page
|
135 |
-
* @since 7/19/12
|
136 |
-
*/
|
137 |
-
function page_children( $pID ){
|
138 |
-
global $wpdb, $table_prefix;
|
139 |
-
return $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID." AND post_type='page' AND post_status='publish'" );
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
*
|
145 |
-
* Determines if this is an ancestor or the current post
|
146 |
-
* @param obj $pID the post object
|
147 |
-
* @since 7/19/12
|
148 |
-
*/
|
149 |
-
function page_ancestor( $pID ){
|
150 |
-
global $post;
|
151 |
-
if($pID->ID == $post->ID or $pID->ID == $post->post_parent or @in_array($pID->ID, $post->ancestors) ){
|
152 |
-
return true;
|
153 |
-
} else {
|
154 |
-
return false;
|
155 |
-
}
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Determines if the parent page or cat should be included
|
161 |
-
* @since 7/16/12
|
162 |
-
* @return bool
|
163 |
-
*/
|
164 |
-
function include_parent(){
|
165 |
-
if( ($this->instance['include_parent'] == 'checked') && (!in_array($this->top_id, $this->exclude)) ){
|
166 |
-
return true;
|
167 |
-
} else {
|
168 |
-
return false;
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
|
173 |
-
/**
|
174 |
-
* Echos the title of the widget to the page
|
175 |
-
* @since 7/16/12
|
176 |
-
*/
|
177 |
-
function title(){
|
178 |
-
if( $this->instance['title'] != '' ){
|
179 |
-
echo '<h4 class="widgettitle">' . $this->instance['title'] . '</h4>';
|
180 |
-
}
|
181 |
-
|
182 |
-
}
|
183 |
-
|
184 |
-
|
185 |
-
/**
|
186 |
-
*
|
187 |
-
* Checks is this id is excluded or not
|
188 |
-
* @param int $id the id to check
|
189 |
-
* @return bool
|
190 |
-
*/
|
191 |
-
function exclude( $id ){
|
192 |
-
if( !in_array( $id, $this->exclude ) ){
|
193 |
-
return true;
|
194 |
-
} else {
|
195 |
-
return false;
|
196 |
-
}
|
197 |
-
}
|
198 |
-
|
199 |
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
|
|
|
|
206 |
|
207 |
-
|
208 |
-
if ( $theme_file = locate_template(array('advanced-sidebar-menu/'.$file)) ) {
|
209 |
-
$file = $theme_file;
|
210 |
-
} else {
|
211 |
-
$file = ADVANCED_SIDEBAR_VIEWS_DIR . $file;
|
212 |
-
}
|
213 |
-
return $file;
|
214 |
|
|
|
|
|
|
|
|
|
215 |
}
|
|
|
|
|
|
|
216 |
|
217 |
} //End class
|
218 |
|
4 |
/**
|
5 |
* These Functions are Specific to the Advanced Sidebar Menu
|
6 |
* @author Mat Lipe
|
7 |
+
* @since 6/3/12
|
8 |
*/
|
9 |
|
10 |
|
11 |
|
12 |
class advanced_sidebar_menu_functions{
|
13 |
+
protected $bad = array(); //for 3.2 version
|
14 |
+
protected $cat_file = ''; //for 3.2 version
|
15 |
|
16 |
|
17 |
/**
|
18 |
* Validate the views for the new structure
|
19 |
+
* @since 6/3/12
|
20 |
*/
|
21 |
+
function validate_3_2(){
|
22 |
+
|
23 |
+
|
24 |
/** Note to self -- Remove this at the new version **/
|
25 |
+
if ( $cat_file = locate_template(array('advanced-sidebar-menu/category_list.php')) ) {
|
26 |
+
|
27 |
+
$data = explode("\n", file_get_contents( $cat_file )); //create array separate by new line
|
28 |
+
|
29 |
+
//print_r( $data );
|
30 |
+
|
31 |
foreach( $data as $line => $content ){
|
32 |
+
|
33 |
$line++;
|
34 |
+
|
35 |
+
if( strpos( $content, " class=\"advanced-sidebar-menu widget advanced-sidebar-category\">" ) ){
|
36 |
$bad[$line] = htmlentities( $content );
|
37 |
}
|
38 |
+
|
39 |
+
if( strpos( $content, "<div class=\"widget-wrap\">';" ) ){
|
40 |
$bad[$line] = htmlentities( $content );
|
41 |
}
|
42 |
+
|
43 |
+
|
44 |
+
if( strpos( $content, "</div></div><!-- END #advanced-sidebar-cat-menu -->';" ) ){
|
45 |
|
46 |
$bad[$line] = htmlentities( $content );
|
47 |
}
|
48 |
+
|
49 |
}
|
50 |
+
|
51 |
if( !empty( $bad ) ){
|
52 |
$this->bad = $bad;
|
53 |
+
$this->cat_file = get_bloginfo( 'stylesheet_directory' ) . 'advanced-sidebar-menu/category_list.php';
|
54 |
+
add_action( 'admin_notices', array( $this, 'notice_3_2') );
|
55 |
}
|
56 |
+
|
57 |
}
|
58 |
+
|
59 |
}
|
60 |
|
61 |
|
62 |
/**
|
63 |
* Adds an admin notice if there are issues with the view
|
64 |
+
* @since 6/3/12
|
65 |
*/
|
66 |
+
function notice_3_2( ){
|
67 |
echo '<div class="error">';
|
68 |
+
echo 'To use version 3.2 of <b>Advanced Sidebar Menu</b> you must delete the following lines from <b>"' . $this->cat_file . '"</b><br>';
|
69 |
|
70 |
foreach( $this->bad as $line => $content ){
|
71 |
echo '<b>line' . $line . ': </b> '. $content . '<br>';
|
74 |
echo '</div>';
|
75 |
|
76 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Allows for Overwritting files in the child theme
|
84 |
+
* @since 6/3/12
|
85 |
+
*/
|
86 |
|
87 |
+
static function file_hyercy( $file ){
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
+
if ( $theme_file = locate_template(array('advanced-sidebar-menu/'.$file)) ) {
|
90 |
+
$file = $theme_file;
|
91 |
+
} else {
|
92 |
+
$file = ADVANCED_SIDEBAR_VIEWS_DIR . $file;
|
93 |
}
|
94 |
+
return $file;
|
95 |
+
|
96 |
+
}
|
97 |
|
98 |
} //End class
|
99 |
|
views/category_list.php
CHANGED
@@ -3,52 +3,56 @@
|
|
3 |
/**
|
4 |
* The Ouput of tad Advanced Sidebar Categories Widget
|
5 |
* @author Mat Lipe
|
6 |
-
* @since
|
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
|
12 |
*/
|
13 |
|
14 |
|
15 |
-
//Displays the title
|
16 |
-
$asm->title();
|
17 |
|
18 |
-
|
19 |
-
if( $
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
echo '<ul class="child-sidebar-menu">';
|
26 |
|
27 |
#-- If they want all the child categories displayed always
|
28 |
-
if( $
|
29 |
wp_list_categories('title_li=&child_of=' . $top_cat .'&depth=' .$instance['levels'] );
|
30 |
-
|
31 |
-
|
32 |
} else {
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
if( $asm->first_level_category( $child_cat ) ){
|
39 |
-
|
40 |
//List the child category and the children if it is the current one
|
41 |
wp_list_categories('title_li=&include=' . $child_cat->cat_ID . '&depth=1' );
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
#-- Create a new menu with all the children under it
|
47 |
echo '<ul class="grandchild-sidebar-menu">';
|
48 |
-
|
|
|
|
|
49 |
echo '</ul>';
|
50 |
-
|
51 |
-
|
52 |
}
|
53 |
} //End foreach
|
54 |
|
@@ -56,10 +60,18 @@ if( $asm->include_parent() ){
|
|
56 |
|
57 |
} //End if display all is not checked
|
58 |
|
|
|
59 |
} //End if the are child categories
|
60 |
|
61 |
|
62 |
#-- if a parent category was displayed
|
63 |
-
if( $
|
64 |
echo '</ul><!-- End #parent-sidebar-menu -->';
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
/**
|
4 |
* The Ouput of tad Advanced Sidebar Categories Widget
|
5 |
* @author Mat Lipe
|
6 |
+
* @since 6/3/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 update
|
12 |
*/
|
13 |
|
14 |
|
|
|
|
|
15 |
|
16 |
+
#-- if the checkbox to include parent is checked
|
17 |
+
if( $instance['include_parent'] == 'checked' && !in_array($top_cat, $exclude) ){
|
18 |
+
|
19 |
+
echo '<ul class="parent-sidebar-menu">';
|
20 |
+
wp_list_categories( 'title_li=&include=' . $top_cat);
|
21 |
+
|
22 |
+
$parent = 'yes';
|
23 |
+
}
|
24 |
+
|
25 |
+
if( !empty($all) ){
|
26 |
+
|
27 |
echo '<ul class="child-sidebar-menu">';
|
28 |
|
29 |
#-- If they want all the child categories displayed always
|
30 |
+
if( $instance['display_all'] == 'checked' ){
|
31 |
wp_list_categories('title_li=&child_of=' . $top_cat .'&depth=' .$instance['levels'] );
|
32 |
+
echo '</ul><!-- End #child-sidebar-menu -->';
|
|
|
33 |
} else {
|
34 |
+
|
35 |
+
foreach( $all as $child_cat ){
|
36 |
+
|
37 |
+
if( !in_array($child_cat->cat_ID, $exclude) && $child_cat->parent == $top_cat){
|
38 |
+
|
|
|
|
|
39 |
//List the child category and the children if it is the current one
|
40 |
wp_list_categories('title_li=&include=' . $child_cat->cat_ID . '&depth=1' );
|
41 |
|
42 |
+
if( $child_cat->cat_ID == get_query_var('cat' ) || in_array( $child_cat->cat_ID, $cat_ancestors ) ){
|
43 |
+
|
44 |
+
$all_children = array();
|
45 |
+
$all_children = get_categories( array( 'child_of' => $child_cat->cat_ID ) );
|
46 |
+
|
47 |
+
if( !empty( $all_children ) ){
|
48 |
#-- Create a new menu with all the children under it
|
49 |
echo '<ul class="grandchild-sidebar-menu">';
|
50 |
+
|
51 |
+
wp_list_categories("title_li=&exclude=".$instance['exclude']."&depth=3&child_of=" .$child_cat->cat_ID );
|
52 |
+
|
53 |
echo '</ul>';
|
54 |
+
}
|
55 |
+
}
|
56 |
}
|
57 |
} //End foreach
|
58 |
|
60 |
|
61 |
} //End if display all is not checked
|
62 |
|
63 |
+
|
64 |
} //End if the are child categories
|
65 |
|
66 |
|
67 |
#-- if a parent category was displayed
|
68 |
+
if( isset($parent) ){
|
69 |
echo '</ul><!-- End #parent-sidebar-menu -->';
|
70 |
+
|
71 |
+
unset( $parent); //for next time
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
|
77 |
+
|
views/page_list.php
CHANGED
@@ -13,22 +13,33 @@
|
|
13 |
* @uses Do not edit this file in its original location or it will break on upgrade
|
14 |
*/
|
15 |
|
16 |
-
$asm->title();
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
|
25 |
//If there are children start the Child Sidebar Menu
|
26 |
-
if( $
|
27 |
echo '<ul class="child-sidebar-menu">';
|
28 |
|
29 |
#-- If they want all the pages displayed always
|
30 |
-
if( $
|
31 |
-
|
32 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&child_of=".$top_parent."&depth=".$instance['levels']."&exclude=".$instance['exclude']);
|
33 |
} else {
|
34 |
|
@@ -36,19 +47,21 @@ if( $child_pages ){
|
|
36 |
foreach($result as $pID){
|
37 |
|
38 |
#-- If the page is not in the excluded ones
|
39 |
-
if(
|
40 |
#--echo the current page from the $result
|
41 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
|
42 |
}
|
43 |
|
44 |
#-- if the link that was just listed is the current page we are on
|
45 |
-
if( $
|
46 |
|
47 |
-
//
|
48 |
-
$grandkids = $
|
49 |
if( $grandkids ){
|
|
|
50 |
#-- Create a new menu with all the children under it
|
51 |
echo '<ul class="grandchild-sidebar-menu">';
|
|
|
52 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&exclude=".$instance['exclude']."&depth=3&child_of=".$pID->ID);
|
53 |
|
54 |
echo '</ul>';
|
@@ -61,10 +74,14 @@ if( $child_pages ){
|
|
61 |
echo '</ul><!-- End child-sidebar-menu -->';
|
62 |
|
63 |
}
|
64 |
-
if( $asm->include_parent() ) {
|
65 |
-
echo '</ul><!-- .parent-sidebar-menu -->';
|
66 |
-
}
|
67 |
-
|
68 |
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
13 |
* @uses Do not edit this file in its original location or it will break on upgrade
|
14 |
*/
|
15 |
|
|
|
16 |
|
17 |
+
//Start the menu
|
18 |
+
echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget advanced-sidebar-page">
|
19 |
+
<div class="widget-wrap">';
|
20 |
+
|
21 |
+
|
22 |
+
#-- if the checkbox to include parent is checked
|
23 |
+
if( $instance['include_parent'] == 'checked' ){
|
24 |
+
echo '<ul class="parent-sidebar-menu" >';
|
25 |
+
|
26 |
+
#-- If the page is not excluded from the menu
|
27 |
+
if( !in_array($top_parent, $exclude) ){
|
28 |
+
#-- list the parent page
|
29 |
+
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$top_parent);
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
|
36 |
|
37 |
//If there are children start the Child Sidebar Menu
|
38 |
+
if( $result != FALSE ){
|
39 |
echo '<ul class="child-sidebar-menu">';
|
40 |
|
41 |
#-- If they want all the pages displayed always
|
42 |
+
if( $instance['display_all'] == 'checked' ){
|
|
|
43 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&child_of=".$top_parent."&depth=".$instance['levels']."&exclude=".$instance['exclude']);
|
44 |
} else {
|
45 |
|
47 |
foreach($result as $pID){
|
48 |
|
49 |
#-- If the page is not in the excluded ones
|
50 |
+
if( !in_array($pID->ID, $exclude) ){
|
51 |
#--echo the current page from the $result
|
52 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
|
53 |
}
|
54 |
|
55 |
#-- if the link that was just listed is the current page we are on
|
56 |
+
if($pID->ID == $post->ID or $pID->ID == $post->post_parent or @in_array($pID->ID, $post->ancestors) ){
|
57 |
|
58 |
+
//must be done this way to prevent bloat or doubling up
|
59 |
+
$grandkids = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID->ID." AND post_type='page' AND post_status='publish'" );
|
60 |
if( $grandkids ){
|
61 |
+
|
62 |
#-- Create a new menu with all the children under it
|
63 |
echo '<ul class="grandchild-sidebar-menu">';
|
64 |
+
|
65 |
wp_list_pages("sort_column=menu_order&title_li=&echo=1&exclude=".$instance['exclude']."&depth=3&child_of=".$pID->ID);
|
66 |
|
67 |
echo '</ul>';
|
74 |
echo '</ul><!-- End child-sidebar-menu -->';
|
75 |
|
76 |
}
|
|
|
|
|
|
|
|
|
77 |
|
78 |
|
79 |
+
#-- If there was a menu close it off
|
80 |
+
if($child_pages != false || ($instance['include_childless_parent'] == 'checked') ){
|
81 |
+
|
82 |
+
if( $instance['include_parent'] == 'checked' ) {
|
83 |
+
echo '</ul>';
|
84 |
+
}
|
85 |
+
echo '</div></div><!-- end of very-custom-menu -->';
|
86 |
+
}
|
87 |
|
widgets/category.widget.php
CHANGED
@@ -20,9 +20,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
20 |
function form( $instance ) {
|
21 |
// require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
22 |
?>
|
23 |
-
|
24 |
-
<input id="<?php echo $this->get_field_name('title'); ?>"
|
25 |
-
name="<?php echo $this->get_field_name('title'); ?>" size="50" type="text" value="<?php echo $instance['title']; ?>"/></p>
|
26 |
|
27 |
|
28 |
<p> Include Parent Category <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
@@ -38,7 +36,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
38 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
39 |
<?php echo $instance['css']; ?>/></p>
|
40 |
|
41 |
-
<p> Display Categories on Single
|
42 |
name="<?php echo $this->get_field_name('single'); ?>" type="checkbox" value="checked"
|
43 |
onclick="javascript:asm_reveal_element( 'new-widget-<?php echo $this->get_field_name('new_widget'); ?>' )"
|
44 |
<?php echo $instance['single']; ?>/></p>
|
@@ -107,8 +105,6 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
107 |
$instance['css'] = strip_tags($new_instance['css']);
|
108 |
$instance['single'] = strip_tags($new_instance['single']); //Display on single pages
|
109 |
$instance['new_widget'] = strip_tags($new_instance['new_widget']); //Create a new widget for each single category
|
110 |
-
$instance['title'] = strip_tags($new_instance['title']);
|
111 |
-
|
112 |
return $instance;
|
113 |
}
|
114 |
|
@@ -128,7 +124,6 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
128 |
|
129 |
// adds the output to the widget area on the page
|
130 |
function widget($args, $instance) {
|
131 |
-
global $asm;
|
132 |
#-- Create a usable array of the excluded pages
|
133 |
$exclude = explode(',', $instance['exclude']);
|
134 |
$cat_ids = $already_top = array();
|
@@ -186,13 +181,11 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
186 |
|
187 |
|
188 |
//Check for children
|
189 |
-
$
|
190 |
-
|
191 |
-
//for depreciation
|
192 |
-
$all = $all_categories;
|
193 |
|
194 |
//If there are any child categories or the include childless parent is checked
|
195 |
-
if( !empty($
|
196 |
|
197 |
|
198 |
//Creates a new widget for each category the single page has if the options are selected to do so
|
@@ -211,9 +204,8 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
211 |
}
|
212 |
|
213 |
|
214 |
-
$asm->set_widget_vars( $instance, $top_cat, $exclude, $cat_ancestors );
|
215 |
//Bring in the view
|
216 |
-
|
217 |
|
218 |
|
219 |
if( $close ){
|
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'); ?>"
|
36 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
37 |
<?php echo $instance['css']; ?>/></p>
|
38 |
|
39 |
+
<p> Display Categories on Single Post Page's <input id="<?php echo $this->get_field_name('single'); ?>"
|
40 |
name="<?php echo $this->get_field_name('single'); ?>" type="checkbox" value="checked"
|
41 |
onclick="javascript:asm_reveal_element( 'new-widget-<?php echo $this->get_field_name('new_widget'); ?>' )"
|
42 |
<?php echo $instance['single']; ?>/></p>
|
105 |
$instance['css'] = strip_tags($new_instance['css']);
|
106 |
$instance['single'] = strip_tags($new_instance['single']); //Display on single pages
|
107 |
$instance['new_widget'] = strip_tags($new_instance['new_widget']); //Create a new widget for each single category
|
|
|
|
|
108 |
return $instance;
|
109 |
}
|
110 |
|
124 |
|
125 |
// adds the output to the widget area on the page
|
126 |
function widget($args, $instance) {
|
|
|
127 |
#-- Create a usable array of the excluded pages
|
128 |
$exclude = explode(',', $instance['exclude']);
|
129 |
$cat_ids = $already_top = array();
|
181 |
|
182 |
|
183 |
//Check for children
|
184 |
+
$all = get_categories( array( 'child_of' => $top_cat ) );
|
185 |
+
|
|
|
|
|
186 |
|
187 |
//If there are any child categories or the include childless parent is checked
|
188 |
+
if( !empty($all ) || ($instance['include_childless_parent'] == 'checked' && !in_array($top_cat, $exclude)) ){
|
189 |
|
190 |
|
191 |
//Creates a new widget for each category the single page has if the options are selected to do so
|
204 |
}
|
205 |
|
206 |
|
|
|
207 |
//Bring in the view
|
208 |
+
require( advanced_sidebar_menu_functions::file_hyercy( 'category_list.php' ) );
|
209 |
|
210 |
|
211 |
if( $close ){
|
widgets/page.widget.php
CHANGED
@@ -11,7 +11,6 @@
|
|
11 |
*/
|
12 |
|
13 |
|
14 |
-
|
15 |
class advanced_sidebar_menu_page extends WP_Widget {
|
16 |
|
17 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
@@ -19,28 +18,24 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
19 |
function form( $instance ) {
|
20 |
// require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
21 |
?>
|
22 |
-
|
23 |
-
<p> Title <br>
|
24 |
-
<input id="<?php echo $this->get_field_name('title'); ?>"
|
25 |
-
name="<?php echo $this->get_field_name('title'); ?>" size="50" type="text" value="<?php echo $instance['title']; ?>"/></p>
|
26 |
|
27 |
-
<p> Include Parent Page
|
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
|
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
|
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
|
41 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
42 |
|
43 |
-
<p> Always Display Child Pages
|
44 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
45 |
onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
46 |
<?php echo $instance['display_all']; ?>/></p>
|
@@ -51,7 +46,7 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
51 |
} else {
|
52 |
echo 'display:none';
|
53 |
} ?>">
|
54 |
-
<p> Levels to Display
|
55 |
name="<?php echo $this->get_field_name('levels'); ?>">
|
56 |
<?php
|
57 |
for( $i= 1; $i<6; $i++ ){
|
@@ -75,7 +70,6 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
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 |
-
$instance['title'] = strip_tags($new_instance['title']);
|
79 |
return $instance;
|
80 |
}
|
81 |
|
@@ -85,10 +79,10 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
85 |
function advanced_sidebar_menu_page( ) {
|
86 |
/* Widget settings. */
|
87 |
$widget_ops = array( 'classname' => 'sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' );
|
88 |
-
|
89 |
|
90 |
/* Create the widget. */
|
91 |
-
$this->WP_Widget( 'advanced_sidebar_menu', 'Advanced Sidebar Pages Menu', $widget_ops
|
92 |
}
|
93 |
|
94 |
|
@@ -96,10 +90,9 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
96 |
|
97 |
// adds the output to the widget area on the page
|
98 |
function widget($args, $instance) {
|
99 |
-
|
100 |
if( is_page() ){
|
101 |
|
102 |
-
global $wpdb, $post, $table_prefix
|
103 |
|
104 |
#-- Create a usable array of the excluded pages
|
105 |
$exclude = explode(',', $instance['exclude']);
|
@@ -130,13 +123,10 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
130 |
echo '</style>';
|
131 |
}
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
#-- Bring in the view
|
138 |
-
require( $asm->file_hyercy( 'page_list.php' ) );
|
139 |
-
echo '</div></div><!-- end #'.$args['widget_id'].' -->';
|
140 |
}
|
141 |
}
|
142 |
} #== /widget()
|
11 |
*/
|
12 |
|
13 |
|
|
|
14 |
class advanced_sidebar_menu_page extends WP_Widget {
|
15 |
|
16 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
18 |
function form( $instance ) {
|
19 |
// require( ADVANCED_SIDEBAR_DIR . 'advanced-sidebar-menu.js' );
|
20 |
?>
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
<p> Include Parent Page <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
23 |
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
24 |
<?php echo $instance['include_parent']; ?>/></p>
|
25 |
|
26 |
|
27 |
+
<p> Include Parent Even With No Children<input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
28 |
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
29 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
30 |
|
31 |
+
<p> Use Built in Styling <input id="<?php echo $this->get_field_name('css'); ?>"
|
32 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
33 |
<?php echo $instance['css']; ?>/></p>
|
34 |
|
35 |
+
<p> Pages to Exclude, Comma Separated:<input id="<?php echo $this->get_field_name('exclude'); ?>"
|
36 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
37 |
|
38 |
+
<p> Always Display Child Pages <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
39 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
40 |
onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_name('levels'); ?>' )"
|
41 |
<?php echo $instance['display_all']; ?>/></p>
|
46 |
} else {
|
47 |
echo 'display:none';
|
48 |
} ?>">
|
49 |
+
<p> Levels to Display <select id="<?php echo $this->get_field_name('levels'); ?>"
|
50 |
name="<?php echo $this->get_field_name('levels'); ?>">
|
51 |
<?php
|
52 |
for( $i= 1; $i<6; $i++ ){
|
70 |
$instance['display_all'] = strip_tags($new_instance['display_all']);
|
71 |
$instance['levels'] = strip_tags($new_instance['levels']);
|
72 |
$instance['css'] = strip_tags($new_instance['css']);
|
|
|
73 |
return $instance;
|
74 |
}
|
75 |
|
79 |
function advanced_sidebar_menu_page( ) {
|
80 |
/* Widget settings. */
|
81 |
$widget_ops = array( 'classname' => 'sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' );
|
82 |
+
|
83 |
|
84 |
/* Create the widget. */
|
85 |
+
$this->WP_Widget( 'advanced_sidebar_menu', 'Advanced Sidebar Pages Menu', $widget_ops);
|
86 |
}
|
87 |
|
88 |
|
90 |
|
91 |
// adds the output to the widget area on the page
|
92 |
function widget($args, $instance) {
|
|
|
93 |
if( is_page() ){
|
94 |
|
95 |
+
global $wpdb, $post, $table_prefix;
|
96 |
|
97 |
#-- Create a usable array of the excluded pages
|
98 |
$exclude = explode(',', $instance['exclude']);
|
123 |
echo '</style>';
|
124 |
}
|
125 |
|
126 |
+
|
127 |
+
#-- Bring in the output
|
128 |
+
require( advanced_sidebar_menu_functions::file_hyercy( 'page_list.php' ) );
|
129 |
+
|
|
|
|
|
|
|
130 |
}
|
131 |
}
|
132 |
} #== /widget()
|