Advanced Sidebar Menu - Version 7.2.1

Version Description

Update to fix misc bugs and support PRO version 3.2.0

Download this release

Release Info

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

Code changes from version 7.2.0 to 7.2.1

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.0
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.0' );
18
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
19
 
20
  if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
@@ -87,7 +87,8 @@ function advanced_sidebar_menu_script() {
87
  }
88
 
89
 
90
- add_action( 'advanced_sidebar_menu_after_widget_form', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
 
91
  /**
92
  * @todo translate these features
93
  *
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.1
8
  Author URI: https://matlipe.com
9
  Text Domain: advanced-sidebar-menu
10
  */
14
  return;
15
  }
16
 
17
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.2.1' );
18
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
19
 
20
  if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
87
  }
88
 
89
 
90
+ add_action( 'advanced-sidebar-menu/widget/category/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
91
+ add_action( 'advanced-sidebar-menu/widget/page/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
92
  /**
93
  * @todo translate these features
94
  *
readme.txt CHANGED
@@ -6,7 +6,7 @@ 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.0
10
 
11
  == Description ==
12
 
@@ -34,6 +34,7 @@ Keeps the menu clean and usable. Only related items display so you don't have to
34
  * Display highest level parent page
35
  * Display menu when there is only the parent page
36
  * Order pages by (date, title, page order)
 
37
  * Exclude pages
38
  * Always display child Pages
39
  * Number of levels of child pages to display when always display child pages is checked
@@ -42,6 +43,7 @@ Keeps the menu clean and usable. Only related items display so you don't have to
42
  * Add a title to the widget
43
  * Display highest level parent category
44
  * Display menu when there is only the parent category
 
45
  * Display categories on single posts
46
  * Display each single post's category in a new widget or in same list
47
  * Exclude categories
@@ -145,7 +147,7 @@ Yes. Based on whatever page, post, or category you are on, the menu will change
145
 
146
 
147
  == Changelog ==
148
- = 7.2.0
149
  * New improved widget structure
150
 
151
  = 7.1.0 =
@@ -218,6 +220,9 @@ Yes. Based on whatever page, post, or category you are on, the menu will change
218
 
219
 
220
  == Upgrade Notice ==
 
 
 
221
  = 7.1.2 =
222
  Update to support PRO version 3.1.0
223
 
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.1
10
 
11
  == Description ==
12
 
34
  * Display highest level parent page
35
  * Display menu when there is only the parent page
36
  * Order pages by (date, title, page order)
37
+ * Use built in styling (very plain styling, for more advanced styling <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Go Pro!</a>)
38
  * Exclude pages
39
  * Always display child Pages
40
  * Number of levels of child pages to display when always display child pages is checked
43
  * Add a title to the widget
44
  * Display highest level parent category
45
  * Display menu when there is only the parent category
46
+ * Use built in styling (very plain styling, for more advanced styling <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Go Pro!</a>)
47
  * Display categories on single posts
48
  * Display each single post's category in a new widget or in same list
49
  * Exclude categories
147
 
148
 
149
  == Changelog ==
150
+ = 7.2.0 =
151
  * New improved widget structure
152
 
153
  = 7.1.0 =
220
 
221
 
222
  == Upgrade Notice ==
223
+ = 7.2.1 =
224
+ Update to fix misc bugs and support PRO version 3.2.0
225
+
226
  = 7.1.2 =
227
  Update to support PRO version 3.1.0
228
 
resources/css/advanced-sidebar-menu.css CHANGED
@@ -14,6 +14,11 @@
14
  background: #f1f1f1;
15
  }
16
 
 
 
 
 
 
17
  @media all and ( max-width: 620px ) {
18
  .advanced-sidebar-menu-column {
19
  width: 100%;
14
  background: #f1f1f1;
15
  }
16
 
17
+ .advanced-sidebar-menu-full-width {
18
+ width: 98%;
19
+ clear: both;
20
+ }
21
+
22
  @media all and ( max-width: 620px ) {
23
  .advanced-sidebar-menu-column {
24
  width: 100%;
src/Core.php CHANGED
@@ -21,6 +21,21 @@ class Advanced_Sidebar_Menu_Core {
21
  }
22
 
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  /**
25
  * Retrieve a template file from either the theme's 'advanced-sidebar-menu' directory
26
  * or this plugins views folder if one does not exist
@@ -42,16 +57,6 @@ class Advanced_Sidebar_Menu_Core {
42
  return $file;
43
  }
44
 
45
-
46
- /**
47
- * @deprecated
48
- */
49
- public function include_plugin_styles() {
50
- _deprecated_function( 'Advanced_Sidebar_Menu_Core', '7.2.0' );
51
- }
52
-
53
-
54
-
55
  //********** SINGLETON FUNCTIONS **********/
56
 
57
 
21
  }
22
 
23
 
24
+ /**
25
+ * The plugin styles are universal
26
+ * This ensures that we only include them once on a single request
27
+ *
28
+ * @return void
29
+ */
30
+ public function include_plugin_styles() {
31
+ ?>
32
+ <style>
33
+ <?php include_once $this->get_template_part( 'sidebar-menu.css' ); ?>
34
+ </style>
35
+ <?php
36
+ }
37
+
38
+
39
  /**
40
  * Retrieve a template file from either the theme's 'advanced-sidebar-menu' directory
41
  * or this plugins views folder if one does not exist
57
  return $file;
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
60
  //********** SINGLETON FUNCTIONS **********/
61
 
62
 
src/List_Pages.php CHANGED
@@ -171,8 +171,9 @@ class Advanced_Sidebar_Menu_List_Pages {
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
  break;
177
  }
178
 
@@ -215,7 +216,7 @@ class Advanced_Sidebar_Menu_List_Pages {
215
  'exclude' => '',
216
  'echo' => 0,
217
  'order' => 'ASC',
218
- 'orderby' => 'menu_order, post_title',
219
  'walker' => new Advanced_Sidebar_Menu_Page_Walker(),
220
  'link_before' => '',
221
  'link_after' => '',
@@ -318,10 +319,11 @@ class Advanced_Sidebar_Menu_List_Pages {
318
  $cache = Advanced_Sidebar_Menu_Cache::instance();
319
  $child_pages = $cache->get_child_pages( $this );
320
  if ( false === $child_pages ) {
321
- $args = $this->args;
322
- $args['post_parent'] = $parent_page_id;
323
- $args['fields'] = 'ids';
324
- $child_pages = get_posts( $args );
 
325
 
326
  $cache->add_child_pages( $this, $child_pages );
327
  }
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();
177
  break;
178
  }
179
 
216
  'exclude' => '',
217
  'echo' => 0,
218
  'order' => 'ASC',
219
+ 'orderby' => 'menu_order, title',
220
  'walker' => new Advanced_Sidebar_Menu_Page_Walker(),
221
  'link_before' => '',
222
  'link_after' => '',
319
  $cache = Advanced_Sidebar_Menu_Cache::instance();
320
  $child_pages = $cache->get_child_pages( $this );
321
  if ( false === $child_pages ) {
322
+ $args = $this->args;
323
+ $args['post_parent'] = $parent_page_id;
324
+ $args['fields'] = 'ids';
325
+ $args['suppress_filters'] = false;
326
+ $child_pages = get_posts( $args );
327
 
328
  $cache->add_child_pages( $this, $child_pages );
329
  }
src/Menus/Category.php CHANGED
@@ -452,7 +452,6 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
452
  * @return void
453
  */
454
  public function render() {
455
- // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped
456
  if ( ! $this->is_displayed() ) {
457
  return;
458
  }
@@ -462,12 +461,14 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
462
 
463
  foreach ( $this->get_top_level_terms() as $_cat ) {
464
  $this->set_current_top_level_term( $_cat );
465
- if ( ! $this->is_term_displayed( $this->get_child_terms() ) ) {
 
 
466
  continue;
467
  }
468
 
469
  if ( ! $menu_open || ( 'widget' === $this->instance[ self::EACH_CATEGORY_DISPLAY ] ) ) {
470
- //phpcs
471
  echo $this->args['before_widget'];
472
 
473
  do_action( 'advanced-sidebar-menu/menus/category/render', $this );
@@ -475,6 +476,9 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
475
  if ( ! $menu_open ) {
476
  //must remain in the loop vs the template
477
  $this->title();
 
 
 
478
 
479
  $menu_open = true;
480
  $close_menu = true;
@@ -496,7 +500,6 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
496
  if ( ! $close_menu && $menu_open ) {
497
  echo $this->args['after_widget'];
498
  }
499
- // phpcs:enable WordPress.XSS.EscapeOutput.OutputNotEscaped
500
 
501
  }
502
 
452
  * @return void
453
  */
454
  public function render() {
 
455
  if ( ! $this->is_displayed() ) {
456
  return;
457
  }
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 );
476
  if ( ! $menu_open ) {
477
  //must remain in the loop vs the template
478
  $this->title();
479
+ if ( $this->checked( self::USE_PLUGIN_STYLES ) ) {
480
+ Advanced_Sidebar_Menu_Core::instance()->include_plugin_styles();
481
+ }
482
 
483
  $menu_open = true;
484
  $close_menu = true;
500
  if ( ! $close_menu && $menu_open ) {
501
  echo $this->args['after_widget'];
502
  }
 
503
 
504
  }
505
 
src/Menus/Page.php CHANGED
@@ -168,11 +168,15 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
168
  return;
169
  }
170
 
171
- // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped
172
  echo $this->args['before_widget'];
173
 
174
  do_action( 'advanced-sidebar-menu/menus/page/render', $this );
175
 
 
 
 
 
176
  $output = require Advanced_Sidebar_Menu_Core::instance()->get_template_part( 'page_list.php' );
177
  echo apply_filters( 'advanced_sidebar_menu_page_widget_output', $output, $this->get_current_post(), $this->args, $this->instance, $this );
178
 
168
  return;
169
  }
170
 
171
+ // phpcs:disable
172
  echo $this->args['before_widget'];
173
 
174
  do_action( 'advanced-sidebar-menu/menus/page/render', $this );
175
 
176
+ if ( $this->checked( self::USE_PLUGIN_STYLES ) ) {
177
+ Advanced_Sidebar_Menu_Core::instance()->include_plugin_styles();
178
+ }
179
+
180
  $output = require Advanced_Sidebar_Menu_Core::instance()->get_template_part( 'page_list.php' );
181
  echo apply_filters( 'advanced_sidebar_menu_page_widget_output', $output, $this->get_current_post(), $this->args, $this->instance, $this );
182
 
src/Widget/Category.php CHANGED
@@ -35,6 +35,8 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
35
  self::LEVELS => 1,
36
  );
37
 
 
 
38
 
39
  public function __construct() {
40
  $widget_ops = array(
@@ -44,13 +46,153 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
44
  $control_ops = array( 'width' => 620 );
45
 
46
  parent::__construct( 'advanced_sidebar_menu_category', __( 'Advanced Sidebar Categories Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  }
48
 
49
 
50
  /**
51
  * Form
52
  *
53
- * @since 7.2.0
54
  *
55
  * @param array $instance
56
  *
@@ -58,6 +200,7 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
58
  */
59
  public function form( $instance ) {
60
  $instance = $this->set_instance( $instance, self::$defaults );
 
61
  ?>
62
  <p>
63
  <label>
@@ -71,109 +214,15 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
71
  type="text"
72
  value="<?php echo esc_attr( $instance[ self::TITLE ] ); ?>"/>
73
  </p>
74
- <div class="advanced-sidebar-menu-column">
75
- <div class="advanced-sidebar-menu-column-box">
76
- <p>
77
- <?php $this->checkbox( self::INCLUDE_PARENT ); ?>
78
- <label>
79
- <?php esc_html_e( 'Display highest level parent category', 'advanced-sidebar-menu' ); ?>
80
- </label>
81
- </p>
82
-
83
-
84
- <p>
85
- <?php $this->checkbox( self::INCLUDE_CHILDLESS_PARENT ); ?>
86
- <label>
87
- <?php esc_html_e( 'Display menu when there is only the parent category', 'advanced-sidebar-menu' ); ?>
88
- </label>
89
- </p>
90
-
91
- <p>
92
- <?php $this->checkbox( self::DISPLAY_ALL, self::LEVELS ); ?>
93
- <label>
94
- <?php esc_html_e( 'Always display child categories', 'advanced-sidebar-menu' ); ?>
95
- </label>
96
- </p>
97
- <div
98
- data-js="<?php echo esc_attr( $this->get_field_id( self::LEVELS ) ); ?>"
99
- <?php $this->hide_element( self::DISPLAY_ALL ); ?>>
100
- <p>
101
- <label>
102
- <?php esc_html_e( 'Levels to display', 'advanced-sidebar-menu' ); ?>:</label>
103
- <select
104
- name="<?php echo esc_attr( $this->get_field_name( self::LEVELS ) ); ?>">
105
- <?php
106
- for ( $i = 1; $i < 6; $i ++ ) {
107
- ?>
108
- <option
109
- value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, (int) $instance[ self::LEVELS ] ); ?>>
110
- <?php echo esc_html( $i ); ?>
111
- </option>
112
-
113
- <?php
114
- }
115
- ?>
116
- </select>
117
- </p>
118
- </div>
119
-
120
- <?php do_action( 'advanced-sidebar-menu/widget/category/display-box', $instance, $this ); ?>
121
-
122
- </div>
123
- <div class="advanced-sidebar-menu-column-box">
124
- <p>
125
-
126
- <?php $this->checkbox( self::DISPLAY_ON_SINGLE, self::EACH_CATEGORY_DISPLAY ); ?>
127
- <label>
128
- <?php esc_html_e( 'Display categories on single posts', 'advanced-sidebar-menu' ); ?>
129
- </label>
130
- </p>
131
-
132
- <div
133
- data-js="<?php echo esc_attr( $this->get_field_id( self::EACH_CATEGORY_DISPLAY ) ); ?>" <?php $this->hide_element( self::DISPLAY_ON_SINGLE, $instance ); ?>>
134
- <p>
135
- <label><?php esc_html_e( "Display each single post's category", 'advanced-sidebar-menu' ); ?>
136
- :</label>
137
- <select
138
- name="<?php echo esc_attr( $this->get_field_name( self::EACH_CATEGORY_DISPLAY ) ); ?>">
139
- <option
140
- value="widget" <?php selected( 'widget', $instance[ self::EACH_CATEGORY_DISPLAY ] ); ?>>
141
- <?php esc_html_e( 'In a new widget', 'advanced-sidebar-menu' ); ?>
142
- </option>
143
- <option value="list" <?php selected( 'list', $instance[ self::EACH_CATEGORY_DISPLAY ] ); ?>>
144
- <?php esc_html_e( 'In another list in the same widget', 'advanced-sidebar-menu' ); ?>
145
- </option>
146
- </select>
147
- </p>
148
- </div>
149
-
150
- <?php do_action( 'advanced-sidebar-menu/widget/category/singles-box', $instance, $this ); ?>
151
 
152
- </div>
153
-
154
- <div class="advanced-sidebar-menu-column-box">
155
- <p>
156
- <label>
157
- <?php esc_html_e( 'Categories to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
158
- </label>
159
- <input
160
- id="<?php echo esc_attr( $this->get_field_id( self::EXCLUDE ) ); ?>"
161
- name="<?php echo esc_attr( $this->get_field_name( self::EXCLUDE ) ); ?>"
162
- type="text"
163
- class="widefat"
164
- value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>"/>
165
- </p>
166
-
167
- <?php
168
- do_action( 'advanced-sidebar-menu/widget/category/exclude-box', $instance, $this );
169
- ?>
170
- </div>
171
 
172
- <?php
173
  if ( has_action( 'advanced_sidebar_menu_category_widget_form' ) ) {
174
  ?>
175
  <div class="advanced-sidebar-menu-column-box">
176
- <?php do_action( 'advanced_sidebar_menu_category_widget_form', $instance, $this ); ?>
 
177
  </div>
178
  <?php
179
  }
@@ -183,10 +232,14 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
183
 
184
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
185
  <?php
 
 
186
  do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
187
  ?>
188
  </div>
 
189
  <?php
 
190
 
191
  }
192
 
35
  self::LEVELS => 1,
36
  );
37
 
38
+ protected static $hooked = false;
39
+
40
 
41
  public function __construct() {
42
  $widget_ops = array(
46
  $control_ops = array( 'width' => 620 );
47
 
48
  parent::__construct( 'advanced_sidebar_menu_category', __( 'Advanced Sidebar Categories Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
49
+
50
+ if ( ! self::$hooked ) {
51
+ self::$hooked = true;
52
+ $this->hook();
53
+ }
54
+ }
55
+
56
+
57
+ protected function hook() {
58
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_display' ), 5, 1 );
59
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_styles' ), 10, 1 );
60
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_singles' ), 15, 1 );
61
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_exclude' ), 20, 1 );
62
+
63
+ }
64
+
65
+
66
+ public function box_display( array $instance ) {
67
+ ?>
68
+ <div class="advanced-sidebar-menu-column-box">
69
+ <p>
70
+ <?php $this->checkbox( self::INCLUDE_PARENT ); ?>
71
+ <label>
72
+ <?php esc_html_e( 'Display highest level parent category', 'advanced-sidebar-menu' ); ?>
73
+ </label>
74
+ </p>
75
+ <p>
76
+ <?php $this->checkbox( self::INCLUDE_CHILDLESS_PARENT ); ?>
77
+ <label>
78
+ <?php esc_html_e( 'Display menu when there is only the parent category', 'advanced-sidebar-menu' ); ?>
79
+ </label>
80
+ </p>
81
+ <p>
82
+ <?php $this->checkbox( self::DISPLAY_ALL, self::LEVELS ); ?>
83
+ <label>
84
+ <?php esc_html_e( 'Always display child categories', 'advanced-sidebar-menu' ); ?>
85
+ </label>
86
+ </p>
87
+ <div
88
+ data-js="<?php echo esc_attr( $this->get_field_id( self::LEVELS ) ); ?>"
89
+ <?php $this->hide_element( self::DISPLAY_ALL ); ?>>
90
+ <p>
91
+ <label>
92
+ <?php esc_html_e( 'Levels to display', 'advanced-sidebar-menu' ); ?>:</label>
93
+ <select
94
+ name="<?php echo esc_attr( $this->get_field_name( self::LEVELS ) ); ?>">
95
+ <?php
96
+ for ( $i = 1; $i < 6; $i ++ ) {
97
+ ?>
98
+ <option
99
+ value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, (int) $instance[ self::LEVELS ] ); ?>>
100
+ <?php echo esc_html( $i ); ?>
101
+ </option>
102
+
103
+ <?php
104
+ }
105
+ ?>
106
+ </select>
107
+ </p>
108
+ </div>
109
+
110
+ <?php do_action( 'advanced-sidebar-menu/widget/category/display-box', $instance, $this ); ?>
111
+
112
+ </div>
113
+ <?php
114
+ }
115
+
116
+
117
+ public function box_styles( array $instance ) {
118
+ ?>
119
+ <div class="advanced-sidebar-menu-column-box">
120
+ <p>
121
+ <?php $this->checkbox( self::USE_PLUGIN_STYLES ); ?>
122
+ <label>
123
+ <?php esc_html_e( "Use this plugin's default styling", 'advanced-sidebar-menu' ); ?>
124
+ </label>
125
+ </p>
126
+
127
+ <?php do_action( 'advanced-sidebar-menu/widget/category/styles-box', $instance, $this ); ?>
128
+ </div>
129
+ <?php
130
+ }
131
+
132
+
133
+ public function box_singles( array $instance ) {
134
+ ?>
135
+ <div class="advanced-sidebar-menu-column-box">
136
+ <p>
137
+
138
+ <?php $this->checkbox( self::DISPLAY_ON_SINGLE, self::EACH_CATEGORY_DISPLAY ); ?>
139
+ <label>
140
+ <?php esc_html_e( 'Display categories on single posts', 'advanced-sidebar-menu' ); ?>
141
+ </label>
142
+ </p>
143
+
144
+ <div
145
+ data-js="<?php echo esc_attr( $this->get_field_id( self::EACH_CATEGORY_DISPLAY ) ); ?>" <?php $this->hide_element( self::DISPLAY_ON_SINGLE, $instance ); ?>>
146
+ <p>
147
+ <label><?php esc_html_e( "Display each single post's category", 'advanced-sidebar-menu' ); ?>
148
+ :</label>
149
+ <select
150
+ name="<?php echo esc_attr( $this->get_field_name( self::EACH_CATEGORY_DISPLAY ) ); ?>">
151
+ <option
152
+ value="widget" <?php selected( 'widget', $instance[ self::EACH_CATEGORY_DISPLAY ] ); ?>>
153
+ <?php esc_html_e( 'In a new widget', 'advanced-sidebar-menu' ); ?>
154
+ </option>
155
+ <option value="list" <?php selected( 'list', $instance[ self::EACH_CATEGORY_DISPLAY ] ); ?>>
156
+ <?php esc_html_e( 'In another list in the same widget', 'advanced-sidebar-menu' ); ?>
157
+ </option>
158
+ </select>
159
+ </p>
160
+ </div>
161
+
162
+ <?php do_action( 'advanced-sidebar-menu/widget/category/singles-box', $instance, $this ); ?>
163
+
164
+ </div>
165
+ <?php
166
+ }
167
+
168
+
169
+ public function box_exclude( array $instance ) {
170
+ ?>
171
+ <div class="advanced-sidebar-menu-column-box">
172
+ <p>
173
+ <label>
174
+ <?php esc_html_e( 'Categories to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
175
+ </label>
176
+ <input
177
+ id="<?php echo esc_attr( $this->get_field_id( self::EXCLUDE ) ); ?>"
178
+ name="<?php echo esc_attr( $this->get_field_name( self::EXCLUDE ) ); ?>"
179
+ type="text"
180
+ class="widefat"
181
+ value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>"/>
182
+ </p>
183
+
184
+ <?php
185
+ do_action( 'advanced-sidebar-menu/widget/category/exclude-box', $instance, $this );
186
+ ?>
187
+ </div>
188
+ <?php
189
  }
190
 
191
 
192
  /**
193
  * Form
194
  *
195
+ * @since 7.2.1
196
  *
197
  * @param array $instance
198
  *
200
  */
201
  public function form( $instance ) {
202
  $instance = $this->set_instance( $instance, self::$defaults );
203
+ do_action( 'advanced-sidebar-menu/widget/category/before-form', $instance, $this );
204
  ?>
205
  <p>
206
  <label>
214
  type="text"
215
  value="<?php echo esc_attr( $instance[ self::TITLE ] ); ?>"/>
216
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
+ <div class="advanced-sidebar-menu-column">
219
+ <?php do_action( 'advanced-sidebar-menu/widget/category/left-column', $instance, $this );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
 
 
221
  if ( has_action( 'advanced_sidebar_menu_category_widget_form' ) ) {
222
  ?>
223
  <div class="advanced-sidebar-menu-column-box">
224
+ <?php
225
+ do_action( 'advanced_sidebar_menu_category_widget_form', $instance, $this ); ?>
226
  </div>
227
  <?php
228
  }
232
 
233
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
234
  <?php
235
+ do_action( 'advanced-sidebar-menu/widget/category/right-column', $instance, $this );
236
+ //@deprecated action
237
  do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
238
  ?>
239
  </div>
240
+
241
  <?php
242
+ do_action( 'advanced-sidebar-menu/widget/category/after-form', $instance, $this );
243
 
244
  }
245
 
src/Widget/Page.php CHANGED
@@ -31,6 +31,8 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
31
  self::LEVELS => 1,
32
  );
33
 
 
 
34
 
35
  public function __construct() {
36
  $widget_ops = array(
@@ -43,17 +45,150 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
43
 
44
  parent::__construct( 'advanced_sidebar_menu', __( 'Advanced Sidebar Pages Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
 
49
  /**
50
- * Output a simple widget Form
51
- *
52
- * Not of ton of options here but who needs them
53
- * Most of the magic happens automatically
54
  *
55
- * @filters do_action('advanced_sidebar_menu_page_widget_form', $instance, $this->get_field_name('parent_only'),
56
- * $this->get_field_id('parent_only'));
57
  *
58
  * @param array $instance
59
  *
@@ -61,6 +196,7 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
61
  */
62
  public function form( $instance ) {
63
  $instance = $this->set_instance( $instance, self::$defaults );
 
64
  ?>
65
  <p xmlns="http://www.w3.org/1999/html">
66
  <label>
@@ -75,96 +211,8 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
75
  value="<?php echo esc_attr( $instance[ self::TITLE ] ); ?>"/>
76
  </p>
77
  <div class="advanced-sidebar-menu-column">
78
- <div class="advanced-sidebar-menu-column-box">
79
- <p>
80
- <?php $this->checkbox( self::INCLUDE_PARENT ); ?>
81
- <label>
82
- <?php esc_html_e( 'Display highest level parent page', 'advanced-sidebar-menu' ); ?>
83
- </label>
84
- </p>
85
-
86
-
87
- <p>
88
- <?php $this->checkbox( self::INCLUDE_CHILDLESS_PARENT ); ?>
89
- <label>
90
- <?php esc_html_e( 'Display menu when there is only the parent page', 'advanced-sidebar-menu' ); ?>
91
- </label>
92
- </p>
93
-
94
- <p>
95
- <?php $this->checkbox( self::DISPLAY_ALL, self::LEVELS ); ?>
96
- <label>
97
- <?php esc_html_e( 'Always display child pages', 'advanced-sidebar-menu' ); ?>:
98
- </label>
99
- </p>
100
-
101
- <div
102
- data-js="<?php echo esc_attr( $this->get_field_id( self::LEVELS ) ); ?>"
103
- <?php $this->hide_element( self::DISPLAY_ALL ); ?>>
104
- <p>
105
- <label>
106
- <?php esc_html_e( 'Levels to display', 'advanced-sidebar-menu' ); ?>:</label>
107
- <select
108
- name="<?php echo esc_attr( $this->get_field_name( self::LEVELS ) ); ?>">
109
- <?php
110
- for ( $i = 1; $i < 6; $i ++ ) {
111
- ?>
112
- <option
113
- value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, (int) $instance[ self::LEVELS ] ); ?>>
114
- <?php echo esc_html( $i ); ?>
115
- </option>
116
-
117
- <?php
118
- }
119
- ?>
120
- </select>
121
- </p>
122
- </div>
123
-
124
- <?php do_action( 'advanced-sidebar-menu/widget/page/display-box', $instance, $this ); ?>
125
-
126
- </div>
127
- <div class="advanced-sidebar-menu-column-box">
128
- <p>
129
- <label>
130
- <?php esc_html_e( 'Order by', 'advanced-sidebar-menu' ); ?>:
131
- </label>
132
- <select
133
- id="<?php echo esc_attr( $this->get_field_id( self::ORDER_BY ) ); ?>"
134
- name="<?php echo esc_attr( $this->get_field_name( self::ORDER_BY ) ); ?>">
135
- <?php
136
- $order_by = (array) apply_filters( 'advanced-sidebar-menu/widget/page/order-by-options', array(
137
- 'menu_order' => 'Page Order',
138
- 'post_title' => 'Title',
139
- 'post_date' => 'Published Date',
140
- ) );
141
-
142
- foreach ( $order_by as $key => $order ) {
143
- printf( '<option value="%s" %s>%s</option>', esc_attr( $key ), selected( $instance[ self::ORDER_BY ], $key, false ), esc_html( $order ) );
144
- }
145
- ?>
146
- </select>
147
- </p>
148
- <?php do_action( 'advanced-sidebar-menu/widget/page/order-box', $instance, $this ); ?>
149
-
150
- </div>
151
- <div class="advanced-sidebar-menu-column-box">
152
- <p>
153
- <label>
154
- <?php esc_html_e( 'Pages to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
155
- </label>
156
- <input
157
- id="<?php echo esc_attr( $this->get_field_id( self::EXCLUDE ) ); ?>"
158
- name="<?php echo esc_attr( $this->get_field_name( self::EXCLUDE ) ); ?>"
159
- class="widefat"
160
- type="text"
161
- value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>"/>
162
- </p>
163
- <?php
164
- do_action( 'advanced-sidebar-menu/widget/page/exclude-box', $instance, $this );
165
- ?>
166
- </div>
167
  <?php
 
168
  if ( has_action( 'advanced_sidebar_menu_page_widget_form' ) ) {
169
  ?>
170
  <div class="advanced-sidebar-menu-column-box">
@@ -176,11 +224,15 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
176
  </div>
177
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
178
  <?php
 
 
179
  do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
 
 
180
  ?>
181
  </div>
182
  <?php
183
-
184
  }
185
 
186
 
31
  self::LEVELS => 1,
32
  );
33
 
34
+ protected static $hooked = false;
35
+
36
 
37
  public function __construct() {
38
  $widget_ops = array(
45
 
46
  parent::__construct( 'advanced_sidebar_menu', __( 'Advanced Sidebar Pages Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
47
 
48
+ if ( ! self::$hooked ) {
49
+ self::$hooked = true;
50
+ $this->hook();
51
+ }
52
+
53
+ }
54
+
55
+
56
+ protected function hook() {
57
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_display' ), 5, 1 );
58
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_styles' ), 10, 1 );
59
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_order' ), 15, 1 );
60
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_exclude' ), 20, 1 );
61
+
62
+ }
63
+
64
+
65
+ public function box_display( array $instance ) {
66
+ ?>
67
+ <div class="advanced-sidebar-menu-column-box">
68
+ <p>
69
+ <?php $this->checkbox( self::INCLUDE_PARENT ); ?>
70
+ <label>
71
+ <?php esc_html_e( 'Display highest level parent page', 'advanced-sidebar-menu' ); ?>
72
+ </label>
73
+ </p>
74
+
75
+
76
+ <p>
77
+ <?php $this->checkbox( self::INCLUDE_CHILDLESS_PARENT ); ?>
78
+ <label>
79
+ <?php esc_html_e( 'Display menu when there is only the parent page', 'advanced-sidebar-menu' ); ?>
80
+ </label>
81
+ </p>
82
+
83
+ <p>
84
+ <?php $this->checkbox( self::DISPLAY_ALL, self::LEVELS ); ?>
85
+ <label>
86
+ <?php esc_html_e( 'Always display child pages', 'advanced-sidebar-menu' ); ?>:
87
+ </label>
88
+ </p>
89
+
90
+ <div
91
+ data-js="<?php echo esc_attr( $this->get_field_id( self::LEVELS ) ); ?>"
92
+ <?php $this->hide_element( self::DISPLAY_ALL ); ?>>
93
+ <p>
94
+ <label>
95
+ <?php esc_html_e( 'Levels to display', 'advanced-sidebar-menu' ); ?>:</label>
96
+ <select
97
+ name="<?php echo esc_attr( $this->get_field_name( self::LEVELS ) ); ?>">
98
+ <?php
99
+ for ( $i = 1; $i < 6; $i ++ ) {
100
+ ?>
101
+ <option
102
+ value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, (int) $instance[ self::LEVELS ] ); ?>>
103
+ <?php echo esc_html( $i ); ?>
104
+ </option>
105
+
106
+ <?php
107
+ }
108
+ ?>
109
+ </select>
110
+ </p>
111
+ </div>
112
+
113
+ <?php do_action( 'advanced-sidebar-menu/widget/page/display-box', $instance, $this ); ?>
114
+
115
+ </div>
116
+ <?php
117
+ }
118
+
119
+
120
+ public function box_styles( array $instance ) {
121
+ ?>
122
+ <div class="advanced-sidebar-menu-column-box">
123
+ <p>
124
+ <?php $this->checkbox( self::USE_PLUGIN_STYLES ); ?>
125
+ <label>
126
+ <?php esc_html_e( "Use this plugin's default styling", 'advanced-sidebar-menu' ); ?>:
127
+ </label>
128
+ </p>
129
+ <?php do_action( 'advanced-sidebar-menu/widget/page/styles-box', $instance, $this ); ?>
130
+ </div>
131
+ <?php
132
+ }
133
+
134
+
135
+ public function box_order( array $instance ) {
136
+ ?>
137
+ <div class="advanced-sidebar-menu-column-box">
138
+
139
+ <p>
140
+ <label>
141
+ <?php esc_html_e( 'Order by', 'advanced-sidebar-menu' ); ?>:
142
+ </label>
143
+ <select
144
+ id="<?php echo esc_attr( $this->get_field_id( self::ORDER_BY ) ); ?>"
145
+ name="<?php echo esc_attr( $this->get_field_name( self::ORDER_BY ) ); ?>">
146
+ <?php
147
+ $order_by = (array) apply_filters( 'advanced-sidebar-menu/widget/page/order-by-options', array(
148
+ 'menu_order' => 'Page Order',
149
+ 'post_title' => 'Title',
150
+ 'post_date' => 'Published Date',
151
+ ) );
152
+
153
+ foreach ( $order_by as $key => $order ) {
154
+ printf( '<option value="%s" %s>%s</option>', esc_attr( $key ), selected( $instance[ self::ORDER_BY ], $key, false ), esc_html( $order ) );
155
+ }
156
+ ?>
157
+ </select>
158
+ </p>
159
+ <?php do_action( 'advanced-sidebar-menu/widget/page/order-box', $instance, $this ); ?>
160
+
161
+ </div>
162
+ <?php
163
+ }
164
+
165
+
166
+ public function box_exclude( array $instance ) {
167
+ ?>
168
+ <div class="advanced-sidebar-menu-column-box">
169
+ <p>
170
+ <label>
171
+ <?php esc_html_e( 'Pages to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
172
+ </label>
173
+ <input
174
+ id="<?php echo esc_attr( $this->get_field_id( self::EXCLUDE ) ); ?>"
175
+ name="<?php echo esc_attr( $this->get_field_name( self::EXCLUDE ) ); ?>"
176
+ class="widefat"
177
+ type="text"
178
+ value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>"/>
179
+ </p>
180
+ <?php
181
+ do_action( 'advanced-sidebar-menu/widget/page/exclude-box', $instance, $this );
182
+ ?>
183
+ </div>
184
+ <?php
185
  }
186
 
187
 
188
  /**
189
+ * Form
 
 
 
190
  *
191
+ * @since 7.2.1
 
192
  *
193
  * @param array $instance
194
  *
196
  */
197
  public function form( $instance ) {
198
  $instance = $this->set_instance( $instance, self::$defaults );
199
+ do_action( 'advanced-sidebar-menu/widget/page/before-form', $instance, $this );
200
  ?>
201
  <p xmlns="http://www.w3.org/1999/html">
202
  <label>
211
  value="<?php echo esc_attr( $instance[ self::TITLE ] ); ?>"/>
212
  </p>
213
  <div class="advanced-sidebar-menu-column">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  <?php
215
+ do_action( 'advanced-sidebar-menu/widget/page/left-column', $instance, $this );
216
  if ( has_action( 'advanced_sidebar_menu_page_widget_form' ) ) {
217
  ?>
218
  <div class="advanced-sidebar-menu-column-box">
224
  </div>
225
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
226
  <?php
227
+
228
+ //@deprecated action
229
  do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
230
+
231
+ do_action( 'advanced-sidebar-menu/widget/page/right-column', $instance, $this );
232
  ?>
233
  </div>
234
  <?php
235
+ do_action( 'advanced-sidebar-menu/widget/page/after-form', $instance, $this );
236
  }
237
 
238
 
views/sidebar-menu.css ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .advanced-sidebar-menu ul li a{
2
+ font-weight: bold;
3
+ font-size: 130%;
4
+ text-decoration: none;
5
+ }
6
+
7
+ .advanced-sidebar-menu ul li a:hover{
8
+ text-decoration: underline;
9
+ }
10
+
11
+ .advanced-sidebar-menu ul ul li a{
12
+ font-weight: normal;
13
+ font-size: 100%;
14
+ }
15
+
16
+ .advanced-sidebar-menu ul{
17
+ margin: 0 0 0 18px;
18
+ list-style: none;
19
+ }
20
+
21
+ .advanced-sidebar-menu ul li{
22
+ list-style:none;
23
+ margin: 0;
24
+ }
25
+
26
+ .advanced-sidebar-menu li.current_page_item{
27
+ list-style-type: disc;
28
+ }
29
+
30
+ .advanced-sidebar-menu li.current_page_item a{
31
+ font-weight: bold;
32
+ }
33
+
34
+ .advanced-sidebar-menu li.current_page_item li a{
35
+ font-weight: normal;
36
+ }