Admin Menu Editor - Version 1.1.12

Version Description

  • Fixed several more small CPT-related bugs that would cause the wrong menu to be marked as current.
  • Tested on WP 3.5-beta2.
Download this release

Release Info

Developer whiteshadow
Plugin Icon 128x128 Admin Menu Editor
Version 1.1.12
Comparing to
See all releases

Code changes from version 1.1.11 to 1.1.12

includes/menu-editor-core.php CHANGED
@@ -1078,7 +1078,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
1078
  $variation_index = hexdec( substr(md5(get_site_url()), -1) ) % count($benefit_variations);
1079
  $selected_variation = $benefit_variations[$variation_index];
1080
 
1081
- $pro_version_link = 'http://w-shadow.com/admin-menu-editor-pro/upgrade-to-pro/?utm_source=Admin%2BMenu%2BEditor%2Bfree&utm_medium=text_link&utm_content=sidebar_link_bv' . $variation_index . '&utm_campaign=Plugins';
1082
  ?>
1083
  <div class="clear"></div>
1084
 
@@ -1089,7 +1089,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
1089
  <ul>
1090
  <li><?php echo $selected_variation; ?></li>
1091
  <li>Drag items between menu levels.</li>
1092
- <li>Menu export & import.</li>
1093
  </ul>
1094
  <a href="<?php echo esc_attr($pro_version_link); ?>" target="_blank">Learn more</a>
1095
  </div>
@@ -1282,7 +1282,7 @@ window.wsMenuEditorPro = false; //Will be overwritten if extras are loaded
1282
  (function($){
1283
  $('#screen-meta-links').append(
1284
  '<div id="ws-pro-version-notice">' +
1285
- '<a href="http://w-shadow.com/admin-menu-editor-pro/?utm_source=Admin%2BMenu%2BEditor%2Bfree&utm_medium=text_link&utm_content=top_upgrade_link&utm_campaign=Plugins" id="ws-pro-version-notice-link" class="show-settings" target="_blank" title="View Pro version details">Upgrade to Pro</a>' +
1286
  '</div>'
1287
  );
1288
  })(jQuery);
1078
  $variation_index = hexdec( substr(md5(get_site_url()), -1) ) % count($benefit_variations);
1079
  $selected_variation = $benefit_variations[$variation_index];
1080
 
1081
+ $pro_version_link = 'http://adminmenueditor.com/upgrade-to-pro/?utm_source=Admin%2BMenu%2BEditor%2Bfree&utm_medium=text_link&utm_content=sidebar_link_bv' . $variation_index . '&utm_campaign=Plugins';
1082
  ?>
1083
  <div class="clear"></div>
1084
 
1089
  <ul>
1090
  <li><?php echo $selected_variation; ?></li>
1091
  <li>Drag items between menu levels.</li>
1092
+ <li>Menu export &amp; import.</li>
1093
  </ul>
1094
  <a href="<?php echo esc_attr($pro_version_link); ?>" target="_blank">Learn more</a>
1095
  </div>
1282
  (function($){
1283
  $('#screen-meta-links').append(
1284
  '<div id="ws-pro-version-notice">' +
1285
+ '<a href="http://adminmenueditor.com/?utm_source=Admin%2BMenu%2BEditor%2Bfree&utm_medium=text_link&utm_content=top_upgrade_link&utm_campaign=Plugins" id="ws-pro-version-notice-link" class="show-settings" target="_blank" title="View Pro version details">Upgrade to Pro</a>' +
1286
  '</div>'
1287
  );
1288
  })(jQuery);
js/menu-highlight-fix.js CHANGED
@@ -42,7 +42,8 @@ jQuery(function($) {
42
  matchingParams : -1,
43
  differentParams : 10000,
44
  isAnchorMatch : false,
45
- isTopMenu : false
 
46
  };
47
 
48
  //Special case: ".../wp-admin/" should match ".../wp-admin/index.php".
@@ -51,7 +52,6 @@ jQuery(function($) {
51
  }
52
 
53
  var adminMenu = $('#adminmenu');
54
-
55
  adminMenu.find('li > a').each(function(index, link) {
56
  var $link = $(link);
57
 
@@ -68,6 +68,7 @@ jQuery(function($) {
68
  for (var i = 0; (i < components.length) && isCloseMatch; i++) {
69
  isCloseMatch = isCloseMatch && (uri[components[i]] == currentUri[components[i]]);
70
  }
 
71
 
72
  if (!isCloseMatch) {
73
  return; //Skip to the next link.
@@ -77,8 +78,13 @@ jQuery(function($) {
77
  var matchingParams = 0, differentParams = 0, param;
78
  for(param in uri.queryKey) {
79
  if (uri.queryKey.hasOwnProperty(param)) {
80
- if (currentUri.queryKey.hasOwnProperty(param) && (uri.queryKey[param] == currentUri.queryKey[param])) {
81
- matchingParams++;
 
 
 
 
 
82
  } else {
83
  differentParams++;
84
  }
@@ -92,6 +98,7 @@ jQuery(function($) {
92
 
93
  var isAnchorMatch = uri.anchor == currentUri.anchor;
94
  var isTopMenu = $link.hasClass('menu-top');
 
95
 
96
  //Figure out if the current link is better than the best found so far.
97
  //To do that, we compare them by several criteria (in order of priority):
@@ -108,6 +115,15 @@ jQuery(function($) {
108
  better : (isAnchorMatch && (!bestMatch.isAnchorMatch)),
109
  equal : (isAnchorMatch == bestMatch.isAnchorMatch)
110
  },
 
 
 
 
 
 
 
 
 
111
  {
112
  better : (!isTopMenu && bestMatch.isTopMenu),
113
  equal : (isTopMenu == bestMatch.isTopMenu)
@@ -124,14 +140,15 @@ jQuery(function($) {
124
  j++;
125
  }
126
 
127
- if (isBetterMatch || isEquallyGood) {
128
  bestMatch = {
129
  uri : uri,
130
  link : $link,
131
  matchingParams : matchingParams,
132
  differentParams : differentParams,
133
  isAnchorMatch : isAnchorMatch,
134
- isTopMenu : isTopMenu
 
135
  }
136
  }
137
  });
@@ -170,4 +187,14 @@ jQuery(function($) {
170
  bestMatchLink.addClass('current').closest('li').addClass('current');
171
  }
172
  }
 
 
 
 
 
 
 
 
 
 
173
  });
42
  matchingParams : -1,
43
  differentParams : 10000,
44
  isAnchorMatch : false,
45
+ isTopMenu : false,
46
+ isHighlighted: false
47
  };
48
 
49
  //Special case: ".../wp-admin/" should match ".../wp-admin/index.php".
52
  }
53
 
54
  var adminMenu = $('#adminmenu');
 
55
  adminMenu.find('li > a').each(function(index, link) {
56
  var $link = $(link);
57
 
68
  for (var i = 0; (i < components.length) && isCloseMatch; i++) {
69
  isCloseMatch = isCloseMatch && (uri[components[i]] == currentUri[components[i]]);
70
  }
71
+ //TODO: Consider using get_current_screen and the current_screen filter to get post types and taxonomies.
72
 
73
  if (!isCloseMatch) {
74
  return; //Skip to the next link.
78
  var matchingParams = 0, differentParams = 0, param;
79
  for(param in uri.queryKey) {
80
  if (uri.queryKey.hasOwnProperty(param)) {
81
+ if (currentUri.queryKey.hasOwnProperty(param)) {
82
+ //All parameters that are present in *both* URLs must have the same exact values.
83
+ if (uri.queryKey[param] == currentUri.queryKey[param]) {
84
+ matchingParams++;
85
+ } else {
86
+ return; //Skip to the next link.
87
+ }
88
  } else {
89
  differentParams++;
90
  }
98
 
99
  var isAnchorMatch = uri.anchor == currentUri.anchor;
100
  var isTopMenu = $link.hasClass('menu-top');
101
+ var isHighlighted = $link.is('.current, .wp-has-current-submenu');
102
 
103
  //Figure out if the current link is better than the best found so far.
104
  //To do that, we compare them by several criteria (in order of priority):
115
  better : (isAnchorMatch && (!bestMatch.isAnchorMatch)),
116
  equal : (isAnchorMatch == bestMatch.isAnchorMatch)
117
  },
118
+
119
+ //All else being equal, the item highlighted by WP is probably a better match.
120
+ {
121
+ better : (isHighlighted && !bestMatch.isHighlighted),
122
+ equal : (isHighlighted == bestMatch.isHighlighted)
123
+ },
124
+
125
+ //When a menu has multiple submenus, the first submenu usually has the same URL
126
+ //as the parent menu. We want to highlight this item and not just the parent.
127
  {
128
  better : (!isTopMenu && bestMatch.isTopMenu),
129
  equal : (isTopMenu == bestMatch.isTopMenu)
140
  j++;
141
  }
142
 
143
+ if (isBetterMatch) {
144
  bestMatch = {
145
  uri : uri,
146
  link : $link,
147
  matchingParams : matchingParams,
148
  differentParams : differentParams,
149
  isAnchorMatch : isAnchorMatch,
150
+ isTopMenu : isTopMenu,
151
+ isHighlighted: isHighlighted
152
  }
153
  }
154
  });
187
  bestMatchLink.addClass('current').closest('li').addClass('current');
188
  }
189
  }
190
+
191
+ //If a submenu is highlighted, so must be its parent.
192
+ //In some cases, if we decide to stick with the WP-selected highlighted menu,
193
+ //this might not be the case and we'll need to fix it.
194
+ var parentOfHighlightedMenu = $('.wp-submenu a.current', '#adminmenu').closest('.menu-top');
195
+ parentOfHighlightedMenu
196
+ .add('> a.menu-top', parentOfHighlightedMenu)
197
+ .removeClass('wp-not-current-submenu')
198
+ .addClass('wp-has-current-submenu wp-menu-open');
199
+
200
  });
menu-editor.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Admin Menu Editor
4
  Plugin URI: http://w-shadow.com/blog/2008/12/20/admin-menu-editor-for-wordpress/
5
  Description: Lets you directly edit the WordPress admin menu. You can re-order, hide or rename existing menus, add custom menus and more.
6
- Version: 1.1.11
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/
9
  */
3
  Plugin Name: Admin Menu Editor
4
  Plugin URI: http://w-shadow.com/blog/2008/12/20/admin-menu-editor-for-wordpress/
5
  Description: Lets you directly edit the WordPress admin menu. You can re-order, hide or rename existing menus, add custom menus and more.
6
+ Version: 1.1.12
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/
9
  */
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: admin, dashboard, menu, security, wpmu
5
  Requires at least: 3.2
6
  Tested up to: 3.4.2
7
- Stable tag: 1.1.11
8
 
9
  Lets you edit the WordPress admin menu. You can re-order, hide or rename menus, add custom menus and more.
10
 
@@ -63,6 +63,10 @@ Plugins installed in the `mu-plugins` directory are treated as "always on", so y
63
 
64
  == Changelog ==
65
 
 
 
 
 
66
  = 1.1.11 =
67
  * Tested on WP 3.4.2 and WP 3.5-alpha-21879.
68
  * Fixed a visual glitch related to the arrow that's used to expand menu settings. In certain situations clicking it would cause the arrow icon to be briefly replaced with multiple copies of the same icon.
4
  Tags: admin, dashboard, menu, security, wpmu
5
  Requires at least: 3.2
6
  Tested up to: 3.4.2
7
+ Stable tag: 1.1.12
8
 
9
  Lets you edit the WordPress admin menu. You can re-order, hide or rename menus, add custom menus and more.
10
 
63
 
64
  == Changelog ==
65
 
66
+ = 1.1.12 =
67
+ * Fixed several more small CPT-related bugs that would cause the wrong menu to be marked as current.
68
+ * Tested on WP 3.5-beta2.
69
+
70
  = 1.1.11 =
71
  * Tested on WP 3.4.2 and WP 3.5-alpha-21879.
72
  * Fixed a visual glitch related to the arrow that's used to expand menu settings. In certain situations clicking it would cause the arrow icon to be briefly replaced with multiple copies of the same icon.