Advanced Sidebar Menu - Version 8.8.2

Version Description

  • Fixed widget id generation with block based widgets.
  • Introduced advanced-sidebar-menu/core/include-template-parts-comments filter.
  • Organized the Menu_Abtract class constants.
  • Tested to WordPress Core 6.0.1.
Download this release

Release Info

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

Code changes from version 8.8.1 to 8.8.2

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: 8.8.1
8
  * Author URI: https://onpointplugins.com
9
  * Text Domain: advanced-sidebar-menu
10
  * Domain Path: /languages/
@@ -19,7 +19,7 @@ if ( defined( 'ADVANCED_SIDEBAR_BASIC_VERSION' ) ) {
19
  return;
20
  }
21
 
22
- define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '8.8.1' );
23
  define( 'ADVANCED_SIDEBAR_MENU_REQUIRED_PRO_VERSION', '8.7.0' );
24
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
25
  define( 'ADVANCED_SIDEBAR_MENU_URL', plugin_dir_url( __FILE__ ) );
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: 8.8.2
8
  * Author URI: https://onpointplugins.com
9
  * Text Domain: advanced-sidebar-menu
10
  * Domain Path: /languages/
19
  return;
20
  }
21
 
22
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '8.8.2' );
23
  define( 'ADVANCED_SIDEBAR_MENU_REQUIRED_PRO_VERSION', '8.7.0' );
24
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
25
  define( 'ADVANCED_SIDEBAR_MENU_URL', plugin_dir_url( __FILE__ ) );
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: menus, sidebar menu, hierarchy, category menu, pages menu, dynamic
6
  Requires at least: 5.4.0
7
  Tested up to: 6.0.1
8
  Requires PHP: 5.6.0
9
- Stable tag: 8.8.1
10
 
11
  == Description ==
12
 
6
  Requires at least: 5.4.0
7
  Tested up to: 6.0.1
8
  Requires PHP: 5.6.0
9
+ Stable tag: 8.8.2
10
 
11
  == Description ==
12
 
src/Core.php CHANGED
@@ -49,12 +49,15 @@ class Core {
49
  */
50
  public function get_template_part( $file_name ) {
51
  $file = locate_template( 'advanced-sidebar-menu/' . $file_name );
 
52
  if ( empty( $file ) ) {
53
- ?>
54
- <!-- advanced-sidebar-menu/core-template -->
55
- <?php
 
 
56
  $file = ADVANCED_SIDEBAR_DIR . 'views/' . $file_name;
57
- } else {
58
  ?>
59
  <!-- advanced-sidebar-menu/template-override -->
60
  <?php
49
  */
50
  public function get_template_part( $file_name ) {
51
  $file = locate_template( 'advanced-sidebar-menu/' . $file_name );
52
+ $comments = apply_filters( 'advanced-sidebar-menu/core/include-template-parts-comments', true, $file_name );
53
  if ( empty( $file ) ) {
54
+ if ( $comments ) {
55
+ ?>
56
+ <!-- advanced-sidebar-menu/core-template -->
57
+ <?php
58
+ }
59
  $file = ADVANCED_SIDEBAR_DIR . 'views/' . $file_name;
60
+ } elseif ( $comments ) {
61
  ?>
62
  <!-- advanced-sidebar-menu/template-override -->
63
  <?php
src/Menus/Menu_Abstract.php CHANGED
@@ -11,19 +11,22 @@ namespace Advanced_Sidebar_Menu\Menus;
11
  abstract class Menu_Abstract {
12
  const WIDGET = 'menu-abstract';
13
 
 
14
  const DISPLAY_ALL = 'display_all';
15
  const EXCLUDE = 'exclude';
16
  const INCLUDE_CHILDLESS_PARENT = 'include_childless_parent';
17
  const INCLUDE_PARENT = 'include_parent';
18
  const LEVELS = 'levels';
19
- const LEVEL_CHILD = 'child';
20
- const LEVEL_DISPLAY_ALL = 'display-all';
21
- const LEVEL_GRANDCHILD = 'grandchild';
22
- const LEVEL_PARENT = 'parent';
23
  const ORDER = 'order';
24
  const ORDER_BY = 'order_by';
25
  const TITLE = 'title';
26
 
 
 
 
 
 
 
27
  /**
28
  * Widget Args
29
  *
@@ -128,7 +131,8 @@ abstract class Menu_Abstract {
128
  protected function increment_widget_id() {
129
  // Block widgets loaded via the REST API don't have full widget args.
130
  if ( ! isset( $this->args['widget_id'] ) ) {
131
- $this->args['widget_id'] = wp_hash( microtime() );
 
132
  }
133
  if ( \in_array( $this->args['widget_id'], self::$unique_widget_ids, true ) ) {
134
  $suffix = 2;
11
  abstract class Menu_Abstract {
12
  const WIDGET = 'menu-abstract';
13
 
14
+ // Options shared between menus.
15
  const DISPLAY_ALL = 'display_all';
16
  const EXCLUDE = 'exclude';
17
  const INCLUDE_CHILDLESS_PARENT = 'include_childless_parent';
18
  const INCLUDE_PARENT = 'include_parent';
19
  const LEVELS = 'levels';
 
 
 
 
20
  const ORDER = 'order';
21
  const ORDER_BY = 'order_by';
22
  const TITLE = 'title';
23
 
24
+ // Possible level values.
25
+ const LEVEL_CHILD = 'child';
26
+ const LEVEL_DISPLAY_ALL = 'display-all';
27
+ const LEVEL_GRANDCHILD = 'grandchild';
28
+ const LEVEL_PARENT = 'parent';
29
+
30
  /**
31
  * Widget Args
32
  *
131
  protected function increment_widget_id() {
132
  // Block widgets loaded via the REST API don't have full widget args.
133
  if ( ! isset( $this->args['widget_id'] ) ) {
134
+ // Prefix any leading digits or hyphens with '_'.
135
+ $this->args['widget_id'] = \preg_replace( '/^([\d-])/', '_$1', wp_hash( microtime() ) );
136
  }
137
  if ( \in_array( $this->args['widget_id'], self::$unique_widget_ids, true ) ) {
138
  $suffix = 2;