Advanced Sidebar Menu - Version 7.3.0

Version Description

  • Greatly improve category widget performance
Download this release

Release Info

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

Code changes from version 7.2.5 to 7.3.0

Files changed (3) hide show
  1. advanced-sidebar-menu.php +4 -4
  2. readme.txt +16 -14
  3. src/Menus/Category.php +9 -64
advanced-sidebar-menu.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Advanced Sidebar Menu
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.2.5
8
Author URI: https://matlipe.com
9
Text Domain: advanced-sidebar-menu
10
*/
@@ -14,7 +14,7 @@ if ( defined( 'ADVANCED_SIDEBAR_BASIC_VERSION' ) ) {
14
return;
15
}
16
17
- define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.2.5' );
18
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
19
20
if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
@@ -124,7 +124,7 @@ function advanced_sidebar_menu_upgrade_notice( array $instance, WP_Widget $widge
124
<li><?php esc_html_e( 'Ability to exclude a page from all menus using a simple checkbox.', 'advanced-sidebar-menu' ); ?></li>
125
<li><?php esc_html_e( 'Number of levels of pages to show when always displayed child pages is not checked.', 'advanced-sidebar-menu' ); ?></li>
126
<li><?php esc_html_e( 'Ability to select and display custom post types.', 'advanced-sidebar-menu' ); ?></li>
127
- <li><?php esc_html_e( 'Option to display the current page’s parents and grandparents only, as well as siblings options.', 'advanced-sidebar-menu' ); ?></li>
128
<?php
129
//category widget options
130
} else {
@@ -135,7 +135,7 @@ function advanced_sidebar_menu_upgrade_notice( array $instance, WP_Widget $widge
135
<?php
136
}
137
?>
138
- <li><?php esc_html_e( 'Ability to display the widgets everywhere the sidebar display.', 'advanced-sidebar-menu' ); ?>
139
<strong> NEW</strong></li>
140
<li><?php esc_html_e( 'Support for custom navigation menus from Appearance -> Menus.', 'advanced-sidebar-menu' ); ?><strong> NEW</strong></li>
141
</ol>
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.3.0
8
Author URI: https://matlipe.com
9
Text Domain: advanced-sidebar-menu
10
*/
14
return;
15
}
16
17
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.3.0' );
18
define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
19
20
if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
124
<li><?php esc_html_e( 'Ability to exclude a page from all menus using a simple checkbox.', 'advanced-sidebar-menu' ); ?></li>
125
<li><?php esc_html_e( 'Number of levels of pages to show when always displayed child pages is not checked.', 'advanced-sidebar-menu' ); ?></li>
126
<li><?php esc_html_e( 'Ability to select and display custom post types.', 'advanced-sidebar-menu' ); ?></li>
127
+ <li><?php esc_html_e( 'Option to display the current page’s parents, grandparents, and children only, as well as siblings options.', 'advanced-sidebar-menu' ); ?></li>
128
<?php
129
//category widget options
130
} else {
135
<?php
136
}
137
?>
138
+ <li><?php esc_html_e( 'Ability to display the widgets everywhere the sidebar displays.', 'advanced-sidebar-menu' ); ?>
139
<strong> NEW</strong></li>
140
<li><?php esc_html_e( 'Support for custom navigation menus from Appearance -> Menus.', 'advanced-sidebar-menu' ); ?><strong> NEW</strong></li>
141
</ol>
readme.txt CHANGED
@@ -4,9 +4,9 @@ Contributors: Mat Lipe
4
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40matlipe%2ecom&lc=US&item_name=Advanced%20Sidebar%20Menu&no_note=0&currency_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.6.0
7
- Tested up to: 4.9.6
8
Requires PHP: 5.2.4
9
- Stable tag: 7.2.5
10
11
== Description ==
12
@@ -53,8 +53,7 @@ Keeps the menu clean and usable. Only related items display so you don't have to
53
<h4>Pro Features</h4>
54
* Priority support.
55
* Ability to customize each page's link text.
56
- * Number of levels of pages to show when always displayed child pages is not checked.
57
- * Click and drag styling for both the page and category widgets.
58
* Styling options for links including color, background color, size, and font weight.
59
* Styling options for different levels of links.
60
* Styling options for the current page or category.
@@ -62,23 +61,23 @@ Keeps the menu clean and usable. Only related items display so you don't have to
62
* Block styling options including borders and border colors.
63
* Bullet style selection from 7 styles or select none to have no bullets.
64
* Accordion menu support for pages, categories, and navigation menus.
65
- * Accordion icon selection from 4 styles of icons.
66
- * Accordion icon color selection.
67
* Accordion option to keep all sections closed until clicked.
68
* Accordion option to include highest level parent in accordion.
69
* Ability to exclude a page from all menus using a simple checkbox.
70
* Link ordering for the category widget.
71
* Ability to select and display custom post types.
72
* Ability to select and display custom taxonomies.
73
- * Option to display the current page's parents and grandparents only.
74
- * Option to display child page siblings when on a child page.
75
- * Option to display child page siblings when on a child page with no grandchild pages.
76
- * Ability to display the widgets everywhere the sidebar display.
77
* Ability to select the parent page/category when using the display widget everywhere option. **NEW**
78
- * Ability to display assigned posts under categories. **NEW**
79
- * Ability to display assigned custom post types under categories. **NEW**
80
- * Ability to limit the number of posts to display under categories or custom post types. **NEW**
81
- * Support for custom navigation menus from Appearance -> Menus **NEW**
82
* Access to members only support area.
83
84
<h4>Currently ships with the following languages</h4>
@@ -150,6 +149,9 @@ Yes. Based on whatever page, post, or category you are on, the menu will change
150
151
152
== Changelog ==
153
= 7.2.0 =
154
* New improved widget structure
155
4
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40matlipe%2ecom&lc=US&item_name=Advanced%20Sidebar%20Menu&no_note=0&currency_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.6.0
7
+ Tested up to: 4.9.7
8
Requires PHP: 5.2.4
9
+ Stable tag: 7.3.0
10
11
== Description ==
12
53
<h4>Pro Features</h4>
54
* Priority support.
55
* Ability to customize each page's link text.
56
+ * Click and drag styling for page, category, and navigation menu widgets.
57
* Styling options for links including color, background color, size, and font weight.
58
* Styling options for different levels of links.
59
* Styling options for the current page or category.
61
* Block styling options including borders and border colors.
62
* Bullet style selection from 7 styles or select none to have no bullets.
63
* Accordion menu support for pages, categories, and navigation menus.
64
+ * Accordion icon style and color selection.
65
* Accordion option to keep all sections closed until clicked.
66
* Accordion option to include highest level parent in accordion.
67
* Ability to exclude a page from all menus using a simple checkbox.
68
* Link ordering for the category widget.
69
+ * Number of levels of pages to show when always displayed child pages is not checked.
70
* Ability to select and display custom post types.
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
83
<h4>Currently ships with the following languages</h4>
149
150
151
== Changelog ==
152
+ = 7.3.0 =
153
+ * Greatly improve category widget performance
154
+
155
= 7.2.0 =
156
* New improved widget structure
157
src/Menus/Category.php CHANGED
@@ -21,14 +21,6 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
21
*/
22
public $ancestors = array();
23
24
- /**
25
- * taxonomy
26
- *
27
- * @deprecated 7.0.0
28
- *
29
- * @var string
30
- */
31
- public $taxonomy = 'category';
32
33
/**
34
* top_level_term
@@ -58,7 +50,6 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
58
* @return void
59
*/
60
public function set_current_top_level_term( WP_Term $term ) {
61
- $this->top_id = $term->term_id;
62
$this->top_level_term = $term;
63
}
64
@@ -205,9 +196,7 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
205
206
207
public function get_taxonomy() {
208
- $this->taxonomy = apply_filters( 'advanced_sidebar_menu_taxonomy', 'category', $this->args, $this->instance, $this );
209
-
210
- return $this->taxonomy;
211
}
212
213
@@ -221,16 +210,12 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
221
222
223
public function get_order_by() {
224
- $this->order_by = apply_filters( 'advanced_sidebar_menu_category_orderby', 'name', $this->args, $this->instance, $this );
225
-
226
- return $this->order_by;
227
}
228
229
230
public function get_order() {
231
- $this->order = apply_filters( 'advanced_sidebar_menu_category_order', 'ASC', $this->args, $this->instance, $this );
232
-
233
- return $this->order;
234
}
235
236
@@ -240,10 +225,6 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
240
if ( $this->checked( self::DISPLAY_ON_SINGLE ) ) {
241
$display = true;
242
}
243
- if ( has_filter( 'advanced_sidebar_menu_proper_single' ) ) {
244
- _deprecated_hook( 'advanced_sidebar_menu_proper_single', '7.0.0', 'advanced-sidebar-menu/menus/category/is-displayed' );
245
- $display = ! apply_filters( 'advanced_sidebar_menu_proper_single', ! $display, $this->args, $this->instance, $this );
246
- }
247
} elseif ( $this->is_tax() ) {
248
$display = true;
249
}
@@ -363,12 +344,7 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
363
* @return array
364
*/
365
public function add_has_children_category_class( $classes, $category ) {
366
- $children = get_terms( $category->taxonomy, array(
367
- 'parent' => $category->term_id,
368
- 'hide_empty' => false,
369
- 'number' => 1,
370
- ) );
371
- if ( ! empty( $children ) ) {
372
$classes[] = 'has_children';
373
}
374
@@ -409,20 +385,12 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
409
public function is_current_term_ancestor( WP_Term $term ) {
410
$return = false;
411
if ( (int) $term->term_id === (int) $this->top_level_term->term_id || in_array( $term->term_id, $this->ancestors, false ) ) {
412
- $all_children = get_terms( $this->get_taxonomy(), array(
413
- 'child_of' => $term->term_id,
414
- 'fields' => 'ids',
415
- ) );
416
- if ( ! empty( $all_children ) ) {
417
$return = true;
418
}
419
}
420
421
- if ( has_filter( 'advanced_sidebar_menu_second_level_category' ) ) {
422
- _deprecated_hook( 'advanced_sidebar_menu_second_level_category', '7.0.0', 'advanced-sidebar-menu/menus/category/is-current-term-ancestor' );
423
- $return = apply_filters( 'advanced_sidebar_menu_second_level_category', $return, $term, $this );
424
- }
425
-
426
return apply_filters( 'advanced-sidebar-menu/menus/category/is-current-term-ancestor', $return, $term, $this );
427
428
}
@@ -461,14 +429,12 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
461
462
foreach ( $this->get_top_level_terms() as $_cat ) {
463
$this->set_current_top_level_term( $_cat );
464
- //@deprecated 7.0.0 variable name
465
- $all_categories = $this->get_child_terms();
466
- if ( ! $this->is_term_displayed( $all_categories ) ) {
467
continue;
468
}
469
470
if ( ! $menu_open || ( 'widget' === $this->instance[ self::EACH_CATEGORY_DISPLAY ] ) ) {
471
- //Start the menu
472
echo $this->args['before_widget'];
473
474
do_action( 'advanced-sidebar-menu/menus/category/render', $this );
@@ -501,32 +467,11 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
501
echo $this->args['after_widget'];
502
}
503
504
- }
505
506
-
507
- /**
508
- * @deprecated
509
- *
510
- */
511
- public function first_level_category( WP_Term $term ) {
512
- _deprecated_function( 'Advanced_Sidebar_Menu_Menus_Category::first_level_category', '7.0.0', 'Advanced_Sidebar_Menu_Menus_Category::is_first_level_term' );
513
-
514
- return $this->is_first_level_term( $term );
515
}
516
517
518
- /**
519
- * @deprecated
520
- */
521
- public function second_level_cat( WP_Term $term ) {
522
- _deprecated_function( 'Advanced_Sidebar_Menu_Menus_Category::second_level_cat', '7.0.0', 'Advanced_Sidebar_Menu_Menus_Category::is_current_term_ancestor' );
523
-
524
- $return = ( $this->is_current_term_ancestor( $term ) && $this->has_children( $term ) );
525
-
526
- return apply_filters( 'advanced_sidebar_menu_second_level_category', $return, $term, $this );
527
-
528
- }
529
-
530
/******************** static ****************************/
531
532
/**
21
*/
22
public $ancestors = array();
23
24
25
/**
26
* top_level_term
50
* @return void
51
*/
52
public function set_current_top_level_term( WP_Term $term ) {
53
$this->top_level_term = $term;
54
}
55
196
197
198
public function get_taxonomy() {
199
+ return apply_filters( 'advanced_sidebar_menu_taxonomy', 'category', $this->args, $this->instance, $this );
200
}
201
202
210
211
212
public function get_order_by() {
213
+ return apply_filters( 'advanced_sidebar_menu_category_orderby', 'name', $this->args, $this->instance, $this );
214
}
215
216
217
public function get_order() {
218
+ return apply_filters( 'advanced_sidebar_menu_category_order', 'ASC', $this->args, $this->instance, $this );
219
}
220
221
225
if ( $this->checked( self::DISPLAY_ON_SINGLE ) ) {
226
$display = true;
227
}
228
} elseif ( $this->is_tax() ) {
229
$display = true;
230
}
344
* @return array
345
*/
346
public function add_has_children_category_class( $classes, $category ) {
347
+ if ( $this->has_children( $category ) ) {
348
$classes[] = 'has_children';
349
}
350
385
public function is_current_term_ancestor( WP_Term $term ) {
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
}
393
394
return apply_filters( 'advanced-sidebar-menu/menus/category/is-current-term-ancestor', $return, $term, $this );
395
396
}
429
430
foreach ( $this->get_top_level_terms() as $_cat ) {
431
$this->set_current_top_level_term( $_cat );
432
+ if ( ! $this->is_term_displayed( $this->get_child_terms() ) ) {
433
continue;
434
}
435
436
if ( ! $menu_open || ( 'widget' === $this->instance[ self::EACH_CATEGORY_DISPLAY ] ) ) {
437
+ //phpcs:disable
438
echo $this->args['before_widget'];
439
440
do_action( 'advanced-sidebar-menu/menus/category/render', $this );
467
echo $this->args['after_widget'];
468
}
469
470
+ //phpcs:enable
471
472
}
473
474
475
/******************** static ****************************/
476
477
/**