Version Description
- Tested to 5.3.3.
- Change default "levels to display" to All.
- Fix notice level errors when retrieving current page.
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Advanced Sidebar Menu |
Version | 7.7.2 |
Comparing to | |
See all releases |
Code changes from version 7.7.1 to 7.7.2
- advanced-sidebar-menu.php +2 -2
- readme.txt +4 -3
- src/List_Pages.php +24 -8
- src/Menus/Abstract.php +0 -9
- src/Menus/Page.php +13 -9
advanced-sidebar-menu.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin URI: https://onpointplugins.com/advanced-sidebar-menu/
|
5 |
* Description: Creates dynamic menus based on parent/child relationship of your pages or categories.
|
6 |
* Author: OnPoint Plugins
|
7 |
-
* Version: 7.7.
|
8 |
* Author URI: https://onpointplugins.com
|
9 |
* Text Domain: advanced-sidebar-menu
|
10 |
*
|
@@ -17,7 +17,7 @@ if ( defined( 'ADVANCED_SIDEBAR_BASIC_VERSION' ) ) {
|
|
17 |
return;
|
18 |
}
|
19 |
|
20 |
-
define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.7.
|
21 |
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
|
22 |
define( 'ADVANCED_SIDEBAR_MENU_URL', plugin_dir_url( __FILE__ ) );
|
23 |
|
4 |
* Plugin URI: https://onpointplugins.com/advanced-sidebar-menu/
|
5 |
* Description: Creates dynamic menus based on parent/child relationship of your pages or categories.
|
6 |
* Author: OnPoint Plugins
|
7 |
+
* Version: 7.7.2
|
8 |
* Author URI: https://onpointplugins.com
|
9 |
* Text Domain: advanced-sidebar-menu
|
10 |
*
|
17 |
return;
|
18 |
}
|
19 |
|
20 |
+
define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.7.2' );
|
21 |
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
|
22 |
define( 'ADVANCED_SIDEBAR_MENU_URL', plugin_dir_url( __FILE__ ) );
|
23 |
|
readme.txt
CHANGED
@@ -4,9 +4,9 @@ Contributors: Mat Lipe, onpointplugins
|
|
4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40onpointplugins%2ecom&lc=US&item_name=Advanced%20Sidebar%20Menu&no_note=0¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
|
5 |
Tags: menus, sidebar menu, hierarchy, category menu, pages menu
|
6 |
Requires at least: 4.8.0
|
7 |
-
Tested up to: 5.
|
8 |
Requires PHP: 5.6.0
|
9 |
-
Stable tag: 7.7.
|
10 |
|
11 |
== Description ==
|
12 |
|
@@ -155,9 +155,10 @@ Yes. Based on whatever page, post, or category you are on, the menu will change
|
|
155 |
|
156 |
|
157 |
== Changelog ==
|
158 |
-
= 7.7.
|
159 |
* Tested to 5.3.3.
|
160 |
* Change default "levels to display" to All.
|
|
|
161 |
|
162 |
= 7.7.0 =
|
163 |
* Enable accordion previews when editing via Beaver Builder.
|
4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40onpointplugins%2ecom&lc=US&item_name=Advanced%20Sidebar%20Menu&no_note=0¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
|
5 |
Tags: menus, sidebar menu, hierarchy, category menu, pages menu
|
6 |
Requires at least: 4.8.0
|
7 |
+
Tested up to: 5.4.0
|
8 |
Requires PHP: 5.6.0
|
9 |
+
Stable tag: 7.7.2
|
10 |
|
11 |
== Description ==
|
12 |
|
155 |
|
156 |
|
157 |
== Changelog ==
|
158 |
+
= 7.7.2 =
|
159 |
* Tested to 5.3.3.
|
160 |
* Change default "levels to display" to All.
|
161 |
+
* Fix notice level errors when retrieving current page.
|
162 |
|
163 |
= 7.7.0 =
|
164 |
* Enable accordion previews when editing via Beaver Builder.
|
src/List_Pages.php
CHANGED
@@ -29,7 +29,7 @@ class Advanced_Sidebar_Menu_List_Pages {
|
|
29 |
/**
|
30 |
* Used when walking the list
|
31 |
*
|
32 |
-
* @var WP_Post
|
33 |
*/
|
34 |
protected $current_page;
|
35 |
|
@@ -121,9 +121,9 @@ class Advanced_Sidebar_Menu_List_Pages {
|
|
121 |
// page posts are handled by wp core. This is for custom post types.
|
122 |
if ( 'page' !== $post->post_type ) {
|
123 |
$ancestors = get_post_ancestors( $post );
|
124 |
-
if ( ! empty( $ancestors ) && in_array( $this->
|
125 |
$classes[] = 'current_page_ancestor';
|
126 |
-
} elseif ( $this->
|
127 |
$classes[] = 'current_page_parent';
|
128 |
}
|
129 |
}
|
@@ -218,15 +218,30 @@ class Advanced_Sidebar_Menu_List_Pages {
|
|
218 |
}
|
219 |
|
220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
/**
|
222 |
* List the pages very similar to wp_list_pages.
|
223 |
*
|
224 |
* @return string
|
225 |
*/
|
226 |
public function list_pages() {
|
|
|
227 |
$pages = $this->get_child_pages( $this->top_parent_id, true );
|
228 |
foreach ( $pages as $page ) {
|
229 |
-
$this->output .= walk_page_tree( array( $page ), 1, $this->
|
230 |
$this->output .= $this->list_grandchild_pages( $page->ID, 0 );
|
231 |
$this->output .= '</li>' . "\n";
|
232 |
}
|
@@ -266,7 +281,7 @@ class Advanced_Sidebar_Menu_List_Pages {
|
|
266 |
|
267 |
$inside = '';
|
268 |
foreach ( $pages as $page ) {
|
269 |
-
$inside .= walk_page_tree(
|
270 |
$inside .= $this->list_grandchild_pages( $page->ID, $level + 1 );
|
271 |
$inside .= "</li>\n";
|
272 |
}
|
@@ -326,8 +341,9 @@ class Advanced_Sidebar_Menu_List_Pages {
|
|
326 |
*/
|
327 |
public function is_current_page_ancestor( $page_id ) {
|
328 |
$return = false;
|
329 |
-
|
330 |
-
|
|
|
331 |
$return = true;
|
332 |
} elseif ( $this->current_page->post_parent === (int) $page_id ) {
|
333 |
$return = true;
|
@@ -339,7 +355,7 @@ class Advanced_Sidebar_Menu_List_Pages {
|
|
339 |
}
|
340 |
}
|
341 |
|
342 |
-
return apply_filters( 'advanced_sidebar_menu_page_ancestor', $return, $
|
343 |
}
|
344 |
|
345 |
|
29 |
/**
|
30 |
* Used when walking the list
|
31 |
*
|
32 |
+
* @var null|\WP_Post
|
33 |
*/
|
34 |
protected $current_page;
|
35 |
|
121 |
// page posts are handled by wp core. This is for custom post types.
|
122 |
if ( 'page' !== $post->post_type ) {
|
123 |
$ancestors = get_post_ancestors( $post );
|
124 |
+
if ( ! empty( $ancestors ) && in_array( $this->get_current_page_id(), $ancestors, false ) ) { //phpcs:ignore
|
125 |
$classes[] = 'current_page_ancestor';
|
126 |
+
} elseif ( $this->get_current_page_id() === $post->post_parent ) {
|
127 |
$classes[] = 'current_page_parent';
|
128 |
}
|
129 |
}
|
218 |
}
|
219 |
|
220 |
|
221 |
+
/**
|
222 |
+
* Return the ID of the current page or 0 if not on a page.
|
223 |
+
* Helper method to prevent a bunch of conditionals throughout.
|
224 |
+
*
|
225 |
+
* @since 7.7.2
|
226 |
+
*/
|
227 |
+
public function get_current_page_id() {
|
228 |
+
if ( null !== $this->current_page ) {
|
229 |
+
return $this->current_page->ID;
|
230 |
+
}
|
231 |
+
return 0;
|
232 |
+
}
|
233 |
+
|
234 |
+
|
235 |
/**
|
236 |
* List the pages very similar to wp_list_pages.
|
237 |
*
|
238 |
* @return string
|
239 |
*/
|
240 |
public function list_pages() {
|
241 |
+
|
242 |
$pages = $this->get_child_pages( $this->top_parent_id, true );
|
243 |
foreach ( $pages as $page ) {
|
244 |
+
$this->output .= walk_page_tree( array( $page ), 1, $this->get_current_page_id(), $this->args );
|
245 |
$this->output .= $this->list_grandchild_pages( $page->ID, 0 );
|
246 |
$this->output .= '</li>' . "\n";
|
247 |
}
|
281 |
|
282 |
$inside = '';
|
283 |
foreach ( $pages as $page ) {
|
284 |
+
$inside .= walk_page_tree( [ $page ], 1, $this->get_current_page_id(), $this->args );
|
285 |
$inside .= $this->list_grandchild_pages( $page->ID, $level + 1 );
|
286 |
$inside .= "</li>\n";
|
287 |
}
|
341 |
*/
|
342 |
public function is_current_page_ancestor( $page_id ) {
|
343 |
$return = false;
|
344 |
+
$current_page_id = $this->get_current_page_id();
|
345 |
+
if ( ! empty( $current_page_id ) ) {
|
346 |
+
if ( (int) $page_id === $current_page_id ) {
|
347 |
$return = true;
|
348 |
} elseif ( $this->current_page->post_parent === (int) $page_id ) {
|
349 |
$return = true;
|
355 |
}
|
356 |
}
|
357 |
|
358 |
+
return apply_filters( 'advanced_sidebar_menu_page_ancestor', $return, $current_page_id, $this );
|
359 |
}
|
360 |
|
361 |
|
src/Menus/Abstract.php
CHANGED
@@ -51,15 +51,6 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
|
|
51 |
*/
|
52 |
public $order_by;
|
53 |
|
54 |
-
/**
|
55 |
-
* Top post_id or term_id
|
56 |
-
*
|
57 |
-
* @deprecated 7.0.0
|
58 |
-
*
|
59 |
-
* @var int
|
60 |
-
*/
|
61 |
-
public $top_id;
|
62 |
-
|
63 |
/**
|
64 |
* Track the ids which have been used in case of
|
65 |
* plugins like Elementor that we need to manually increment.
|
51 |
*/
|
52 |
public $order_by;
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
/**
|
55 |
* Track the ids which have been used in case of
|
56 |
* plugins like Elementor that we need to manually increment.
|
src/Menus/Page.php
CHANGED
@@ -21,9 +21,8 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
|
|
21 |
public $post_type = 'page';
|
22 |
|
23 |
/**
|
24 |
-
* post
|
25 |
*
|
26 |
-
* @var
|
27 |
*/
|
28 |
protected $post;
|
29 |
|
@@ -39,7 +38,7 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
|
|
39 |
* Gets the current queried post unless it
|
40 |
* has been set explicitly.
|
41 |
*
|
42 |
-
* @return
|
43 |
*/
|
44 |
public function get_current_post() {
|
45 |
if ( null === $this->post ) {
|
@@ -62,19 +61,24 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
|
|
62 |
}
|
63 |
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
public function get_top_parent_id() {
|
|
|
66 |
$ancestors = get_post_ancestors( $this->get_current_post() );
|
67 |
if ( ! empty( $ancestors ) ) {
|
68 |
$top_id = end( $ancestors );
|
69 |
-
}
|
70 |
$top_id = $this->get_current_post()->ID;
|
71 |
}
|
72 |
|
73 |
-
|
74 |
-
$this->top_id = apply_filters( 'advanced_sidebar_menu_top_parent', $top_id, $this->args, $this->instance, $this );
|
75 |
-
|
76 |
-
return $this->top_id;
|
77 |
-
|
78 |
}
|
79 |
|
80 |
|
21 |
public $post_type = 'page';
|
22 |
|
23 |
/**
|
|
|
24 |
*
|
25 |
+
* @var null|\WP_Post
|
26 |
*/
|
27 |
protected $post;
|
28 |
|
38 |
* Gets the current queried post unless it
|
39 |
* has been set explicitly.
|
40 |
*
|
41 |
+
* @return null|\WP_Post
|
42 |
*/
|
43 |
public function get_current_post() {
|
44 |
if ( null === $this->post ) {
|
61 |
}
|
62 |
|
63 |
|
64 |
+
/**
|
65 |
+
* Get the id of page which is the top level parent of
|
66 |
+
* the page we are currently on.
|
67 |
+
*
|
68 |
+
* Returns -1 if we don't have one.
|
69 |
+
*
|
70 |
+
* @return int
|
71 |
+
*/
|
72 |
public function get_top_parent_id() {
|
73 |
+
$top_id = - 1;
|
74 |
$ancestors = get_post_ancestors( $this->get_current_post() );
|
75 |
if ( ! empty( $ancestors ) ) {
|
76 |
$top_id = end( $ancestors );
|
77 |
+
} elseif ( null !== $this->get_current_post() ) {
|
78 |
$top_id = $this->get_current_post()->ID;
|
79 |
}
|
80 |
|
81 |
+
return apply_filters( 'advanced_sidebar_menu_top_parent', $top_id, $this->args, $this->instance, $this );
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
|
84 |
|