Advanced Sidebar Menu - Version 7.6.0

Version Description

  • Elementor support for multiple widgets of the same type on the same page.
  • Automatically increment widget ids under any cases where they would duplicate.
  • Bump required WordPress Core version to 4.8.0.
Download this release

Release Info

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

Code changes from version 7.5.5 to 7.6.0

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.5.5
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.5.4' );
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.6.0
8
  * Author URI: https://matlipe.com
9
  * Text Domain: advanced-sidebar-menu
10
  *
15
  return;
16
  }
17
 
18
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.6.0' );
19
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
20
 
21
  if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
readme.txt CHANGED
@@ -3,10 +3,10 @@
3
  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.7.0
7
- Tested up to: 5.2.1
8
  Requires PHP: 5.4.4
9
- Stable tag: 7.5.5
10
 
11
  == Description ==
12
 
@@ -150,6 +150,11 @@ Yes. Based on whatever page, post, or category you are on, the menu will change
150
 
151
 
152
  == Changelog ==
 
 
 
 
 
153
  = 7.5.0 =
154
  * Convert "Always display child pages" to use our List_Pages structure and support all widget options.
155
  * Bump required PHP version to 5.4.4.
3
  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.8.0
7
+ Tested up to: 5.2.2
8
  Requires PHP: 5.4.4
9
+ Stable tag: 7.6.0
10
 
11
  == Description ==
12
 
150
 
151
 
152
  == Changelog ==
153
+ = 7.6.0 =
154
+ * Elementor support for multiple widgets of the same type on the same page.
155
+ * Automatically increment widget ids under any cases where they would duplicate.
156
+ * Bump required WordPress Core version to 4.8.0.
157
+
158
  = 7.5.0 =
159
  * Convert "Always display child pages" to use our List_Pages structure and support all widget options.
160
  * Bump required PHP version to 5.4.4.
src/Menus/Abstract.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  /**
4
  * Advanced_Sidebar_Menu_Menus_Abstract
5
  *
@@ -67,10 +69,23 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
67
  */
68
  public $top_id;
69
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  public function __construct( array $widget_instance, array $widget_args ) {
72
  $this->instance = apply_filters( 'advanced-sidebar-menu/menus/widget-instance', $widget_instance, $widget_args, $this );
73
  $this->args = $widget_args;
 
 
74
  }
75
 
76
 
@@ -92,6 +107,37 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
92
  abstract public function get_levels_to_display();
93
 
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  /**
96
  * Return the type of widget we are working with
97
  * Used for comparisons like so
1
  <?php
2
 
3
+ use Prophecy\Argument\Token\StringContainsToken;
4
+
5
  /**
6
  * Advanced_Sidebar_Menu_Menus_Abstract
7
  *
69
  */
70
  public $top_id;
71
 
72
+ /**
73
+ * Track the ids which have been used in case of
74
+ * plugins like Elementor that we need to manually increment.
75
+ *
76
+ * @since 7.6.0
77
+ * @ticket #4775
78
+ *
79
+ * @var string[]
80
+ */
81
+ protected static $unique_widget_ids = array();
82
+
83
 
84
  public function __construct( array $widget_instance, array $widget_args ) {
85
  $this->instance = apply_filters( 'advanced-sidebar-menu/menus/widget-instance', $widget_instance, $widget_args, $this );
86
  $this->args = $widget_args;
87
+
88
+ $this->increment_widget_id();
89
  }
90
 
91
 
107
  abstract public function get_levels_to_display();
108
 
109
 
110
+ /**
111
+ * Increment the widget id until it is unique to all widgets being displayed
112
+ * in the current context.
113
+ *
114
+ * Required because plugins like Elementor will reuse the same generic id for
115
+ * widgets within page content and we need a unique id to properly target with
116
+ * styles, accordions, etc.
117
+ *
118
+ * @since 7.6.0
119
+ * @ticket #4775
120
+ *
121
+ * @return void
122
+ */
123
+ protected function increment_widget_id() {
124
+ if ( ! isset( $this->args['widget_id'] ) ) {
125
+ return;
126
+ }
127
+ if ( in_array( $this->args['widget_id'], self::$unique_widget_ids, true ) ) {
128
+ $suffix = 2;
129
+ do {
130
+ $alt_widget_id = $this->args['widget_id'] . "-$suffix";
131
+ $suffix ++;
132
+ } while ( in_array( $alt_widget_id, self::$unique_widget_ids, true ) );
133
+ $this->args['widget_id'] = $alt_widget_id;
134
+ self::$unique_widget_ids[] = $alt_widget_id;
135
+ } else {
136
+ self::$unique_widget_ids[] = $this->args['widget_id'];
137
+ }
138
+ }
139
+
140
+
141
  /**
142
  * Return the type of widget we are working with
143
  * Used for comparisons like so