Version Description
- Fix: Revert "Refactor: Improve method to determine the depth of a menu item", causing infinite loop on some installations
Download this release
Release Info
Developer | megamenu |
Plugin | Max Mega Menu |
Version | 2.7.6 |
Comparing to | |
See all releases |
Code changes from version 2.7.5 to 2.7.6
- classes/menu-item-manager.class.php +4 -36
- js/admin.js +1 -1
- megamenu.php +21 -29
- readme.txt +4 -0
classes/menu-item-manager.class.php
CHANGED
@@ -48,15 +48,15 @@ class Mega_Menu_Menu_Item_Manager {
|
|
48 |
$this->menu_id = $this->get_menu_id_for_menu_item_id( $this->menu_item_id );
|
49 |
$this->menu_item_objects = wp_get_nav_menu_items( $this->menu_id );
|
50 |
$this->menu_item_title = $this->get_title_for_menu_item_id( $this->menu_item_id, $this->menu_item_objects );
|
51 |
-
|
|
|
|
|
|
|
52 |
|
53 |
$saved_settings = array_filter( (array) get_post_meta( $this->menu_item_id, '_megamenu', true ) );
|
54 |
$this->menu_item_meta = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $saved_settings );
|
55 |
}
|
56 |
|
57 |
-
//if ( isset( $_POST['menu_item_depth'] ) ) {
|
58 |
-
// $this->menu_item_depth = absint( $_POST['menu_item_depth'] );
|
59 |
-
//}
|
60 |
|
61 |
//if ( isset( $_POST['menu_id'] ) ) {
|
62 |
// $this->menu_id = absint( $_POST['menu_id'] );
|
@@ -158,38 +158,6 @@ class Mega_Menu_Menu_Item_Manager {
|
|
158 |
}
|
159 |
|
160 |
|
161 |
-
/**
|
162 |
-
* Returns the depth of a given menu item ID
|
163 |
-
*
|
164 |
-
* @since 2.7.5
|
165 |
-
* @param int $menu_item_id
|
166 |
-
* @param array $menu_item_objects
|
167 |
-
* @return int $menu_id
|
168 |
-
*/
|
169 |
-
public function get_depth_for_menu_item_id( $menu_item_id, $menu_item_objects ) {
|
170 |
-
$level = 0;
|
171 |
-
$stack = array('0');
|
172 |
-
|
173 |
-
foreach( $menu_item_objects as $key => $item ) {
|
174 |
-
|
175 |
-
while( $item->menu_item_parent != array_pop( $stack ) ) {
|
176 |
-
$level--;
|
177 |
-
}
|
178 |
-
|
179 |
-
$level++;
|
180 |
-
$stack[] = $item->menu_item_parent;
|
181 |
-
$stack[] = $item->ID;
|
182 |
-
|
183 |
-
if ( $item->ID == $menu_item_id ) {
|
184 |
-
return $level - 1;
|
185 |
-
}
|
186 |
-
//$menu[$key]->depth = $level - 1;
|
187 |
-
}
|
188 |
-
|
189 |
-
return false;
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
/**
|
194 |
* Returns the title of a given menu item ID
|
195 |
*
|
48 |
$this->menu_id = $this->get_menu_id_for_menu_item_id( $this->menu_item_id );
|
49 |
$this->menu_item_objects = wp_get_nav_menu_items( $this->menu_id );
|
50 |
$this->menu_item_title = $this->get_title_for_menu_item_id( $this->menu_item_id, $this->menu_item_objects );
|
51 |
+
|
52 |
+
if ( isset( $_POST['menu_item_depth'] ) ) {
|
53 |
+
$this->menu_item_depth = absint( $_POST['menu_item_depth'] );
|
54 |
+
}
|
55 |
|
56 |
$saved_settings = array_filter( (array) get_post_meta( $this->menu_item_id, '_megamenu', true ) );
|
57 |
$this->menu_item_meta = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $saved_settings );
|
58 |
}
|
59 |
|
|
|
|
|
|
|
60 |
|
61 |
//if ( isset( $_POST['menu_id'] ) ) {
|
62 |
// $this->menu_id = absint( $_POST['menu_id'] );
|
158 |
}
|
159 |
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
/**
|
162 |
* Returns the title of a given menu item ID
|
163 |
*
|
js/admin.js
CHANGED
@@ -1210,7 +1210,7 @@ jQuery(function($) {
|
|
1210 |
$(this).megaMenu({
|
1211 |
menu_item_id: id,
|
1212 |
menu_item_title: 0, // title, // 2.7.5: detect using PHP
|
1213 |
-
menu_item_depth:
|
1214 |
menu_id: 0 ///menu_id // 2.7.5: detect using PHP
|
1215 |
});
|
1216 |
});
|
1210 |
$(this).megaMenu({
|
1211 |
menu_item_id: id,
|
1212 |
menu_item_title: 0, // title, // 2.7.5: detect using PHP
|
1213 |
+
menu_item_depth: depth,
|
1214 |
menu_id: 0 ///menu_id // 2.7.5: detect using PHP
|
1215 |
});
|
1216 |
});
|
megamenu.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Max Mega Menu
|
5 |
* Plugin URI: https://www.megamenu.com
|
6 |
* Description: An easy to use mega menu plugin. Written the WordPress way.
|
7 |
-
* Version: 2.7.
|
8 |
* Author: megamenu.com
|
9 |
* Author URI: https://www.megamenu.com
|
10 |
* License: GPL-2.0+
|
@@ -36,7 +36,7 @@ final class Mega_Menu {
|
|
36 |
/**
|
37 |
* @var string
|
38 |
*/
|
39 |
-
public $version = '2.7.
|
40 |
|
41 |
|
42 |
/**
|
@@ -78,7 +78,6 @@ final class Mega_Menu {
|
|
78 |
add_filter( 'wp_nav_menu', array( $this, 'add_responsive_toggle' ), 10, 2 );
|
79 |
|
80 |
add_filter( 'wp_nav_menu_objects', array( $this, 'add_widgets_to_menu' ), apply_filters("megamenu_wp_nav_menu_objects_priority", 10), 2 );
|
81 |
-
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'apply_depth_to_menu_items' ), 5, 2 );
|
82 |
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'setup_menu_items' ), 5, 2 );
|
83 |
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'reorder_menu_items_within_megamenus' ), 6, 2 );
|
84 |
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'apply_classes_to_menu_items' ), 7, 2 );
|
@@ -759,44 +758,37 @@ final class Mega_Menu {
|
|
759 |
return $rolling_last_menu_order + 1000;
|
760 |
|
761 |
}
|
762 |
-
|
763 |
|
764 |
/**
|
765 |
-
*
|
766 |
*
|
767 |
-
* @since 2.
|
768 |
* @param array $items - All menu item objects
|
769 |
* @param object $args
|
770 |
* @return array
|
771 |
*/
|
772 |
-
public function
|
773 |
-
$level = 0;
|
774 |
-
$stack = array('0');
|
775 |
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
}
|
780 |
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
|
|
785 |
}
|
786 |
|
787 |
-
|
788 |
-
|
789 |
-
|
|
|
|
|
|
|
|
|
790 |
|
791 |
-
/**
|
792 |
-
* Setup the mega menu settings for each menu item
|
793 |
-
*
|
794 |
-
* @since 2.0
|
795 |
-
* @param array $items - All menu item objects
|
796 |
-
* @param object $args
|
797 |
-
* @return array
|
798 |
-
*/
|
799 |
-
public function setup_menu_items( $items, $args ) {
|
800 |
// apply saved metadata to each menu item
|
801 |
foreach ( $items as $item ) {
|
802 |
$saved_settings = array_filter( (array) get_post_meta( $item->ID, '_megamenu', true ) );
|
4 |
* Plugin Name: Max Mega Menu
|
5 |
* Plugin URI: https://www.megamenu.com
|
6 |
* Description: An easy to use mega menu plugin. Written the WordPress way.
|
7 |
+
* Version: 2.7.6
|
8 |
* Author: megamenu.com
|
9 |
* Author URI: https://www.megamenu.com
|
10 |
* License: GPL-2.0+
|
36 |
/**
|
37 |
* @var string
|
38 |
*/
|
39 |
+
public $version = '2.7.6';
|
40 |
|
41 |
|
42 |
/**
|
78 |
add_filter( 'wp_nav_menu', array( $this, 'add_responsive_toggle' ), 10, 2 );
|
79 |
|
80 |
add_filter( 'wp_nav_menu_objects', array( $this, 'add_widgets_to_menu' ), apply_filters("megamenu_wp_nav_menu_objects_priority", 10), 2 );
|
|
|
81 |
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'setup_menu_items' ), 5, 2 );
|
82 |
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'reorder_menu_items_within_megamenus' ), 6, 2 );
|
83 |
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'apply_classes_to_menu_items' ), 7, 2 );
|
758 |
return $rolling_last_menu_order + 1000;
|
759 |
|
760 |
}
|
761 |
+
|
762 |
|
763 |
/**
|
764 |
+
* Setup the mega menu settings for each menu item
|
765 |
*
|
766 |
+
* @since 2.0
|
767 |
* @param array $items - All menu item objects
|
768 |
* @param object $args
|
769 |
* @return array
|
770 |
*/
|
771 |
+
public function setup_menu_items( $items, $args ) {
|
|
|
|
|
772 |
|
773 |
+
// apply depth
|
774 |
+
// @todo work out a better way to do this. Suggestions welcome..!
|
775 |
+
$parents = array();
|
|
|
776 |
|
777 |
+
foreach ( $items as $key => $item ) {
|
778 |
+
if ( $item->menu_item_parent == 0 ) {
|
779 |
+
$parents[] = $item->ID;
|
780 |
+
$item->depth = 0;
|
781 |
+
}
|
782 |
}
|
783 |
|
784 |
+
if ( count( $parents ) ) {
|
785 |
+
foreach ( $items as $key => $item ) {
|
786 |
+
if ( in_array( $item->menu_item_parent, $parents ) ) {
|
787 |
+
$item->depth = 1;
|
788 |
+
}
|
789 |
+
}
|
790 |
+
}
|
791 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
792 |
// apply saved metadata to each menu item
|
793 |
foreach ( $items as $item ) {
|
794 |
$saved_settings = array_filter( (array) get_post_meta( $item->ID, '_megamenu', true ) );
|
readme.txt
CHANGED
@@ -133,6 +133,10 @@ See https://www.megamenu.com for more screenshots
|
|
133 |
|
134 |
== Changelog ==
|
135 |
|
|
|
|
|
|
|
|
|
136 |
= 2.7.5 =
|
137 |
|
138 |
* Improvement: Add megamenu_javascript_handle filter
|
133 |
|
134 |
== Changelog ==
|
135 |
|
136 |
+
= 2.7.6 =
|
137 |
+
|
138 |
+
* Fix: Revert "Refactor: Improve method to determine the depth of a menu item", causing infinite loop on some installations
|
139 |
+
|
140 |
= 2.7.5 =
|
141 |
|
142 |
* Improvement: Add megamenu_javascript_handle filter
|