Admin Menu Editor - Version 1.4.5

Version Description

  • Fixed a TypeError: invalid 'in' operand a error that caused compatibility issues with WordPress 4.3.
  • Fixed a bug where the current menu item wouldn't get highlighted if its URL included %-encoded query parameters.
  • Fixed a bug in menu URL generation that could cause problems when moving a plugin menu from "Posts", "Pages" or a CPT to another menu. The URL of the menu item got changed in a way that could break some plugins.
  • Fixed a .htaccess compatiblility issue with with Apache 2.3+.
  • Fixed an incorrect directory name in an error message.
  • The "Links" menu will no longer show up in the editor unless explicitly enabled. As of WP 3.5, the "Links" menu still exists in WordPress core but is inaccessible because the Links Manager is disabled by default.
  • Tested with WordPress 4.3.
Download this release

Release Info

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

Code changes from version 1.4.4 to 1.4.5

css/menu-editor.css CHANGED
@@ -23,7 +23,6 @@
23
width: 100%;
24
margin: 0;
25
padding-top: 2px;
26
- padding-bottom: 2px;
27
}
28
29
.ws_basic_container {
@@ -38,15 +37,24 @@
38
}
39
40
.ws_dropzone {
41
- margin: 0 5px 2px 5px;
42
- border: none;
43
- height: 25px;
44
}
45
46
- .ws_dropzone_hover {
47
- border: 1px dashed silver;
48
- background: yellow;
49
- height: 30px;
50
}
51
52
/*************************************************
@@ -695,10 +703,10 @@ select.ws_dropdown optgroup option {
695
.ws_color_scheme_display {
696
display: inline-block;
697
height: 20px;
698
- width: 190px;
699
700
margin-right: 5px;
701
- padding: 2px 2px 2px 3px;
702
703
border: 1px solid #ddd;
704
background: white;
23
width: 100%;
24
margin: 0;
25
padding-top: 2px;
26
}
27
28
.ws_basic_container {
37
}
38
39
.ws_dropzone {
40
+ display: block;
41
+ box-sizing: border-box;
42
+
43
+ margin: 2px 6px;
44
+ border: 3px none #b4b9be;
45
+
46
+ height: 31px;
47
}
48
49
+ .ws_dropzone_active,
50
+ .ws_dropzone_hover,
51
+ .ws_top_to_submenu_drop_hover .ws_dropzone {
52
+ border-style: dashed;
53
+ }
54
+
55
+ .ws_dropzone_hover,
56
+ .ws_top_to_submenu_drop_hover .ws_dropzone {
57
+ border-width: 1px;
58
}
59
60
/*************************************************
703
.ws_color_scheme_display {
704
display: inline-block;
705
height: 20px;
706
+ width: 186px;
707
708
margin-right: 5px;
709
+ padding: 2px 3px;
710
711
border: 1px solid #ddd;
712
background: white;
css/screen-meta.css CHANGED
@@ -20,6 +20,9 @@
20
#screen-meta-links .custom-screen-meta-link-wrap a.custom-screen-meta-link
21
{
22
padding: 3px 16px 3px 16px;
23
}
24
25
#screen-meta-links a.custom-screen-meta-link::after {
20
#screen-meta-links .custom-screen-meta-link-wrap a.custom-screen-meta-link
21
{
22
padding: 3px 16px 3px 16px;
23
+ text-decoration: none;
24
+ display: block;
25
+ min-height: 22px;
26
}
27
28
#screen-meta-links a.custom-screen-meta-link::after {
includes/.htaccess CHANGED
@@ -1,2 +1,11 @@
1
- Order deny,allow
2
- Deny from all
1
+ # Apache < 2.3
2
+ <IfModule !mod_authz_core.c>
3
+ Order allow,deny
4
+ Deny from all
5
+ Satisfy All
6
+ </IfModule>
7
+
8
+ # Apache >= 2.3
9
+ <IfModule mod_authz_core.c>
10
+ Require all denied
11
+ </IfModule>
includes/admin-menu-editor-mu.php CHANGED
@@ -42,7 +42,7 @@ function ws_ame_installation_error(){
42
<strong>Admin Menu Editor is installed incorrectly!</strong>
43
</p>
44
<p>
45
- Please copy the entire <code>admin-menu-directory</code> directory to your <code>mu-plugins</code>
46
directory, then move only the admin-menu-editor-mu.php file from
47
<code>admin-menu-editor/includes</code> to <code>mu-plugins</code>.
48
</p>
42
<strong>Admin Menu Editor is installed incorrectly!</strong>
43
</p>
44
<p>
45
+ Please copy the entire <code>admin-menu-editor</code> directory to your <code>mu-plugins</code>
46
directory, then move only the admin-menu-editor-mu.php file from
47
<code>admin-menu-editor/includes</code> to <code>mu-plugins</code>.
48
</p>
includes/menu-editor-core.php CHANGED
@@ -287,6 +287,10 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
287
$this->apply_woocommerce_compat_fix();
288
//Compatibility fix for WordPress Mu Domain Mapping.
289
$this->apply_wpmu_domain_mapping_fix();
290
291
//Generate item templates from the default menu.
292
$this->item_templates = $this->build_templates($this->default_wp_menu, $this->default_wp_submenu);
@@ -2499,6 +2503,48 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
2499
}
2500
}
2501
2502
/**
2503
* Get the names of the roles that a user belongs to.
2504
*
287
$this->apply_woocommerce_compat_fix();
288
//Compatibility fix for WordPress Mu Domain Mapping.
289
$this->apply_wpmu_domain_mapping_fix();
290
+ //As of WP 3.5, the "Links" menu is hidden by default.
291
+ if ( !current_user_can('manage_links') ) {
292
+ $this->remove_link_manager_menus();
293
+ }
294
295
//Generate item templates from the default menu.
296
$this->item_templates = $this->build_templates($this->default_wp_menu, $this->default_wp_submenu);
2503
}
2504
}
2505
2506
+ /**
2507
+ * As of WP 3.5, the Links Manager is hidden by default. It's only visible if the user has existing links
2508
+ * or they choose to enable it by installing the Links Manager plugin.
2509
+ *
2510
+ * However, the "Links" menu still exists. This can be confusing to users who will now see an apparently
2511
+ * useless menu item that can't be enabled (since they don't have the Links Manager plugin) and can't be
2512
+ * deleted either (since it's a default menu). To remedy that, hide the default "Links" menu.
2513
+ */
2514
+ private function remove_link_manager_menus() {
2515
+ //Find the "Links" menu.
2516
+ $links_index = null;
2517
+ $links_slug = null;
2518
+ foreach($this->default_wp_menu as $index => $menu) {
2519
+ if ( ($menu[1] === 'manage_links') && isset($menu[5]) && ($menu[5] === 'menu-links') ) {
2520
+ $links_index = $index;
2521
+ $links_slug = $menu[2];
2522
+ }
2523
+ }
2524
+
2525
+ //Remove the default "Links" submenus, but leave custom items created by other plugins.
2526
+ if ( isset($this->default_wp_submenu[$links_slug]) ) {
2527
+ $this->default_wp_submenu[$links_slug] = array_filter(
2528
+ $this->default_wp_submenu[$links_slug],
2529
+ array($this, 'filter_default_links_submenus')
2530
+ );
2531
+ if ( empty($this->default_wp_submenu[$links_slug]) ) {
2532
+ unset($this->default_wp_submenu[$links_slug]);
2533
+ }
2534
+ }
2535
+
2536
+ //Remove the "Links" menu itself if it no longer has any children.
2537
+ if ( !isset($this->default_wp_submenu[$links_slug]) ) {
2538
+ unset($this->default_wp_menu[$links_index]);
2539
+ }
2540
+ }
2541
+
2542
+ private function filter_default_links_submenus($item) {
2543
+ $default_items = array('link-manager.php', 'link-add.php', 'edit-tags.php?taxonomy=link_category');
2544
+ $is_default = isset($item[2]) && in_array($item[2], $default_items);
2545
+ return !$is_default;
2546
+ }
2547
+
2548
/**
2549
* Get the names of the roles that a user belongs to.
2550
*
includes/menu-item.php CHANGED
@@ -457,7 +457,8 @@ abstract class ameMenuItem {
457
}
458
459
if ( self::is_hook_or_plugin_page($menu_url, $parent_url) ) {
460
- $base_file = self::is_wp_admin_file($parent_url) ? $parent_url : 'admin.php';
461
$url = add_query_arg(array('page' => $menu_url), $base_file);
462
} else {
463
$url = $menu_url;
457
}
458
459
if ( self::is_hook_or_plugin_page($menu_url, $parent_url) ) {
460
+ $parent_file = self::remove_query_from($parent_url);
461
+ $base_file = self::is_wp_admin_file($parent_file) ? $parent_url : 'admin.php';
462
$url = add_query_arg(array('page' => $menu_url), $base_file);
463
} else {
464
$url = $menu_url;
js/menu-editor.js CHANGED
@@ -717,7 +717,7 @@ var knownMenuFields = {
717
advanced : true,
718
719
display: function(menuItem, displayValue, input, containerNode) {
720
- var colors = getFieldValue(menuItem, 'colors', {});
721
var colorList = containerNode.find('.ws_color_scheme_display');
722
723
colorList.empty();
@@ -2103,7 +2103,7 @@ $(document).ready(function(){
2103
colorDialogState.containerNode = containerNode;
2104
colorDialogState.menuItem = menuItem;
2105
2106
- var colors = getFieldValue(menuItem, 'colors', {});
2107
var customColorCount = 0;
2108
for (var i = 0; i < menuColorVariables.length; i++) {
2109
var name = menuColorVariables[i];
@@ -2972,6 +2972,7 @@ $(document).ready(function(){
2972
//Allow the user to drag sub-menu items to the top level.
2973
$('#ws_top_menu_dropzone').droppable({
2974
'hoverClass' : 'ws_dropzone_hover',
2975
2976
'accept' : (function(thing){
2977
return thing.hasClass('ws_item');
@@ -2987,8 +2988,8 @@ $(document).ready(function(){
2987
});
2988
2989
//...and to drag top level menus to a sub-menu.
2990
- $('#ws_sub_menu_dropzone').droppable({
2991
- 'hoverClass' : 'ws_dropzone_hover',
2992
2993
'accept' : (function(thing){
2994
var visibleSubmenu = $('#ws_submenu_box').find('.ws_submenu:visible');
717
advanced : true,
718
719
display: function(menuItem, displayValue, input, containerNode) {
720
+ var colors = getFieldValue(menuItem, 'colors', {}) || {};
721
var colorList = containerNode.find('.ws_color_scheme_display');
722
723
colorList.empty();
2103
colorDialogState.containerNode = containerNode;
2104
colorDialogState.menuItem = menuItem;
2105
2106
+ var colors = getFieldValue(menuItem, 'colors', {}) || {};
2107
var customColorCount = 0;
2108
for (var i = 0; i < menuColorVariables.length; i++) {
2109
var name = menuColorVariables[i];
2972
//Allow the user to drag sub-menu items to the top level.
2973
$('#ws_top_menu_dropzone').droppable({
2974
'hoverClass' : 'ws_dropzone_hover',
2975
+ 'activeClass' : 'ws_dropzone_active',
2976
2977
'accept' : (function(thing){
2978
return thing.hasClass('ws_item');
2988
});
2989
2990
//...and to drag top level menus to a sub-menu.
2991
+ $('#ws_submenu_box').closest('.ws_main_container').droppable({
2992
+ 'hoverClass' : 'ws_top_to_submenu_drop_hover',
2993
2994
'accept' : (function(thing){
2995
var visibleSubmenu = $('#ws_submenu_box').find('.ws_submenu:visible');
js/menu-highlight-fix.js CHANGED
@@ -2,6 +2,7 @@ jQuery(function($) {
2
// parseUri 1.2.2
3
// (c) Steven Levithan <stevenlevithan.com>
4
// MIT License
5
6
function parseUri (str) {
7
var o = parseUri.options,
@@ -13,7 +14,14 @@ jQuery(function($) {
13
14
uri[o.q.name] = {};
15
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
16
- if ($1) uri[o.q.name][$1] = $2;
17
});
18
19
return uri;
2
// parseUri 1.2.2
3
// (c) Steven Levithan <stevenlevithan.com>
4
// MIT License
5
+ // Modified: Added partial URL-decoding support.
6
7
function parseUri (str) {
8
var o = parseUri.options,
14
15
uri[o.q.name] = {};
16
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
17
+ if ($1) {
18
+ //Decode percent-encoded query parameters.
19
+ if (o.q.name === 'queryKey') {
20
+ $1 = decodeURIComponent($1);
21
+ $2 = decodeURIComponent($2);
22
+ }
23
+ uri[o.q.name][$1] = $2;
24
+ }
25
});
26
27
return uri;
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.4.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.4.5
7
Author: Janis Elsts
8
Author URI: http://w-shadow.com/blog/
9
*/
readme.txt CHANGED
@@ -3,8 +3,8 @@ 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: 3.8
6
- Tested up to: 4.2
7
- Stable tag: 1.4.4
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,15 @@ Plugins installed in the `mu-plugins` directory are treated as "always on", so y
63
64
== Changelog ==
65
66
= 1.4.4 =
67
* Tested with WordPress 4.2.
68
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: 3.8
6
+ Tested up to: 4.3
7
+ Stable tag: 1.4.5
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.4.5 =
67
+ * Fixed a `TypeError: invalid 'in' operand a` error that caused compatibility issues with WordPress 4.3.
68
+ * Fixed a bug where the current menu item wouldn't get highlighted if its URL included %-encoded query parameters.
69
+ * Fixed a bug in menu URL generation that could cause problems when moving a plugin menu from "Posts", "Pages" or a CPT to another menu. The URL of the menu item got changed in a way that could break some plugins.
70
+ * Fixed a .htaccess compatiblility issue with with Apache 2.3+.
71
+ * Fixed an incorrect directory name in an error message.
72
+ * The "Links" menu will no longer show up in the editor unless explicitly enabled. As of WP 3.5, the "Links" menu still exists in WordPress core but is inaccessible because the Links Manager is disabled by default.
73
+ * Tested with WordPress 4.3.
74
+
75
= 1.4.4 =
76
* Tested with WordPress 4.2.
77