Version Description
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Advanced Sidebar Menu |
Version | 4.1.2 |
Comparing to | |
See all releases |
Code changes from version 4.1.0 to 4.1.2
- advanced-sidebar-menu.php +3 -2
- legacy/category_list.php +65 -0
- legacy/page_list.php +67 -0
- legacy/sidebar-menu.css +34 -0
- lib/advancedSidebarMenu.php +163 -161
- readme.txt +1 -1
- views/page_list.php +3 -3
- widgets/category.widget.php +30 -12
- widgets/page.widget.php +22 -17
advanced-sidebar-menu.php
CHANGED
@@ -4,9 +4,9 @@ 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: 4.1.
|
8 |
Author URI: http://lipeimagination.info
|
9 |
-
Since: 4.
|
10 |
*/
|
11 |
|
12 |
#-- Bring in the functions
|
@@ -20,6 +20,7 @@ require( 'widgets/init.php' );
|
|
20 |
#-- Define Constants
|
21 |
define( 'ADVANCED_SIDEBAR_WIDGETS_DIR', plugin_dir_path(__FILE__) . 'widgets/' );
|
22 |
define( 'ADVANCED_SIDEBAR_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
|
|
23 |
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path(__FILE__) );
|
24 |
|
25 |
|
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: 4.1.2
|
8 |
Author URI: http://lipeimagination.info
|
9 |
+
Since: 4.23.13
|
10 |
*/
|
11 |
|
12 |
#-- Bring in the functions
|
20 |
#-- Define Constants
|
21 |
define( 'ADVANCED_SIDEBAR_WIDGETS_DIR', plugin_dir_path(__FILE__) . 'widgets/' );
|
22 |
define( 'ADVANCED_SIDEBAR_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
23 |
+
define( 'ADVANCED_SIDEBAR_LEGACY_DIR', plugin_dir_path(__FILE__) . 'legacy/' );
|
24 |
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path(__FILE__) );
|
25 |
|
26 |
|
legacy/category_list.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The Ouput of tad Advanced Sidebar Categories Widget
|
5 |
+
* @author Mat Lipe
|
6 |
+
* @since 7/16/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 in this location or it will break on update
|
12 |
+
*/
|
13 |
+
|
14 |
+
|
15 |
+
//Displays the title
|
16 |
+
$asm->title();
|
17 |
+
|
18 |
+
//Include the parent page if chosen
|
19 |
+
if( $asm->include_parent() ){
|
20 |
+
echo '<ul class="parent-sidebar-menu">';
|
21 |
+
wp_list_categories( 'title_li=&include=' . $top_cat);
|
22 |
+
}
|
23 |
+
//If there are children to display
|
24 |
+
if( !empty($all_categories) ){
|
25 |
+
echo '<ul class="child-sidebar-menu">';
|
26 |
+
|
27 |
+
#-- If they want all the child categories displayed always
|
28 |
+
if( $asm->display_all() ){
|
29 |
+
wp_list_categories('title_li=&child_of=' . $top_cat .'&depth=' .$instance['levels'] );
|
30 |
+
echo '</ul><!-- End #child-sidebar-menu -->';
|
31 |
+
|
32 |
+
} else {
|
33 |
+
|
34 |
+
#-- to Display the categories based a parent child relationship
|
35 |
+
foreach( $all_categories as $child_cat ){
|
36 |
+
|
37 |
+
//IF this is a child category of the top one
|
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 |
+
//If there are children of this cat and it is a parent or child or the current cat
|
45 |
+
if( $asm->second_level_cat( $child_cat ) ){
|
46 |
+
#-- Create a new menu with all the children under it
|
47 |
+
echo '<ul class="grandchild-sidebar-menu">';
|
48 |
+
wp_list_categories("title_li=&exclude=".$instance['exclude']."&depth=3&child_of=" .$child_cat->cat_ID );
|
49 |
+
echo '</ul>';
|
50 |
+
|
51 |
+
}
|
52 |
+
}
|
53 |
+
} //End foreach
|
54 |
+
|
55 |
+
echo '</ul><!-- End #child-sidebar-menu -->';
|
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( $asm->include_parent() ){
|
64 |
+
echo '</ul><!-- End #parent-sidebar-menu -->';
|
65 |
+
}
|
legacy/page_list.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Ouput of the Advanced Sidebar Page Widget
|
4 |
+
* @author Mat Lipe
|
5 |
+
* @since 3.1.13
|
6 |
+
*
|
7 |
+
*
|
8 |
+
* @uses to edit, create a file named page_list.php and put in a folder in the your theme called 'advanced-sidebar-menu
|
9 |
+
* @uses copy the contents of the file into that file and edit at will
|
10 |
+
* @uses Do not edit this file in its original location or it will break on upgrade
|
11 |
+
*/
|
12 |
+
|
13 |
+
$asm->title();
|
14 |
+
|
15 |
+
#-- list the parent page if chosen
|
16 |
+
if( $asm->include_parent() ){
|
17 |
+
echo '<ul class="parent-sidebar-menu" >';
|
18 |
+
wp_list_pages("post_type=".$post_type."&sort_column=$order_by&title_li=&echo=1&depth=1&include=".$top_parent);
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
//If there are children start the Child Sidebar Menu
|
23 |
+
if( $child_pages ){
|
24 |
+
echo '<ul class="child-sidebar-menu">';
|
25 |
+
|
26 |
+
#-- If they want all the pages displayed always
|
27 |
+
if( $asm->display_all() ){
|
28 |
+
|
29 |
+
wp_list_pages("post_type=".$post_type."&sort_column=$order_by&title_li=&echo=1&child_of=".$top_parent."&depth=".$instance['levels']."&exclude=".$instance['exclude']);
|
30 |
+
} else {
|
31 |
+
|
32 |
+
#-- Display children of current page's parent only
|
33 |
+
foreach($result as $pID){
|
34 |
+
|
35 |
+
#-- If the page is not in the excluded ones
|
36 |
+
if( $asm->exclude( $pID->ID) ){
|
37 |
+
#--echo the current page from the $result
|
38 |
+
wp_list_pages("post_type=".$post_type."&sort_column=$order_by&title_li=&echo=1&depth=1&include=".$pID->ID);
|
39 |
+
}
|
40 |
+
|
41 |
+
#-- if the link that was just listed is the current page we are on
|
42 |
+
if( $asm->page_ancestor( $pID ) ){
|
43 |
+
|
44 |
+
//Get the children of this page
|
45 |
+
$grandkids = $asm->page_children($pID->ID );
|
46 |
+
if( $grandkids ){
|
47 |
+
#-- Create a new menu with all the children under it
|
48 |
+
echo '<ul class="grandchild-sidebar-menu">';
|
49 |
+
wp_list_pages("post_type=".$post_type."&sort_column=$order_by&title_li=&echo=1&exclude=".$instance['exclude']."&child_of=".$pID->ID);
|
50 |
+
|
51 |
+
echo '</ul>';
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
#-- Close the First Level menu
|
58 |
+
echo '</ul><!-- End child-sidebar-menu -->';
|
59 |
+
|
60 |
+
}
|
61 |
+
if( $asm->include_parent() ) {
|
62 |
+
echo '</ul><!-- .parent-sidebar-menu -->';
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
+
|
legacy/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 |
+
}
|
lib/advancedSidebarMenu.php
CHANGED
@@ -4,18 +4,18 @@
|
|
4 |
/**
|
5 |
* These Functions are Specific to the Advanced Sidebar Menu
|
6 |
* @author Mat Lipe
|
7 |
-
* @since 4.
|
8 |
*
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*/
|
11 |
class advancedSidebarMenu{
|
12 |
-
|
13 |
var $top_id; //Either the top cat or page
|
14 |
var $exclude;
|
15 |
var $ancestors; //For the category ancestors
|
16 |
var $count = 1; //Count for grandchild levels
|
17 |
var $order_by;
|
18 |
-
|
19 |
|
20 |
/**
|
21 |
* Removes the closing </li> tag from a list item to allow for child menus inside of it
|
@@ -46,7 +46,7 @@ class advancedSidebarMenu{
|
|
46 |
if( $grandkids ){
|
47 |
#-- Create a new menu with all the children under it
|
48 |
$content .= '<ul class="grandchild-sidebar-menu">';
|
49 |
-
$content .= wp_list_pages("post_type=".$this->post_type."&sort_column=$order_by&title_li=&echo=0&exclude=".$this->instance['exclude']."&child_of=".$pID->ID);
|
50 |
|
51 |
$content .= '</ul>';
|
52 |
}
|
@@ -55,7 +55,7 @@ class advancedSidebarMenu{
|
|
55 |
}
|
56 |
|
57 |
|
58 |
-
|
59 |
* Displays all the levels of the Grandchild Menus
|
60 |
*
|
61 |
* Will run until there are no children left for the current page's hyercy
|
@@ -68,7 +68,7 @@ class advancedSidebarMenu{
|
|
68 |
*
|
69 |
* @since 4.7.13
|
70 |
*/
|
71 |
-
|
72 |
static $count = 0;
|
73 |
$count++;
|
74 |
|
@@ -107,168 +107,170 @@ class advancedSidebarMenu{
|
|
107 |
return $content;
|
108 |
|
109 |
}
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
$title = apply_filters('widget_title', $this->instance['title'], $this->args, $this->instance );
|
234 |
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
|
256 |
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
|
|
|
|
272 |
|
273 |
} //End class
|
274 |
|
4 |
/**
|
5 |
* These Functions are Specific to the Advanced Sidebar Menu
|
6 |
* @author Mat Lipe
|
7 |
+
* @since 4.23.13
|
8 |
*
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*/
|
11 |
class advancedSidebarMenu{
|
12 |
+
var $instance; //The widget instance
|
13 |
var $top_id; //Either the top cat or page
|
14 |
var $exclude;
|
15 |
var $ancestors; //For the category ancestors
|
16 |
var $count = 1; //Count for grandchild levels
|
17 |
var $order_by;
|
18 |
+
|
19 |
|
20 |
/**
|
21 |
* Removes the closing </li> tag from a list item to allow for child menus inside of it
|
46 |
if( $grandkids ){
|
47 |
#-- Create a new menu with all the children under it
|
48 |
$content .= '<ul class="grandchild-sidebar-menu">';
|
49 |
+
$content .= wp_list_pages("post_type=".$this->post_type."&sort_column=$this->order_by&title_li=&echo=0&exclude=".$this->instance['exclude']."&child_of=".$pID->ID);
|
50 |
|
51 |
$content .= '</ul>';
|
52 |
}
|
55 |
}
|
56 |
|
57 |
|
58 |
+
/**
|
59 |
* Displays all the levels of the Grandchild Menus
|
60 |
*
|
61 |
* Will run until there are no children left for the current page's hyercy
|
68 |
*
|
69 |
* @since 4.7.13
|
70 |
*/
|
71 |
+
function displayGrandChildMenu($page){
|
72 |
static $count = 0;
|
73 |
$count++;
|
74 |
|
107 |
return $content;
|
108 |
|
109 |
}
|
110 |
+
|
111 |
+
|
112 |
+
|
113 |
+
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Adds the class for current page item etc to the page list when using a custom post type
|
117 |
+
* @param array $css the currrent css classes
|
118 |
+
* @param obj $this_menu_item the page being checked
|
119 |
+
* @return array
|
120 |
+
* @since 10.10.12
|
121 |
+
*/
|
122 |
+
function custom_post_type_css($css, $this_menu_item){
|
123 |
+
global $post;
|
124 |
+
if ( isset($post->ancestors) && in_array($this_menu_item->ID, (array)$post->ancestors) ){
|
125 |
+
$css[] = 'current_page_ancestor';
|
126 |
+
}
|
127 |
+
if ( $this_menu_item->ID == $post->ID ){
|
128 |
+
$css[] = 'current_page_item';
|
129 |
+
|
130 |
+
} elseif ($this_menu_item->ID == $post->post_parent ){
|
131 |
+
$css[] = 'current_page_parent';
|
132 |
+
}
|
133 |
+
return $css;
|
134 |
+
}
|
135 |
+
|
136 |
|
137 |
+
/**
|
138 |
+
*
|
139 |
+
* IF this is a top level category
|
140 |
+
* @param obj $cat the cat object
|
141 |
+
*/
|
142 |
+
function first_level_category( $cat ){
|
143 |
+
if( !in_array($cat->cat_ID, $this->exclude) && $cat->parent == $this->top_id){
|
144 |
+
return true;
|
145 |
+
} else {
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* If the cat is a second level cat
|
152 |
+
* @param obj $cat the cat
|
153 |
+
* @since 10.12.12
|
154 |
+
*/
|
155 |
+
function second_level_cat( $child_cat ){
|
156 |
+
//if this is the currrent cat or a parent of the current cat
|
157 |
+
if( $child_cat->cat_ID == get_query_var('cat' ) || in_array( $child_cat->cat_ID, $this->ancestors )){
|
158 |
+
$all_children = array();
|
159 |
+
$all_children = get_categories( array( 'child_of' => $child_cat->cat_ID ) );
|
160 |
+
if( !empty( $all_children ) ){
|
161 |
+
return true;
|
162 |
+
} else {
|
163 |
+
return false;
|
164 |
+
}
|
165 |
+
|
166 |
+
} else {
|
167 |
+
return false;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Determines if all the children should be included
|
173 |
+
* @since 7/16/12
|
174 |
+
* @return bool
|
175 |
+
*/
|
176 |
+
function display_all(){
|
177 |
+
if( $this->instance['display_all'] == 'checked' ){
|
178 |
+
return true;
|
179 |
+
} else {
|
180 |
+
return false;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
*
|
186 |
+
* Returns and array of all the children of a page
|
187 |
+
* @param int $pID the id of the page
|
188 |
+
* @since 4.8.13
|
189 |
+
*/
|
190 |
+
function page_children( $pID ){
|
191 |
+
global $wpdb, $table_prefix;
|
192 |
+
return $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID." AND post_status='publish' ORDER By ".$this->order_by );
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
*
|
198 |
+
* Determines if this is an ancestor or the current post
|
199 |
+
* @param obj $pID the post object
|
200 |
+
* @since 7/19/12
|
201 |
+
*/
|
202 |
+
function page_ancestor( $pID ){
|
203 |
+
global $post;
|
204 |
+
if($pID->ID == $post->ID or $pID->ID == $post->post_parent or @in_array($pID->ID, $post->ancestors) ){
|
205 |
+
return true;
|
206 |
+
} else {
|
207 |
+
return false;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Determines if the parent page or cat should be included
|
214 |
+
* @since 7/16/12
|
215 |
+
* @return bool
|
216 |
+
*/
|
217 |
+
function include_parent(){
|
218 |
+
if( ($this->instance['include_parent'] == 'checked') && (!in_array($this->top_id, $this->exclude)) ){
|
219 |
+
return true;
|
220 |
+
} else {
|
221 |
+
return false;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
|
226 |
+
/**
|
227 |
+
* Echos the title of the widget to the page
|
228 |
+
* @since 4.7.13
|
229 |
+
*/
|
230 |
+
function title(){
|
231 |
+
if( $this->instance['title'] != '' ){
|
232 |
+
|
233 |
$title = apply_filters('widget_title', $this->instance['title'], $this->args, $this->instance );
|
234 |
|
235 |
+
echo '<h4 class="widgettitle">' . $title . '</h4>';
|
236 |
+
}
|
237 |
+
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
/**
|
242 |
+
*
|
243 |
+
* Checks is this id is excluded or not
|
244 |
+
* @param int $id the id to check
|
245 |
+
* @return bool
|
246 |
+
*/
|
247 |
+
function exclude( $id ){
|
248 |
+
if( !in_array( $id, $this->exclude ) ){
|
249 |
+
return true;
|
250 |
+
} else {
|
251 |
+
return false;
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
|
256 |
|
257 |
+
/**
|
258 |
+
* Allows for Overwritting files in the child theme
|
259 |
+
* @since 4.23.13
|
260 |
+
* @param string $file the name of the file to overwrite
|
261 |
+
*/
|
262 |
|
263 |
+
static function file_hyercy( $file, $legacy = false ){
|
264 |
+
if ( $theme_file = locate_template(array('advanced-sidebar-menu/'.$file)) ) {
|
265 |
+
$file = $theme_file;
|
266 |
+
} elseif( $legacy ){
|
267 |
+
$file = ADVANCED_SIDEBAR_LEGACY_DIR . $file;
|
268 |
+
} else {
|
269 |
+
$file = ADVANCED_SIDEBAR_VIEWS_DIR . $file;
|
270 |
+
}
|
271 |
+
return apply_filters( 'advanced_sidebar_menu_view_file', $file, $legacy );
|
272 |
+
|
273 |
+
}
|
274 |
|
275 |
} //End class
|
276 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypa
|
|
4 |
Tags: menus, sidebar menu, heirchy, category menu, pages menu
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 4.1.
|
8 |
|
9 |
Creates a widget for both page and categories that will display the current page/category and all child pages or categories.
|
10 |
|
4 |
Tags: menus, sidebar menu, heirchy, category menu, pages menu
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 4.1.2
|
8 |
|
9 |
Creates a widget for both page and categories that will display the current page/category and all child pages or categories.
|
10 |
|
views/page_list.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* The Ouput of the Advanced Sidebar Page Widget
|
4 |
* @author Mat Lipe
|
5 |
-
* @since 4.
|
6 |
*
|
7 |
*
|
8 |
* @uses to edit, create a file named page_list.php and put in a folder in the your theme called 'advanced-sidebar-menu
|
@@ -32,8 +32,8 @@ if( $child_pages ){
|
|
32 |
} else {
|
33 |
|
34 |
#-- Display children of current page's parent only
|
35 |
-
foreach($
|
36 |
-
|
37 |
#-- If the page is not in the excluded ones
|
38 |
if( $asm->exclude( $pID->ID) ){
|
39 |
#--echo the current page from the $result
|
2 |
/**
|
3 |
* The Ouput of the Advanced Sidebar Page Widget
|
4 |
* @author Mat Lipe
|
5 |
+
* @since 4.23.13
|
6 |
*
|
7 |
*
|
8 |
* @uses to edit, create a file named page_list.php and put in a folder in the your theme called 'advanced-sidebar-menu
|
32 |
} else {
|
33 |
|
34 |
#-- Display children of current page's parent only
|
35 |
+
foreach($child_pages as $pID){
|
36 |
+
|
37 |
#-- If the page is not in the excluded ones
|
38 |
if( $asm->exclude( $pID->ID) ){
|
39 |
#--echo the current page from the $result
|
widgets/category.widget.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Creates a Widget of parent Child Categories
|
6 |
*
|
7 |
* @author mat lipe
|
8 |
-
* @since 4.
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*
|
11 |
*/
|
@@ -45,7 +45,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
45 |
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
46 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
47 |
|
48 |
-
<p> Use
|
49 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
50 |
<?php echo $instance['css']; ?>/></p>
|
51 |
|
@@ -80,6 +80,15 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
80 |
|
81 |
<p> Categories to Exclude, Comma Separated:<input id="<?php echo $this->get_field_name('exclude'); ?>"
|
82 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
<p> Always Display Child Categories <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
85 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
@@ -103,6 +112,10 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
103 |
}
|
104 |
}
|
105 |
echo '</select></p></span>';
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
|
108 |
#------------------------------------------------------------------------------------------------------------------------------
|
@@ -119,7 +132,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
119 |
$instance['single'] = strip_tags($new_instance['single']); //Display on single pages
|
120 |
$instance['new_widget'] = strip_tags($new_instance['new_widget']); //Create a new widget for each single category
|
121 |
$instance['title'] = strip_tags($new_instance['title']);
|
122 |
-
|
123 |
return $instance;
|
124 |
}
|
125 |
|
@@ -165,14 +178,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
165 |
} elseif( is_category() ){
|
166 |
$cat_ids[] = get_query_var('cat');
|
167 |
}
|
168 |
-
|
169 |
-
//Bring in the Styling
|
170 |
-
if( $instance['css'] == 'checked' ){
|
171 |
-
echo '<style type="text/css">';
|
172 |
-
include( $asm->file_hyercy( 'sidebar-menu.css' ) );
|
173 |
-
echo '</style>';
|
174 |
-
}
|
175 |
-
|
176 |
//Go through each category there will be only one if this is a category page mulitple possible if this is single
|
177 |
foreach( $cat_ids as $cat_id ){
|
178 |
$cat_ancestors = array ();
|
@@ -224,9 +230,21 @@ class advanced_sidebar_menu_category extends WP_Widget {
|
|
224 |
} else {
|
225 |
$close = false;
|
226 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
//Bring in the view
|
229 |
-
require( $asm->file_hyercy( 'category_list.php' ) );
|
230 |
|
231 |
echo apply_filters('advanced_sidebar_menu_category_widget_output', $content, $args, $instance );
|
232 |
|
5 |
* Creates a Widget of parent Child Categories
|
6 |
*
|
7 |
* @author mat lipe
|
8 |
+
* @since 4.23.13
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*
|
11 |
*/
|
45 |
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
46 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
47 |
|
48 |
+
<p> Use this plugins styling <input id="<?php echo $this->get_field_name('css'); ?>"
|
49 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
50 |
<?php echo $instance['css']; ?>/></p>
|
51 |
|
80 |
|
81 |
<p> Categories to Exclude, Comma Separated:<input id="<?php echo $this->get_field_name('exclude'); ?>"
|
82 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
83 |
+
|
84 |
+
|
85 |
+
<p> Legacy Mode: (use pre 4.0 structure and css) <input id="<?php echo $this->get_field_name('legacy_mode'); ?>"
|
86 |
+
name="<?php echo $this->get_field_name('legacy_mode'); ?>" type="checkbox" value="checked"
|
87 |
+
<?php echo $instance['legacy_mode']; ?>/>
|
88 |
+
</p>
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
|
93 |
<p> Always Display Child Categories <input id="<?php echo $this->get_field_name('display_all'); ?>"
|
94 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
112 |
}
|
113 |
}
|
114 |
echo '</select></p></span>';
|
115 |
+
|
116 |
+
|
117 |
+
do_action('advanced_sidebar_menu_category_widget_form', $instance );
|
118 |
+
|
119 |
}
|
120 |
|
121 |
#------------------------------------------------------------------------------------------------------------------------------
|
132 |
$instance['single'] = strip_tags($new_instance['single']); //Display on single pages
|
133 |
$instance['new_widget'] = strip_tags($new_instance['new_widget']); //Create a new widget for each single category
|
134 |
$instance['title'] = strip_tags($new_instance['title']);
|
135 |
+
$instance['legacy_mode'] = strip_tags($new_instance['legacy_mode']);
|
136 |
return $instance;
|
137 |
}
|
138 |
|
178 |
} elseif( is_category() ){
|
179 |
$cat_ids[] = get_query_var('cat');
|
180 |
}
|
181 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
//Go through each category there will be only one if this is a category page mulitple possible if this is single
|
183 |
foreach( $cat_ids as $cat_id ){
|
184 |
$cat_ancestors = array ();
|
230 |
} else {
|
231 |
$close = false;
|
232 |
}
|
233 |
+
|
234 |
+
|
235 |
+
|
236 |
+
$legacy = isset( $instance['legacy_mode'] );
|
237 |
+
|
238 |
+
if( $instance['css'] == 'checked' ){
|
239 |
+
echo '<style type="text/css">';
|
240 |
+
include( $asm->file_hyercy('sidebar-menu.css', $legacy ) );
|
241 |
+
echo '</style>';
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
|
246 |
//Bring in the view
|
247 |
+
require( $asm->file_hyercy( 'category_list.php', $legacy ) );
|
248 |
|
249 |
echo apply_filters('advanced_sidebar_menu_category_widget_output', $content, $args, $instance );
|
250 |
|
widgets/page.widget.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Creates a Widget of parent Child Pages
|
6 |
*
|
7 |
* @author mat lipe
|
8 |
-
* @since 4.
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*
|
11 |
*/
|
@@ -32,46 +32,46 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
32 |
* Not of ton of options here but who need them
|
33 |
* Most of the magic happens automatically
|
34 |
*
|
35 |
-
* @since 4.
|
36 |
*/
|
37 |
function form( $instance ) {
|
38 |
?>
|
39 |
<p> Title <br>
|
40 |
-
<input id="<?php echo $this->
|
41 |
name="<?php echo $this->get_field_name('title'); ?>" size="50" type="text" value="<?php echo $instance['title']; ?>"/></p>
|
42 |
|
43 |
-
<p> Include Parent Page: <input id="<?php echo $this->
|
44 |
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
45 |
<?php echo $instance['include_parent']; ?>/></p>
|
46 |
|
47 |
|
48 |
-
<p> Include Parent Even With No Children: <input id="<?php echo $this->
|
49 |
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
50 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
51 |
|
52 |
-
<p> Use this Plugin's Styling: <input id="<?php echo $this->
|
53 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
54 |
<?php echo $instance['css']; ?>/></p>
|
55 |
|
56 |
-
<p> Pages to Exclude, Comma Separated: <input id="<?php echo $this->
|
57 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
58 |
-
<p> Legacy Mode: (
|
59 |
name="<?php echo $this->get_field_name('legacy_mode'); ?>" type="checkbox" value="checked"
|
60 |
<?php echo $instance['legacy_mode']; ?>/>
|
61 |
</p>
|
62 |
|
63 |
-
<p> Always Display Child Pages: <input id="<?php echo $this->
|
64 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
65 |
-
onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->
|
66 |
<?php echo $instance['display_all']; ?>/></p>
|
67 |
|
68 |
-
<span id="levels-<?php echo $this->
|
69 |
-
if( $instance['display_all'] == checked ){
|
70 |
echo 'display:block';
|
71 |
} else {
|
72 |
echo 'display:none';
|
73 |
} ?>">
|
74 |
-
<p> Levels to Display: <select id="<?php echo $this->
|
75 |
name="<?php echo $this->get_field_name('levels'); ?>">
|
76 |
<?php
|
77 |
for( $i= 1; $i<6; $i++ ){
|
@@ -83,6 +83,9 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
83 |
}
|
84 |
echo '</select></p></span>';
|
85 |
|
|
|
|
|
|
|
86 |
|
87 |
}
|
88 |
|
@@ -170,22 +173,24 @@ class advanced_sidebar_menu_page extends WP_Widget {
|
|
170 |
|
171 |
//for depreciation
|
172 |
$p = $top_parent;
|
173 |
-
$result = $child_pages;
|
174 |
|
175 |
#---- if there are no children do not display the parent unless it is check to do so
|
176 |
if( ($child_pages) || (($instance['include_childless_parent'] == 'checked') && (!in_array($top_parent, $exclude)) ) ){
|
177 |
|
|
|
|
|
178 |
if( $instance['css'] == 'checked' ){
|
179 |
echo '<style type="text/css">';
|
180 |
-
include( $asm->file_hyercy('sidebar-menu.css' ) );
|
181 |
echo '</style>';
|
182 |
}
|
183 |
|
184 |
|
185 |
//Start the menu
|
186 |
echo $before_widget;
|
187 |
-
#-- Bring in the
|
188 |
-
require( $asm->file_hyercy( 'page_list.php' ) );
|
189 |
echo apply_filters('advanced_sidebar_menu_page_widget_output',$content, $args, $instance );
|
190 |
echo $after_widget;
|
191 |
|
5 |
* Creates a Widget of parent Child Pages
|
6 |
*
|
7 |
* @author mat lipe
|
8 |
+
* @since 4.23.13
|
9 |
* @package Advanced Sidebar Menu
|
10 |
*
|
11 |
*/
|
32 |
* Not of ton of options here but who need them
|
33 |
* Most of the magic happens automatically
|
34 |
*
|
35 |
+
* @since 4.23.13
|
36 |
*/
|
37 |
function form( $instance ) {
|
38 |
?>
|
39 |
<p> Title <br>
|
40 |
+
<input id="<?php echo $this->get_field_id('title'); ?>"
|
41 |
name="<?php echo $this->get_field_name('title'); ?>" size="50" type="text" value="<?php echo $instance['title']; ?>"/></p>
|
42 |
|
43 |
+
<p> Include Parent Page: <input id="<?php echo $this->get_field_id('include_parent'); ?>"
|
44 |
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
45 |
<?php echo $instance['include_parent']; ?>/></p>
|
46 |
|
47 |
|
48 |
+
<p> Include Parent Even With No Children: <input id="<?php echo $this->get_field_id('include_childless_parent'); ?>"
|
49 |
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
50 |
<?php echo $instance['include_childless_parent']; ?>/></p>
|
51 |
|
52 |
+
<p> Use this Plugin's Styling: <input id="<?php echo $this->get_field_id('css'); ?>"
|
53 |
name="<?php echo $this->get_field_name('css'); ?>" type="checkbox" value="checked"
|
54 |
<?php echo $instance['css']; ?>/></p>
|
55 |
|
56 |
+
<p> Pages to Exclude, Comma Separated: <input id="<?php echo $this->get_field_id('exclude'); ?>"
|
57 |
name="<?php echo $this->get_field_name('exclude'); ?>" type="text" value="<?php echo $instance['exclude']; ?>"/></p>
|
58 |
+
<p> Legacy Mode: (use pre 4.0 structure and css) <input id="<?php echo $this->get_field_name('legacy_mode'); ?>"
|
59 |
name="<?php echo $this->get_field_name('legacy_mode'); ?>" type="checkbox" value="checked"
|
60 |
<?php echo $instance['legacy_mode']; ?>/>
|
61 |
</p>
|
62 |
|
63 |
+
<p> Always Display Child Pages: <input id="<?php echo $this->get_field_id('display_all'); ?>"
|
64 |
name="<?php echo $this->get_field_name('display_all'); ?>" type="checkbox" value="checked"
|
65 |
+
onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_id('levels'); ?>' )"
|
66 |
<?php echo $instance['display_all']; ?>/></p>
|
67 |
|
68 |
+
<span id="levels-<?php echo $this->get_field_id('levels'); ?>" style="<?php
|
69 |
+
if( $instance['display_all'] == 'checked' ){
|
70 |
echo 'display:block';
|
71 |
} else {
|
72 |
echo 'display:none';
|
73 |
} ?>">
|
74 |
+
<p> Levels to Display: <select id="<?php echo $this->get_field_id('levels'); ?>"
|
75 |
name="<?php echo $this->get_field_name('levels'); ?>">
|
76 |
<?php
|
77 |
for( $i= 1; $i<6; $i++ ){
|
83 |
}
|
84 |
echo '</select></p></span>';
|
85 |
|
86 |
+
|
87 |
+
do_action('advanced_sidebar_menu_page_widget_form', $instance, $this->get_field_name('parent_only'), $this->get_field_id('parent_only'));
|
88 |
+
|
89 |
|
90 |
}
|
91 |
|
173 |
|
174 |
//for depreciation
|
175 |
$p = $top_parent;
|
176 |
+
$result = $child_pages = apply_filters( 'advanced_sidebar_menu_child_pages', $child_pages, $post, $args, $instance );
|
177 |
|
178 |
#---- if there are no children do not display the parent unless it is check to do so
|
179 |
if( ($child_pages) || (($instance['include_childless_parent'] == 'checked') && (!in_array($top_parent, $exclude)) ) ){
|
180 |
|
181 |
+
$legacy = isset( $instance['legacy_mode'] );
|
182 |
+
|
183 |
if( $instance['css'] == 'checked' ){
|
184 |
echo '<style type="text/css">';
|
185 |
+
include( $asm->file_hyercy('sidebar-menu.css', $legacy ) );
|
186 |
echo '</style>';
|
187 |
}
|
188 |
|
189 |
|
190 |
//Start the menu
|
191 |
echo $before_widget;
|
192 |
+
#-- Bring in the
|
193 |
+
require( $asm->file_hyercy( 'page_list.php', $legacy ) );
|
194 |
echo apply_filters('advanced_sidebar_menu_page_widget_output',$content, $args, $instance );
|
195 |
echo $after_widget;
|
196 |
|