Admin Menu Editor - Version 1.8.5

Version Description

  • Fixed a bug where very long submenus wouldn't be scrollable if the current item was one that was moved to the current submenu from a different top level menu.
  • Fixed an obscure bug where clicking on an item in the current submenu could cause the entire submenu to "jump" up or down.
  • Fixed AME not highlighting the correct menu item when there was a space in any of the query parameter values.
  • Fixed another bug where the plugin didn't highlight the correct item if it was the first item in a submenu and also a custom item.
Download this release

Release Info

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

Code changes from version 1.8.4 to 1.8.5

includes/menu-item.php CHANGED
@@ -26,6 +26,7 @@ abstract class ameMenuItem {
26
  'options-general.php' => true, 'options-media.php' => true, 'options-permalink.php' => true,
27
  'options-reading.php' => true, 'options-writing.php' => true, 'plugin-editor.php' => true,
28
  'plugin-install.php' => true, 'plugins.php' => true, 'post-new.php' => true, 'profile.php' => true,
 
29
  'theme-editor.php' => true, 'themes.php' => true, 'tools.php' => true, 'update-core.php' => true,
30
  'upload.php' => true, 'user-new.php' => true, 'users.php' => true, 'widgets.php' => true,
31
  );
26
  'options-general.php' => true, 'options-media.php' => true, 'options-permalink.php' => true,
27
  'options-reading.php' => true, 'options-writing.php' => true, 'plugin-editor.php' => true,
28
  'plugin-install.php' => true, 'plugins.php' => true, 'post-new.php' => true, 'profile.php' => true,
29
+ 'privacy.php' => true,
30
  'theme-editor.php' => true, 'themes.php' => true, 'tools.php' => true, 'update-core.php' => true,
31
  'upload.php' => true, 'user-new.php' => true, 'users.php' => true, 'widgets.php' => true,
32
  );
js/menu-highlight-fix.js CHANGED
@@ -17,6 +17,10 @@ jQuery(function($) {
17
  if ($1) {
18
  //Decode percent-encoded query parameters.
19
  if (o.q.name === 'queryKey') {
 
 
 
 
20
  $1 = decodeURIComponent($1);
21
  $2 = decodeURIComponent($2);
22
  }
@@ -73,7 +77,7 @@ jQuery(function($) {
73
 
74
  //Skip links that have no href or contain nothing but an "#anchor". Both AME and some
75
  //other plugins (e.g. S2Member 120703) use them as separators.
76
- if ( !$link.is('[href]') || ($link.attr('href').substring(0, 1) == '#') ) {
77
  return;
78
  }
79
 
@@ -91,7 +95,7 @@ jQuery(function($) {
91
  var components = ['protocol', 'host', 'port', 'user', 'password', 'path'];
92
  var isCloseMatch = true;
93
  for (var i = 0; (i < components.length) && isCloseMatch; i++) {
94
- isCloseMatch = isCloseMatch && (uri[components[i]] == currentUri[components[i]]);
95
  }
96
 
97
  if (!isCloseMatch) {
@@ -104,7 +108,7 @@ jQuery(function($) {
104
  if (uri.queryKey.hasOwnProperty(param)) {
105
  if (currentUri.queryKey.hasOwnProperty(param)) {
106
  //All parameters that are present in *both* URLs must have the same exact values.
107
- if (uri.queryKey[param] == currentUri.queryKey[param]) {
108
  matchingParams++;
109
  } else {
110
  return; //Skip to the next link.
@@ -120,7 +124,7 @@ jQuery(function($) {
120
  }
121
  }
122
 
123
- var isAnchorMatch = uri.anchor == currentUri.anchor;
124
  var isTopMenu = $link.hasClass('menu-top');
125
  var isHighlighted = $link.is('.current, .wp-has-current-submenu');
126
 
@@ -129,29 +133,32 @@ jQuery(function($) {
129
  var comparisons = [
130
  {
131
  better : (matchingParams > bestMatch.matchingParams),
132
- equal : (matchingParams == bestMatch.matchingParams)
133
  },
134
  {
135
  better : (differentParams < bestMatch.differentParams),
136
- equal : (differentParams == bestMatch.differentParams)
137
  },
138
  {
139
  better : (isAnchorMatch && (!bestMatch.isAnchorMatch)),
140
- equal : (isAnchorMatch == bestMatch.isAnchorMatch)
 
 
 
 
 
 
 
 
 
 
141
  },
142
 
143
  //All else being equal, the item highlighted by WP is probably a better match.
144
  {
145
  better : (isHighlighted && !bestMatch.isHighlighted),
146
- equal : (isHighlighted == bestMatch.isHighlighted)
147
- },
148
-
149
- //When a menu has multiple submenus, the first submenu usually has the same URL
150
- //as the parent menu. We want to highlight this item and not just the parent.
151
- {
152
- better : (!isTopMenu && bestMatch.isTopMenu),
153
- equal : (isTopMenu == bestMatch.isTopMenu)
154
- }
155
  ];
156
 
157
  var isBetterMatch = false,
@@ -213,6 +220,18 @@ jQuery(function($) {
213
  //that's not scrollable (due to being stuck with `position: fixed`).
214
  if ((typeof window['stickyMenu'] === 'object') && (typeof window['stickyMenu']['update'] === 'function')) {
215
  window.stickyMenu.update();
 
 
 
 
 
 
 
 
 
 
 
 
216
  }
217
  }
218
 
17
  if ($1) {
18
  //Decode percent-encoded query parameters.
19
  if (o.q.name === 'queryKey') {
20
+ //A space can be encoded either as "%20" or "+". decodeUriComponent doesn't decode plus signs,
21
+ //so we need to do that first.
22
+ $2 = $2.replace('+', ' ');
23
+
24
  $1 = decodeURIComponent($1);
25
  $2 = decodeURIComponent($2);
26
  }
77
 
78
  //Skip links that have no href or contain nothing but an "#anchor". Both AME and some
79
  //other plugins (e.g. S2Member 120703) use them as separators.
80
+ if ( !$link.is('[href]') || ($link.attr('href').substring(0, 1) === '#') ) {
81
  return;
82
  }
83
 
95
  var components = ['protocol', 'host', 'port', 'user', 'password', 'path'];
96
  var isCloseMatch = true;
97
  for (var i = 0; (i < components.length) && isCloseMatch; i++) {
98
+ isCloseMatch = isCloseMatch && (uri[components[i]] === currentUri[components[i]]);
99
  }
100
 
101
  if (!isCloseMatch) {
108
  if (uri.queryKey.hasOwnProperty(param)) {
109
  if (currentUri.queryKey.hasOwnProperty(param)) {
110
  //All parameters that are present in *both* URLs must have the same exact values.
111
+ if (uri.queryKey[param] === currentUri.queryKey[param]) {
112
  matchingParams++;
113
  } else {
114
  return; //Skip to the next link.
124
  }
125
  }
126
 
127
+ var isAnchorMatch = uri.anchor === currentUri.anchor;
128
  var isTopMenu = $link.hasClass('menu-top');
129
  var isHighlighted = $link.is('.current, .wp-has-current-submenu');
130
 
133
  var comparisons = [
134
  {
135
  better : (matchingParams > bestMatch.matchingParams),
136
+ equal : (matchingParams === bestMatch.matchingParams)
137
  },
138
  {
139
  better : (differentParams < bestMatch.differentParams),
140
+ equal : (differentParams === bestMatch.differentParams)
141
  },
142
  {
143
  better : (isAnchorMatch && (!bestMatch.isAnchorMatch)),
144
+ equal : (isAnchorMatch === bestMatch.isAnchorMatch)
145
+ },
146
+
147
+ //When a menu has multiple submenus, the first submenu usually has the same URL
148
+ //as the parent menu. We want to highlight this item and not just the parent.
149
+ {
150
+ better : (!isTopMenu && bestMatch.isTopMenu
151
+ //Is this link a child of the current best match?
152
+ && (!bestMatch.link || ($link.closest(bestMatch.link.closest('li')).length > 0))
153
+ ),
154
+ equal : (isTopMenu === bestMatch.isTopMenu)
155
  },
156
 
157
  //All else being equal, the item highlighted by WP is probably a better match.
158
  {
159
  better : (isHighlighted && !bestMatch.isHighlighted),
160
+ equal : (isHighlighted === bestMatch.isHighlighted)
161
+ }
 
 
 
 
 
 
 
162
  ];
163
 
164
  var isBetterMatch = false,
220
  //that's not scrollable (due to being stuck with `position: fixed`).
221
  if ((typeof window['stickyMenu'] === 'object') && (typeof window['stickyMenu']['update'] === 'function')) {
222
  window.stickyMenu.update();
223
+ } else {
224
+ //As of WP core revision 29599 (2014-10-05) the `stickyMenu` object no longer exists
225
+ //and the replacement (`setPinMenu` in common.js) is not accessible from an outside scope.
226
+ //We'll resort to faking a resize event to make WP update the menu height and state.
227
+ $(document).trigger('wp-window-resized');
228
+ }
229
+
230
+ //Workaround: Prevent the current submenu from "jumping around" when you click an item. This glitch is
231
+ //caused by a `focusin` event handler in common.js. WP adds this handler to all top level menus that
232
+ //are not the current menu. Since we're changing the current menu, we need to also remove this handler.
233
+ if (typeof parentMenu['off'] === 'function') {
234
+ parentMenu.off('focusin.adminmenu');
235
  }
236
  }
237
 
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.8.4
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/blog/
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.8.5
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/blog/
9
  */
modules/highlight-new-menus/wsNewMenuHighlighter.php CHANGED
@@ -36,6 +36,7 @@ class wsNewMenuHighlighter {
36
  'plugins.php' => true,
37
  'post-new.php' => true,
38
  'profile.php' => true,
 
39
  'theme-editor.php' => true,
40
  'themes.php' => true,
41
  'tools.php' => true,
36
  'plugins.php' => true,
37
  'post-new.php' => true,
38
  'profile.php' => true,
39
+ 'privacy.php' => true,
40
  'theme-editor.php' => true,
41
  'themes.php' => true,
42
  'tools.php' => true,
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: whiteshadow
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A6P9S6CE3SRSW
4
  Tags: admin, dashboard, menu, security, wpmu
5
  Requires at least: 4.1
6
- Tested up to: 4.9.6
7
  Stable tag: 1.8.4
8
 
9
  Lets you edit the WordPress admin menu. You can re-order, hide or rename menus, add custom menus and more.
@@ -63,6 +63,12 @@ Plugins installed in the `mu-plugins` directory are treated as "always on", so y
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
 
66
  = 1.8.4 =
67
  * Added a "Documentation" link below the plugin description. For people concerned about the recent GDPR legislation, the documentation now includes a page explaining [how the plugin processes personal data](https://adminmenueditor.com/free-version-docs/about-data-processing-free-version/). Short version: It usually doesn't.
68
  * Tested with WP 4.9.6.
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A6P9S6CE3SRSW
4
  Tags: admin, dashboard, menu, security, wpmu
5
  Requires at least: 4.1
6
+ Tested up to: 4.9
7
  Stable tag: 1.8.4
8
 
9
  Lets you edit the WordPress admin menu. You can re-order, hide or rename menus, add custom menus and more.
63
 
64
  == Changelog ==
65
 
66
+ = 1.8.5 =
67
+ * Fixed a bug where very long submenus wouldn't be scrollable if the current item was one that was moved to the current submenu from a different top level menu.
68
+ * Fixed an obscure bug where clicking on an item in the current submenu could cause the entire submenu to "jump" up or down.
69
+ * Fixed AME not highlighting the correct menu item when there was a space in any of the query parameter values.
70
+ * Fixed another bug where the plugin didn't highlight the correct item if it was the first item in a submenu and also a custom item.
71
+
72
  = 1.8.4 =
73
  * Added a "Documentation" link below the plugin description. For people concerned about the recent GDPR legislation, the documentation now includes a page explaining [how the plugin processes personal data](https://adminmenueditor.com/free-version-docs/about-data-processing-free-version/). Short version: It usually doesn't.
74
  * Tested with WP 4.9.6.