Advanced Sidebar Menu - Version 8.5.0

Version Description

  • Introduce Utils class for shared non specific functionality.
  • Introduce is_checked method for determining checkbox state from anywhere.
  • Make Widget_Abstract::set_instance public for external use.
  • Complete preparations for PRO version 8.4.
  • Minimum required version for PRO 8.4.
Download this release

Release Info

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

Code changes from version 8.4.0 to 8.5.0

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.4.0
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.4.0' );
23
  define( 'ADVANCED_SIDEBAR_MENU_REQUIRED_PRO_VERSION', '8.2.0' );
24
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
25
  define( 'ADVANCED_SIDEBAR_MENU_URL', plugin_dir_url( __FILE__ ) );
@@ -35,6 +35,7 @@ use Advanced_Sidebar_Menu\Notice;
35
  use Advanced_Sidebar_Menu\Scripts;
36
  use Advanced_Sidebar_Menu\Traits\Memoize;
37
  use Advanced_Sidebar_Menu\Traits\Singleton;
 
38
  use Advanced_Sidebar_Menu\Walkers\Category_Walker;
39
  use Advanced_Sidebar_Menu\Walkers\Page_Walker;
40
  use Advanced_Sidebar_Menu\Widget\Category as Widget_Category;
@@ -82,6 +83,7 @@ function advanced_sidebar_menu_autoload( $class ) {
82
  List_Pages::class => 'List_Pages.php',
83
  Notice::class => 'Notice.php',
84
  Scripts::class => 'Scripts.php',
 
85
 
86
  // Menus.
87
  Category::class => 'Menus/Category.php',
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.5.0
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.5.0' );
23
  define( 'ADVANCED_SIDEBAR_MENU_REQUIRED_PRO_VERSION', '8.2.0' );
24
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
25
  define( 'ADVANCED_SIDEBAR_MENU_URL', plugin_dir_url( __FILE__ ) );
35
  use Advanced_Sidebar_Menu\Scripts;
36
  use Advanced_Sidebar_Menu\Traits\Memoize;
37
  use Advanced_Sidebar_Menu\Traits\Singleton;
38
+ use Advanced_Sidebar_Menu\Utils;
39
  use Advanced_Sidebar_Menu\Walkers\Category_Walker;
40
  use Advanced_Sidebar_Menu\Walkers\Page_Walker;
41
  use Advanced_Sidebar_Menu\Widget\Category as Widget_Category;
83
  List_Pages::class => 'List_Pages.php',
84
  Notice::class => 'Notice.php',
85
  Scripts::class => 'Scripts.php',
86
+ Utils::class => 'Utils.php',
87
 
88
  // Menus.
89
  Category::class => 'Menus/Category.php',
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: menus, sidebar menu, hierarchy, category menu, pages menu, dynamic
6
  Requires at least: 5.2.0
7
  Tested up to: 5.7.2
8
  Requires PHP: 5.6.0
9
- Stable tag: 8.4.0
10
 
11
  == Description ==
12
 
@@ -155,11 +155,16 @@ Yes. Based on whatever page, post, or category you are on, the menu will change
155
 
156
 
157
  == Changelog ==
 
 
 
 
 
 
 
158
  = 8.4.0 =
159
  * Introduce new Category Walker to increase extensibility.
160
  * Support `data-level` on all widgets.
161
- * Complete preparations for PRO version 8.4.
162
- * Minimum required version for PRO 8.4.
163
 
164
  = 8.3.4 =
165
  * Support widget fields with array values.
@@ -254,7 +259,7 @@ Major version update. See <a href="https://onpointplugins.com/advanced-sidebar-m
254
  * Bump required PHP version to 5.4.4.
255
 
256
  == Upgrade Notice ==
257
- = 8.4.0 =
258
  Update to support PRO version 8.4.0.
259
 
260
  = 8.2.0 =
6
  Requires at least: 5.2.0
7
  Tested up to: 5.7.2
8
  Requires PHP: 5.6.0
9
+ Stable tag: 8.5.0
10
 
11
  == Description ==
12
 
155
 
156
 
157
  == Changelog ==
158
+ = 8.5.0 =
159
+ * Introduce `Utils` class for shared non specific functionality.
160
+ * Introduce `is_checked` method for determining checkbox state from anywhere.
161
+ * Make `Widget_Abstract::set_instance` public for external use.
162
+ * Complete preparations for PRO version 8.4.
163
+ * Minimum required version for PRO 8.4.
164
+
165
  = 8.4.0 =
166
  * Introduce new Category Walker to increase extensibility.
167
  * Support `data-level` on all widgets.
 
 
168
 
169
  = 8.3.4 =
170
  * Support widget fields with array values.
259
  * Bump required PHP version to 5.4.4.
260
 
261
  == Upgrade Notice ==
262
+ = 8.5.0 =
263
  Update to support PRO version 8.4.0.
264
 
265
  = 8.2.0 =
src/Utils.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Advanced_Sidebar_Menu;
4
+
5
+ use Advanced_Sidebar_Menu\Traits\Singleton;
6
+
7
+ /**
8
+ * Various helpers for the Advanced Sidebar Menu plugin.
9
+ *
10
+ * @author OnPoint Plugins
11
+ * @since 8.4.1
12
+ */
13
+ class Utils {
14
+ use Singleton;
15
+
16
+ /**
17
+ * Checks if a widget's checkbox is checked.
18
+ *
19
+ * Checks first for a value then verifies the value = checked.
20
+ *
21
+ * @param string $name - name of checkbox.
22
+ * @param array $settings - Widget settings.
23
+ *
24
+ * @return bool
25
+ */
26
+ public function is_checked( $name, array $settings ) {
27
+ // Handle array type names (e.g. open-links[all]).
28
+ preg_match( '/(?<field>\S*?)\[(?<key>\S*?)]/', $name, $array );
29
+ if ( ! empty( $array['field'] ) && ! empty( $array['key'] ) ) {
30
+ return isset( $settings[ $array['field'] ][ $array['key'] ] ) && 'checked' === $settings[ $array['field'] ][ $array['key'] ];
31
+ }
32
+
33
+ // Standard non array names.
34
+ return isset( $settings[ $name ] ) && 'checked' === $settings[ $name ];
35
+ }
36
+ }
src/Widget/Widget_Abstract.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
  namespace Advanced_Sidebar_Menu\Widget;
3
 
 
 
4
  /**
5
  * Base class for this plugin's widgets.
6
  *
@@ -27,7 +29,7 @@ abstract class Widget_Abstract extends \WP_Widget {
27
  *
28
  * @return array
29
  */
30
- protected function set_instance( array $instance, array $defaults ) {
31
  $this->widget_settings = (array) wp_parse_args( $instance, $defaults );
32
 
33
  return $this->widget_settings;
@@ -44,14 +46,7 @@ abstract class Widget_Abstract extends \WP_Widget {
44
  * @return bool
45
  */
46
  public function checked( $name ) {
47
- // Handle array type names (e.g. open-links[all]).
48
- preg_match( '/(?<field>\S*?)\[(?<key>\S*?)]/', $name, $array );
49
- if ( ! empty( $array['field'] ) && ! empty( $array['key'] ) ) {
50
- return isset( $this->widget_settings[ $array['field'] ][ $array['key'] ] ) && 'checked' === $this->widget_settings[ $array['field'] ][ $array['key'] ];
51
- }
52
-
53
- // Standard non array names.
54
- return isset( $this->widget_settings[ $name ] ) && 'checked' === $this->widget_settings[ $name ];
55
  }
56
 
57
 
1
  <?php
2
  namespace Advanced_Sidebar_Menu\Widget;
3
 
4
+ use Advanced_Sidebar_Menu\Utils;
5
+
6
  /**
7
  * Base class for this plugin's widgets.
8
  *
29
  *
30
  * @return array
31
  */
32
+ public function set_instance( array $instance, array $defaults ) {
33
  $this->widget_settings = (array) wp_parse_args( $instance, $defaults );
34
 
35
  return $this->widget_settings;
46
  * @return bool
47
  */
48
  public function checked( $name ) {
49
+ return Utils::instance()->is_checked( $name, $this->widget_settings );
 
 
 
 
 
 
 
50
  }
51
 
52