Advanced Sidebar Menu - Version 7.4.7

Version Description

Update to support PRO version 3.5.0

Download this release

Release Info

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

Code changes from version 7.4.6 to 7.4.7

advanced-sidebar-menu.php CHANGED
@@ -4,7 +4,7 @@
4
* Plugin URI: https://matlipe.com/advanced-sidebar-menu/
5
* Description: Creates dynamic menus based on parent/child relationship of your pages or categories.
6
* Author: Mat Lipe
7
- * Version: 7.4.6
8
* Author URI: https://matlipe.com
9
* Text Domain: advanced-sidebar-menu
10
*
@@ -15,7 +15,7 @@ if ( defined( 'ADVANCED_SIDEBAR_BASIC_VERSION' ) ) {
15
return;
16
}
17
18
- define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.4.6' );
19
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
20
21
if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
4
* Plugin URI: https://matlipe.com/advanced-sidebar-menu/
5
* Description: Creates dynamic menus based on parent/child relationship of your pages or categories.
6
* Author: Mat Lipe
7
+ * Version: 7.4.7
8
* Author URI: https://matlipe.com
9
* Text Domain: advanced-sidebar-menu
10
*
15
return;
16
}
17
18
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.4.7' );
19
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
20
21
if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: menus, sidebar menu, hierarchy, category menu, pages menu
6
Requires at least: 4.7.0
7
Tested up to: 5.0.3
8
Requires PHP: 5.2.4
9
- Stable tag: 7.4.6
10
11
== Description ==
12
@@ -16,7 +16,7 @@ Keeps the menu clean and usable. Only related items display so you don't have to
16
17
<strong>Check out <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/">Advanced Sidebar Menu Pro</a> for more features including priority support, the ability to customize the look and feel, custom link text, excluding of pages, category ordering, accordions, custom post types, custom taxonomies, and so much more!</strong>
18
19
- <blockquote><a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Pro version 3.4.0</a> is now available with support for Beaver Builder!</blockquote>
20
21
<h4>Features</h4>
22
* Page and Category widgets.
@@ -71,12 +71,13 @@ Keeps the menu clean and usable. Only related items display so you don't have to
71
* Ability to select and display custom taxonomies.
72
* Optionally display the current page's parents, grandparents, and children only.
73
* Optionally display child page siblings when on a child page. With our without grandchildren available. .
74
- * Ability to display the widgets everywhere the sidebar displays. **NEW**
75
- * Ability to select the parent page/category when using the display widget everywhere option. **NEW**
76
* Ability to display assigned posts or custom post types under categories. **NEW**
77
- * Ability to limit the number of posts or custom post types to display under categories. **NEW**
78
- * Support for custom navigation menus from Appearance -> Menus. **NEW**
79
- * Ability to display the current Navigation Menu's items parents and children only. **NEW**
80
* Optionally display the top level Navigation Menu's items when there are no child items or not viewing a menu item. **NEW**
81
* Access to members only support area.
82
@@ -228,6 +229,9 @@ Yes. Based on whatever page, post, or category you are on, the menu will change
228
229
230
== Upgrade Notice ==
231
= 7.4.2 =
232
Update to support PRO version 3.4.3
233
6
Requires at least: 4.7.0
7
Tested up to: 5.0.3
8
Requires PHP: 5.2.4
9
+ Stable tag: 7.4.7
10
11
== Description ==
12
16
17
<strong>Check out <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/">Advanced Sidebar Menu Pro</a> for more features including priority support, the ability to customize the look and feel, custom link text, excluding of pages, category ordering, accordions, custom post types, custom taxonomies, and so much more!</strong>
18
19
+ <blockquote><a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Pro version 3.5.0</a> is now available with support for displaying posts under categories on any level!</blockquote>
20
21
<h4>Features</h4>
22
* Page and Category widgets.
71
* Ability to select and display custom taxonomies.
72
* Optionally display the current page's parents, grandparents, and children only.
73
* Optionally display child page siblings when on a child page. With our without grandchildren available. .
74
+ * Ability to display the widgets everywhere the sidebar displays.
75
+ * Ability to select the parent page/category when using the display widget everywhere option.
76
* Ability to display assigned posts or custom post types under categories. **NEW**
77
+ * Ability to select which levels of categories assigned posts should display under. **NEW**
78
+ * Ability to limit the number of posts or custom post types to display under categories.
79
+ * Support for custom navigation menus from Appearance -> Menus.
80
+ * Ability to display the current Navigation Menu's items parents and children only.
81
* Optionally display the top level Navigation Menu's items when there are no child items or not viewing a menu item. **NEW**
82
* Access to members only support area.
83
229
230
231
== Upgrade Notice ==
232
+ = 7.4.7 =
233
+ Update to support PRO version 3.5.0
234
+
235
= 7.4.2 =
236
Update to support PRO version 3.4.3
237
src/List_Pages.php CHANGED
@@ -16,7 +16,6 @@
16
* @author Mat Lipe <mat@matlipe.com>
17
*
18
* @since 5.0.0
19
- *
20
*/
21
class Advanced_Sidebar_Menu_List_Pages {
22
@@ -123,7 +122,6 @@ class Advanced_Sidebar_Menu_List_Pages {
123
/**
124
* Add the custom classes to the list items
125
*
126
- *
127
* @param array $classes
128
* @param \WP_Post $post
129
*
@@ -139,7 +137,7 @@ class Advanced_Sidebar_Menu_List_Pages {
139
$classes[] = 'has_children';
140
}
141
142
- //page posts are handled by wp core. This is for custom post types
143
if ( 'page' !== $post->post_type ) {
144
$ancestors = get_post_ancestors( $post );
145
if ( ! empty( $ancestors ) && in_array( $this->current_page->ID, $ancestors, false ) ) {
@@ -167,10 +165,10 @@ class Advanced_Sidebar_Menu_List_Pages {
167
}
168
$args = $this->args;
169
switch ( $level ) {
170
- case 'parent':
171
$args['include'] = $this->menu->get_top_parent_id();
172
break;
173
- case 'display-all':
174
$args['child_of'] = $this->menu->get_top_parent_id();
175
$args['depth'] = $this->menu->get_levels_to_display();
176
$args['sort_column'] = $this->menu->get_order_by();
@@ -232,7 +230,7 @@ class Advanced_Sidebar_Menu_List_Pages {
232
if ( is_string( $args['exclude'] ) ) {
233
$args['exclude'] = explode( ',', $args['exclude'] );
234
}
235
- //sanitize, mostly to keep spaces out
236
$args['exclude'] = preg_replace( '/[^0-9,]/', '', implode( ',', apply_filters( 'wp_list_pages_excludes', $args['exclude'] ) ) );
237
238
return apply_filters( 'advanced_sidebar_menu_list_pages_args', $args, $this );
@@ -313,7 +311,7 @@ class Advanced_Sidebar_Menu_List_Pages {
313
* @return WP_Post[]
314
*/
315
public function get_child_pages( $parent_page_id, $is_first_level = false ) {
316
- //holds a unique key so Cache can distinguish calls
317
$this->current_children_parent = $parent_page_id;
318
319
$cache = Advanced_Sidebar_Menu_Cache::instance();
@@ -332,14 +330,18 @@ class Advanced_Sidebar_Menu_List_Pages {
332
333
// We only filter the first level with this filter for backward pro compatibility.
334
if ( $is_first_level ) {
335
- $child_pages = apply_filters_deprecated( 'advanced_sidebar_menu_child_pages', array(
336
- $child_pages,
337
- $this->current_page,
338
- $this->menu->instance,
339
- $this->menu->args,
340
- $this->menu,
341
- ), '7.1.0', 'advanced-sidebar-menu/list-pages/first-level-child-pages' );
342
-
343
344
$child_pages = apply_filters( 'advanced-sidebar-menu/list-pages/first-level-child-pages', $child_pages, $this, $this->menu );
345
}
16
* @author Mat Lipe <mat@matlipe.com>
17
*
18
* @since 5.0.0
19
*/
20
class Advanced_Sidebar_Menu_List_Pages {
21
122
/**
123
* Add the custom classes to the list items
124
*
125
* @param array $classes
126
* @param \WP_Post $post
127
*
137
$classes[] = 'has_children';
138
}
139
140
+ // page posts are handled by wp core. This is for custom post types
141
if ( 'page' !== $post->post_type ) {
142
$ancestors = get_post_ancestors( $post );
143
if ( ! empty( $ancestors ) && in_array( $this->current_page->ID, $ancestors, false ) ) {
165
}
166
$args = $this->args;
167
switch ( $level ) {
168
+ case Advanced_Sidebar_Menu_Menus_Page::LEVEL_PARENT:
169
$args['include'] = $this->menu->get_top_parent_id();
170
break;
171
+ case Advanced_Sidebar_Menu_Menus_Page::LEVEL_DISPLAY_ALL:
172
$args['child_of'] = $this->menu->get_top_parent_id();
173
$args['depth'] = $this->menu->get_levels_to_display();
174
$args['sort_column'] = $this->menu->get_order_by();
230
if ( is_string( $args['exclude'] ) ) {
231
$args['exclude'] = explode( ',', $args['exclude'] );
232
}
233
+ // sanitize, mostly to keep spaces out
234
$args['exclude'] = preg_replace( '/[^0-9,]/', '', implode( ',', apply_filters( 'wp_list_pages_excludes', $args['exclude'] ) ) );
235
236
return apply_filters( 'advanced_sidebar_menu_list_pages_args', $args, $this );
311
* @return WP_Post[]
312
*/
313
public function get_child_pages( $parent_page_id, $is_first_level = false ) {
314
+ // holds a unique key so Cache can distinguish calls
315
$this->current_children_parent = $parent_page_id;
316
317
$cache = Advanced_Sidebar_Menu_Cache::instance();
330
331
// We only filter the first level with this filter for backward pro compatibility.
332
if ( $is_first_level ) {
333
+ $child_pages = apply_filters_deprecated(
334
+ 'advanced_sidebar_menu_child_pages',
335
+ array(
336
+ $child_pages,
337
+ $this->current_page,
338
+ $this->menu->instance,
339
+ $this->menu->args,
340
+ $this->menu,
341
+ ),
342
+ '7.1.0',
343
+ 'advanced-sidebar-menu/list-pages/first-level-child-pages'
344
+ );
345
346
$child_pages = apply_filters( 'advanced-sidebar-menu/list-pages/first-level-child-pages', $child_pages, $this, $this->menu );
347
}
src/Menus/Abstract.php CHANGED
@@ -8,19 +8,22 @@
8
*/
9
abstract class Advanced_Sidebar_Menu_Menus_Abstract {
10
// keys available in both widgets.
11
- const TITLE = 'title';
12
- const INCLUDE_PARENT = 'include_parent';
13
const INCLUDE_CHILDLESS_PARENT = 'include_childless_parent';
14
- const ORDER = 'order';
15
- const ORDER_BY = 'order_by';
16
- const USE_PLUGIN_STYLES = 'css';
17
- const EXCLUDE = 'exclude';
18
- const DISPLAY_ALL = 'display_all';
19
- const LEVELS = 'levels';
20
21
/**
22
- * args
23
- *
24
* Widget Args
25
*
26
* @var array
@@ -28,8 +31,6 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
28
public $args = array();
29
30
/**
31
- * exclude
32
- *
33
* @deprecated
34
*
35
* @var array
@@ -44,8 +45,6 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
44
public $instance;
45
46
/**
47
- * levels
48
- *
49
* @deprecated
50
*
51
* @var int
@@ -53,8 +52,6 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
53
public $levels = 100;
54
55
/**
56
- * order
57
- *
58
* @deprecated 7.0.0
59
*
60
* @var string
@@ -62,8 +59,6 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
62
public $order = 'ASC';
63
64
/**
65
- * order_by
66
- *
67
* @deprecated 7.0.0
68
*
69
* @var string
@@ -219,7 +214,6 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
219
}
220
}
221
222
- /********************* static *******************************/
223
224
/**
225
*
8
*/
9
abstract class Advanced_Sidebar_Menu_Menus_Abstract {
10
// keys available in both widgets.
11
+ const TITLE = 'title';
12
+ const INCLUDE_PARENT = 'include_parent';
13
const INCLUDE_CHILDLESS_PARENT = 'include_childless_parent';
14
+ const ORDER = 'order';
15
+ const ORDER_BY = 'order_by';
16
+ const USE_PLUGIN_STYLES = 'css';
17
+ const EXCLUDE = 'exclude';
18
+ const DISPLAY_ALL = 'display_all';
19
+ const LEVELS = 'levels';
20
+
21
+ const LEVEL_CHILD = 'child';
22
+ const LEVEL_DISPLAY_ALL = 'display-all';
23
+ const LEVEL_GRANDCHILD = 'grandchild';
24
+ const LEVEL_PARENT = 'parent';
25
26
/**
27
* Widget Args
28
*
29
* @var array
31
public $args = array();
32
33
/**
34
* @deprecated
35
*
36
* @var array
45
public $instance;
46
47
/**
48
* @deprecated
49
*
50
* @var int
52
public $levels = 100;
53
54
/**
55
* @deprecated 7.0.0
56
*
57
* @var string
59
public $order = 'ASC';
60
61
/**
62
* @deprecated 7.0.0
63
*
64
* @var string
214
}
215
}
216
217
218
/**
219
*
src/Menus/Category.php CHANGED
@@ -1,17 +1,15 @@
1
<?php
2
3
-
4
/**
5
* Advanced_Sidebar_Menu_Menus_Category
6
*
7
* @author Mat Lipe
8
* @since 7.0.0
9
- *
10
*/
11
class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_Abstract {
12
const WIDGET = 'category';
13
14
- const DISPLAY_ON_SINGLE = 'single';
15
const EACH_CATEGORY_DISPLAY = 'new_widget';
16
17
/**
@@ -44,7 +42,6 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
44
* If we are on a post we could potentially have more than one
45
* top level term so we end up calling this more than once.
46
*
47
- *
48
* @param WP_Term $term
49
*
50
* @return void
@@ -76,20 +73,21 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
76
if ( null === $level ) {
77
return $args;
78
}
79
switch ( $level ) {
80
- case 'parent':
81
$args['hide_empty'] = 0;
82
$args['include'] = trim( $this->get_top_parent_id() );
83
break;
84
- case 'display-all':
85
$args['child_of'] = $this->get_top_parent_id();
86
$args['depth'] = $this->get_levels_to_display();
87
break;
88
- case 'child':
89
$args['include'] = $term->term_id;
90
$args['depth'] = 1;
91
break;
92
- case 'grandchild':
93
$args['child_of'] = $term->term_id;
94
$args['depth'] = $this->get_menu_depth();
95
break;
@@ -107,7 +105,6 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
107
*
108
* @see Advanced_Sidebar_Menu_Menus_Category::set_current_top_level_term()
109
*
110
- *
111
* @return array
112
*/
113
public function get_child_terms() {
@@ -161,12 +158,14 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
161
}
162
$terms = array();
163
if ( ! empty( $top_level_term_ids ) ) {
164
- $terms = get_terms( array(
165
- 'include' => array_unique( array_filter( $top_level_term_ids ) ),
166
- 'hide_empty' => false,
167
- 'orderby' => $this->get_order_by(),
168
- 'order' => $this->get_order(),
169
- ) );
170
}
171
if ( is_wp_error( $terms ) ) {
172
return array();
@@ -241,7 +240,6 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
241
* 3. If children empty and not include childless parent we don't display
242
* 4. If children empty and the top parent is excluded we don't display
243
*
244
- *
245
* @param array $child_terms
246
*
247
* @return bool
@@ -325,9 +323,9 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
325
}
326
} while ( $term );
327
328
- //we only track the last calls ancestors because we only care
329
- //about these when on a single term archive
330
- $this->ancestors = array_reverse( $cat_ancestors );
331
list( $_, $top_cat ) = $this->ancestors;
332
333
return $top_cat;
@@ -338,7 +336,7 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
338
/**
339
* If a category has children add the has_children class
340
*
341
- * @param [] $classes
342
* @param \WP_Term $category
343
*
344
* @return array
@@ -386,7 +384,7 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
386
$return = false;
387
if ( (int) $term->term_id === (int) $this->top_level_term->term_id || in_array( $term->term_id, $this->ancestors, false ) ) {
388
$children = get_term_children( $term->term_id, $this->get_taxonomy() );
389
- if ( ! empty( $children) ) {
390
$return = true;
391
}
392
}
1
<?php
2
3
/**
4
* Advanced_Sidebar_Menu_Menus_Category
5
*
6
* @author Mat Lipe
7
* @since 7.0.0
8
*/
9
class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_Abstract {
10
const WIDGET = 'category';
11
12
+ const DISPLAY_ON_SINGLE = 'single';
13
const EACH_CATEGORY_DISPLAY = 'new_widget';
14
15
/**
42
* If we are on a post we could potentially have more than one
43
* top level term so we end up calling this more than once.
44
*
45
* @param WP_Term $term
46
*
47
* @return void
73
if ( null === $level ) {
74
return $args;
75
}
76
+ // @todo switch these to constants to be use across basic and pro.
77
switch ( $level ) {
78
+ case self::LEVEL_PARENT:
79
$args['hide_empty'] = 0;
80
$args['include'] = trim( $this->get_top_parent_id() );
81
break;
82
+ case self::LEVEL_DISPLAY_ALL:
83
$args['child_of'] = $this->get_top_parent_id();
84
$args['depth'] = $this->get_levels_to_display();
85
break;
86
+ case self::LEVEL_CHILD:
87
$args['include'] = $term->term_id;
88
$args['depth'] = 1;
89
break;
90
+ case self::LEVEL_GRANDCHILD:
91
$args['child_of'] = $term->term_id;
92
$args['depth'] = $this->get_menu_depth();
93
break;
105
*
106
* @see Advanced_Sidebar_Menu_Menus_Category::set_current_top_level_term()
107
*
108
* @return array
109
*/
110
public function get_child_terms() {
158
}
159
$terms = array();
160
if ( ! empty( $top_level_term_ids ) ) {
161
+ $terms = get_terms(
162
+ array(
163
+ 'include' => array_unique( array_filter( $top_level_term_ids ) ),
164
+ 'hide_empty' => false,
165
+ 'orderby' => $this->get_order_by(),
166
+ 'order' => $this->get_order(),
167
+ )
168
+ );
169
}
170
if ( is_wp_error( $terms ) ) {
171
return array();
240
* 3. If children empty and not include childless parent we don't display
241
* 4. If children empty and the top parent is excluded we don't display
242
*
243
* @param array $child_terms
244
*
245
* @return bool
323
}
324
} while ( $term );
325
326
+ // we only track the last calls ancestors because we only care
327
+ // about these when on a single term archive
328
+ $this->ancestors = array_reverse( $cat_ancestors );
329
list( $_, $top_cat ) = $this->ancestors;
330
331
return $top_cat;
336
/**
337
* If a category has children add the has_children class
338
*
339
+ * @param [] $classes
340
* @param \WP_Term $category
341
*
342
* @return array
384
$return = false;
385
if ( (int) $term->term_id === (int) $this->top_level_term->term_id || in_array( $term->term_id, $this->ancestors, false ) ) {
386
$children = get_term_children( $term->term_id, $this->get_taxonomy() );
387
+ if ( ! empty( $children ) ) {
388
$return = true;
389
}
390
}
views/category_list.php CHANGED
@@ -1,48 +1,49 @@
1
<?php
2
-
3
/**
4
* The Output of the Advanced Sidebar Categories Widget
5
*
6
- * @since 7.0.0
7
*
8
* To edit create a file named category_list.php and put in a folder in the your
9
* theme called 'advanced-sidebar-menu' copy the contents of the file into that file and edit at will
10
*
11
* @notice Do NOT edit this file in this location or it will break on update
12
*/
13
- $menu = Advanced_Sidebar_Menu_Menus_Category::get_current();
14
- $child_terms = $menu->get_child_terms();
15
- $content = '';
16
17
- //Display parent category
18
- if( $menu->include_parent() ){
19
$content .= '<ul class="parent-sidebar-menu">';
20
21
- $list_args = $menu->get_list_categories_args( 'parent' );
22
- $content .= $menu->openListItem( wp_list_categories( $list_args ) );
23
}
24
25
- if( !empty( $child_terms ) ){
26
$content .= '<ul class="child-sidebar-menu">';
27
28
- //Always display child categories
29
- if( $menu->display_all() ){
30
- $list_args = $menu->get_list_categories_args( 'display-all' );
31
- $content .= wp_list_categories( $list_args );
32
33
} else {
34
- foreach( $child_terms as $_term ){
35
- //Child terms
36
- if( $menu->is_first_level_term( $_term ) ){
37
- $list_args = $menu->get_list_categories_args( 'child', $_term );
38
- $content .= $menu->openListItem( wp_list_categories( $list_args ) );
39
-
40
- //Grandchild terms
41
- if( $menu->is_current_term_ancestor( $_term ) && $menu->has_children( $_term ) ){
42
$content .= '<ul class="grandchild-sidebar-menu children">';
43
44
- $list_args = $menu->get_list_categories_args( 'grandchild', $_term );
45
- $content .= wp_list_categories( $list_args );
46
47
$content .= '</ul>';
48
}
@@ -55,8 +56,8 @@ if( !empty( $child_terms ) ){
55
$content .= '</ul><!-- End .child-sidebar-menu -->';
56
}
57
58
- if( $menu->include_parent() ){
59
$content .= '</li></ul><!-- End .parent-sidebar-menu -->';
60
}
61
62
- return $content;
1
<?php
2
/**
3
* The Output of the Advanced Sidebar Categories Widget
4
*
5
+ * @since 7.4.7
6
+ * @package advanced-sidebar-menu
7
*
8
* To edit create a file named category_list.php and put in a folder in the your
9
* theme called 'advanced-sidebar-menu' copy the contents of the file into that file and edit at will
10
*
11
* @notice Do NOT edit this file in this location or it will break on update
12
*/
13
14
+ $current_menu = Advanced_Sidebar_Menu_Menus_Category::get_current();
15
+ $child_terms = $current_menu->get_child_terms();
16
+ $content = '';
17
+
18
+ // Display parent category.
19
+ if ( $current_menu->include_parent() ) {
20
$content .= '<ul class="parent-sidebar-menu">';
21
22
+ $list_args = $current_menu->get_list_categories_args( Advanced_Sidebar_Menu_Menus_Category::LEVEL_PARENT );
23
+ $content .= $current_menu->openListItem( wp_list_categories( $list_args ) );
24
}
25
26
+ if ( ! empty( $child_terms ) ) {
27
$content .= '<ul class="child-sidebar-menu">';
28
29
+ // Always display child categories.
30
+ if ( $current_menu->display_all() ) {
31
+ $list_args = $current_menu->get_list_categories_args( Advanced_Sidebar_Menu_Menus_Category::LEVEL_DISPLAY_ALL );
32
+ $content .= wp_list_categories( $list_args );
33
34
} else {
35
+ foreach ( $child_terms as $_term ) {
36
+ // Child terms.
37
+ if ( $current_menu->is_first_level_term( $_term ) ) {
38
+ $list_args = $current_menu->get_list_categories_args( Advanced_Sidebar_Menu_Menus_Category::LEVEL_CHILD, $_term );
39
+ $content .= $current_menu->openListItem( wp_list_categories( $list_args ) );
40
+
41
+ // Grandchild terms.
42
+ if ( $current_menu->is_current_term_ancestor( $_term ) && $current_menu->has_children( $_term ) ) {
43
$content .= '<ul class="grandchild-sidebar-menu children">';
44
45
+ $list_args = $current_menu->get_list_categories_args( Advanced_Sidebar_Menu_Menus_Category::LEVEL_GRANDCHILD, $_term );
46
+ $content .= wp_list_categories( $list_args );
47
48
$content .= '</ul>';
49
}
56
$content .= '</ul><!-- End .child-sidebar-menu -->';
57
}
58
59
+ if ( $current_menu->include_parent() ) {
60
$content .= '</li></ul><!-- End .parent-sidebar-menu -->';
61
}
62
63
+ return $content;
views/page_list.php CHANGED
@@ -2,9 +2,10 @@
2
/**
3
* The Output of the Advanced Sidebar Page Widget
4
*
5
- * @author Mat Lipe
6
*
7
- * @since 7.0.0
8
*
9
* @example to edit, create a file named page_list.php and
10
* put in a folder in the your theme called 'advanced-sidebar-menu.
@@ -12,38 +13,39 @@
12
*
13
* @notice Do not edit this file in its original location or it will break on upgrade
14
*/
15
- $menu = Advanced_Sidebar_Menu_Menus_Page::get_current();
16
- $list_pages = Advanced_Sidebar_Menu_List_Pages::factory( $menu );
17
- $child_pages = $list_pages->get_child_pages( $menu->get_top_parent_id(), true );
18
- $content = '';
19
-
20
- $menu->title();
21
-
22
- //Display parent page
23
- if( $menu->include_parent() ){
24
- $content .= '<ul class="parent-sidebar-menu" >';
25
- $list_args = $list_pages->get_args( 'parent' );
26
- $content .= wp_list_pages( $list_args );
27
}
28
29
- if( !empty( $child_pages ) ){
30
$content .= '<ul class="child-sidebar-menu">';
31
32
- //Always display child pages
33
- if( $menu->display_all() ){
34
- $list_args = $list_pages->get_args( 'display-all' );
35
- $content .= wp_list_pages( $list_args );
36
37
} else {
38
- //Child and grandchild pages
39
$content .= $list_pages->list_pages();
40
}
41
42
$content .= '</ul><!-- End .child-sidebar-menu -->';
43
44
}
45
- if( $menu->include_parent() ){
46
$content .= '</li></ul><!-- End .parent-sidebar-menu -->';
47
}
48
49
- return $content;
2
/**
3
* The Output of the Advanced Sidebar Page Widget
4
*
5
+ * @author Mat Lipe
6
*
7
+ * @since 7.4.7
8
+ * @package advanced-sidebar-menu
9
*
10
* @example to edit, create a file named page_list.php and
11
* put in a folder in the your theme called 'advanced-sidebar-menu.
13
*
14
* @notice Do not edit this file in its original location or it will break on upgrade
15
*/
16
+
17
+ $current_menu = Advanced_Sidebar_Menu_Menus_Page::get_current();
18
+ $list_pages = Advanced_Sidebar_Menu_List_Pages::factory( $current_menu );
19
+ $child_pages = $list_pages->get_child_pages( $current_menu->get_top_parent_id(), true );
20
+ $content = '';
21
+
22
+ $current_menu->title();
23
+
24
+ // Display parent page.
25
+ if ( $current_menu->include_parent() ) {
26
+ $content .= '<ul class="parent-sidebar-menu" >';
27
+ $list_args = $list_pages->get_args( Advanced_Sidebar_Menu_Menus_Page::LEVEL_PARENT );
28
+ $content .= wp_list_pages( $list_args );
29
}
30
31
+ if ( ! empty( $child_pages ) ) {
32
$content .= '<ul class="child-sidebar-menu">';
33
34
+ // Always display child pages.
35
+ if ( $current_menu->display_all() ) {
36
+ $list_args = $list_pages->get_args( Advanced_Sidebar_Menu_Menus_Page::LEVEL_DISPLAY_ALL );
37
+ $content .= wp_list_pages( $list_args );
38
39
} else {
40
+ // Child and grandchild pages.
41
$content .= $list_pages->list_pages();
42
}
43
44
$content .= '</ul><!-- End .child-sidebar-menu -->';
45
46
}
47
+ if ( $current_menu->include_parent() ) {
48
$content .= '</li></ul><!-- End .parent-sidebar-menu -->';
49
}
50
51
+ return $content;