Advanced Sidebar Menu - Version 7.4.5

Version Description

Download this release

Release Info

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

Code changes from version 7.4.4 to 7.4.5

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.4.4
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.4.4' );
19
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
20
 
21
  if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
@@ -80,8 +80,12 @@ function advanced_sidebar_menu_translate() {
80
  }
81
 
82
  add_action( 'admin_print_scripts', 'advanced_sidebar_menu_script' );
 
 
 
 
83
  /**
84
- * Add js and css to the admin
85
  *
86
  * @return void
87
  */
@@ -98,11 +102,38 @@ function advanced_sidebar_menu_script() {
98
  apply_filters( 'asm_style', 'advanced-sidebar-menu-style' ),
99
  plugins_url( 'resources/css/advanced-sidebar-menu.css', __FILE__ ),
100
  array(),
101
- ADVANCED_SIDEBAR_BASIC_VERSION,
102
- false
103
  );
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  add_action( 'advanced-sidebar-menu/widget/category/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
108
  add_action( 'advanced-sidebar-menu/widget/page/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
@@ -153,8 +184,7 @@ function advanced_sidebar_menu_upgrade_notice( array $instance, WP_Widget $widge
153
  <?php
154
  }
155
  ?>
156
- <li><?php esc_html_e( 'Ability to display the widgets everywhere the sidebar displays.', 'advanced-sidebar-menu' ); ?>
157
- <strong> NEW</strong></li>
158
  <li><?php esc_html_e( 'Support for custom navigation menus from Appearance -> Menus.', 'advanced-sidebar-menu' ); ?></li>
159
  </ol>
160
  <p>
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.4.5
8
  * Author URI: https://matlipe.com
9
  * Text Domain: advanced-sidebar-menu
10
  *
15
  return;
16
  }
17
 
18
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.4.5' );
19
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
20
 
21
  if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
80
  }
81
 
82
  add_action( 'admin_print_scripts', 'advanced_sidebar_menu_script' );
83
+ // UGH! Beaver Builder hack.
84
+ if ( isset( $_GET['fl_builder'] ) ) {
85
+ add_action( 'wp_enqueue_scripts', 'advanced_sidebar_menu_script' );
86
+ }
87
  /**
88
+ * Add js and css to the admin and in specific cases the front-end.
89
  *
90
  * @return void
91
  */
102
  apply_filters( 'asm_style', 'advanced-sidebar-menu-style' ),
103
  plugins_url( 'resources/css/advanced-sidebar-menu.css', __FILE__ ),
104
  array(),
105
+ ADVANCED_SIDEBAR_BASIC_VERSION
 
106
  );
107
  }
108
 
109
+ add_action( 'advanced-sidebar-menu/widget/category/after-form', 'advanced_sidebar_menu_init_widget_js', 1000 );
110
+ add_action( 'advanced-sidebar-menu/widget/page/after-form', 'advanced_sidebar_menu_init_widget_js', 1000 );
111
+ add_action( 'advanced-sidebar-menu/widget/navigation-menu/after-form', 'advanced_sidebar_menu_init_widget_js', 1000 );
112
+
113
+ /**
114
+ * Trigger any JS needed by the widgets.
115
+ * This is outputted into the markup for each widget so it may be
116
+ * trigger whether the widget is loaded on the front-end by
117
+ * page builders or the backend by standard WordPress or
118
+ * really anywhere.
119
+ *
120
+ * @return void
121
+ */
122
+ function advanced_sidebar_menu_init_widget_js() {
123
+ if ( WP_DEBUG ) {
124
+ ?>
125
+ <!-- <?php echo __FILE__; ?>-->
126
+ <?php
127
+ }
128
+ ?>
129
+ <script>
130
+ if (typeof (advanced_sidebar_menu) !== 'undefined') {
131
+ advanced_sidebar_menu.init()
132
+ }
133
+ </script>
134
+ <?php
135
+ }
136
+
137
 
138
  add_action( 'advanced-sidebar-menu/widget/category/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
139
  add_action( 'advanced-sidebar-menu/widget/page/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
184
  <?php
185
  }
186
  ?>
187
+ <li><?php esc_html_e( 'Ability to display the widgets everywhere the sidebar displays.', 'advanced-sidebar-menu' ); ?></li>
 
188
  <li><?php esc_html_e( 'Support for custom navigation menus from Appearance -> Menus.', 'advanced-sidebar-menu' ); ?></li>
189
  </ol>
190
  <p>
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.7.0
7
- Tested up to: 5.0.2
8
  Requires PHP: 5.2.4
9
- Stable tag: 7.4.4
10
 
11
  == Description ==
12
 
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.0.3
8
  Requires PHP: 5.2.4
9
+ Stable tag: 7.4.5
10
 
11
  == Description ==
12
 
resources/js/advanced-sidebar-menu.js CHANGED
@@ -5,19 +5,68 @@
5
  *
6
  **/
7
  function asm_reveal_element(this_element_id) {
8
- var el = jQuery( '[data-js="' + this_element_id + '"]' );
9
 
10
  el.toggle();
11
  var status = el.is(':visible') ? 'show' : 'hide';
12
- jQuery( document ).trigger('advanced-sidebar-menu/reveal-element', [this_element_id, status]);
 
13
  }
14
 
15
- jQuery(function ($) {
16
- /**
17
- * Use JS to show/hide widget elements instead of PHP because sometimes widgets are loaded
18
- * in weird ways like ajax and we don't want any fields hidden if the JS is never loaded
19
- * to later show them
20
- */
21
- $('[data-advanced-sidebar-menu-hide="1"]').hide();
22
- $('[data-advanced-sidebar-menu-hide="0"]').show();
23
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  *
6
  **/
7
  function asm_reveal_element(this_element_id) {
8
+ var el = jQuery('[data-js="' + this_element_id + '"]');
9
 
10
  el.toggle();
11
  var status = el.is(':visible') ? 'show' : 'hide';
12
+ advanced_sidebar_menu.set_hide_state(el);
13
+ jQuery(document).trigger('advanced-sidebar-menu/reveal-element', [this_element_id, status]);
14
  }
15
 
16
+ /**
17
+ * Proper handling of the show/hide of elements
18
+ * for widgets
19
+ *
20
+ * @since 7.4.5
21
+ */
22
+ var advanced_sidebar_menu = {
23
+
24
+ /**
25
+ * Called by PHP so this will run no matter where the widget is loaded.
26
+ * This solves issues with page builders as well as widget updating.
27
+ *
28
+ * @since 7.4.5
29
+ */
30
+ init: function () {
31
+ this.show_hide_elements();
32
+ jQuery(document).trigger('advanced-sidebar-menu/init');
33
+ },
34
+
35
+ /**
36
+ * Set the data attribute to the current show/hide state so we
37
+ * can track it's visibility and not improperly show/hide an element
38
+ * when a widget is saved.
39
+ *
40
+ * Solves the issue where updating one widget could affect another.
41
+ *
42
+ * @since 7.4.5
43
+ *
44
+ * @param el
45
+ */
46
+ set_hide_state: function (el) {
47
+ if (el.is(':visible')) {
48
+ el.data('advanced-sidebar-menu-hide', 0);
49
+ } else {
50
+ el.data('advanced-sidebar-menu-hide', 1);
51
+ }
52
+ },
53
+
54
+ /**
55
+ * Use JS to show/hide widget elements instead of PHP because sometimes widgets are loaded
56
+ * in weird ways like ajax and we don't want any fields hidden if the JS is never loaded
57
+ * to later show them
58
+ *
59
+ * @since 7.4.5
60
+ *
61
+ */
62
+ show_hide_elements: function () {
63
+ jQuery('[data-advanced-sidebar-menu-hide]').each(function () {
64
+ var el = $(this);
65
+ if (el.data('advanced-sidebar-menu-hide')) {
66
+ el.hide();
67
+ } else {
68
+ el.show();
69
+ }
70
+ });
71
+ }
72
+ };
src/Widget/Category.php CHANGED
@@ -242,13 +242,13 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
242
  </p>
243
 
244
  <div class="advanced-sidebar-menu-column">
245
- <?php do_action( 'advanced-sidebar-menu/widget/category/left-column', $instance, $this );
 
246
 
247
  if ( has_action( 'advanced_sidebar_menu_category_widget_form' ) ) {
248
  ?>
249
  <div class="advanced-sidebar-menu-column-box">
250
- <?php
251
- do_action( 'advanced_sidebar_menu_category_widget_form', $instance, $this ); ?>
252
  </div>
253
  <?php
254
  }
@@ -259,7 +259,7 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
259
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
260
  <?php
261
  do_action( 'advanced-sidebar-menu/widget/category/right-column', $instance, $this );
262
- //@deprecated action
263
  do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
264
  ?>
265
  </div>
242
  </p>
243
 
244
  <div class="advanced-sidebar-menu-column">
245
+ <?php
246
+ do_action( 'advanced-sidebar-menu/widget/category/left-column', $instance, $this );
247
 
248
  if ( has_action( 'advanced_sidebar_menu_category_widget_form' ) ) {
249
  ?>
250
  <div class="advanced-sidebar-menu-column-box">
251
+ <?php do_action( 'advanced_sidebar_menu_category_widget_form', $instance, $this ); ?>
 
252
  </div>
253
  <?php
254
  }
259
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
260
  <?php
261
  do_action( 'advanced-sidebar-menu/widget/category/right-column', $instance, $this );
262
+ // @deprecated action.
263
  do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
264
  ?>
265
  </div>