Admin Menu Editor - Version 1.1.7

Version Description

  • Tested on WP 3.4
  • Fixed a rare "failed to decode input" error.
  • Fixed menus not being expanded/collapsed properly when the current menu item has been moved to a different sub-menu.
  • Added a shortlist of Pro version benefits to the editor page (can be hidden).
Download this release

Release Info

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

Code changes from version 1.1.6.1 to 1.1.7

css/menu-editor.css CHANGED
@@ -548,6 +548,72 @@ a.ws_button:hover {
548
  padding-top: 25px;
549
  }
550
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
  /************************************
552
  Screen meta buttons
553
  *************************************/
548
  padding-top: 25px;
549
  }
550
 
551
+ /************************************
552
+ Tooltips and hints
553
+ *************************************/
554
+
555
+ .ws_tooltip_trigger {
556
+ cursor: pointer;
557
+ }
558
+
559
+ .ws_tooltip_content_list {
560
+ list-style: disc;
561
+ margin-left: 1em;
562
+ }
563
+
564
+ .ws_hint {
565
+ background: #FFFFE0;
566
+ border: 1px solid #E6DB55;
567
+
568
+ margin-bottom: 0.5em;
569
+ border-radius: 3px;
570
+ position: relative;
571
+ padding-right: 20px;
572
+ }
573
+
574
+ .ws_hint_close {
575
+ border: 1px solid #E6DB55;
576
+ border-right: none;
577
+ border-top: none;
578
+ color: #dcc500;
579
+ font-weight: bold;
580
+ cursor: pointer;
581
+
582
+ width: 18px;
583
+ text-align: center;
584
+ border-radius: 3px;
585
+
586
+ position: absolute;
587
+ right: 0px;
588
+ top: 0px;
589
+ }
590
+
591
+ .ws_hint_close:hover {
592
+ background-color: #ffef4c;
593
+ border-color: #e0b900;
594
+ color: black;
595
+ }
596
+
597
+ .ws_hint_content {
598
+ padding: 0.4em 0 0.4em 0.4em;
599
+ }
600
+
601
+ .ws_hint_content ul {
602
+ list-style: disc;
603
+ list-style-position: inside;
604
+ margin-left: 0.5em;
605
+ }
606
+
607
+ #ws_sidebar_pro_ad {
608
+ margin-top: 5px;
609
+ margin-left: 3px;
610
+
611
+ position: fixed;
612
+ right: 20px;
613
+ bottom: 40px;
614
+ z-index: 100;
615
+ }
616
+
617
  /************************************
618
  Screen meta buttons
619
  *************************************/
includes/menu-editor-core.php CHANGED
@@ -27,6 +27,10 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
27
 
28
  private $templates = null; //Template arrays for various menu structures. See the constructor for details.
29
 
 
 
 
 
30
  function init(){
31
  //Determine if the plugin is active network-wide (i.e. either installed in
32
  //the /mu-plugins/ directory or activated "network wide" by the super admin.
@@ -41,7 +45,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
41
  $this->defaults = array(
42
  'hide_advanced_settings' => true,
43
  'menu_format_version' => 0,
44
- 'display_survey_notice' => true,
45
  );
46
  $this->serialize_with_json = false; //(Don't) store the options in JSON format
47
 
@@ -94,7 +98,17 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
94
  );
95
 
96
  //AJAXify screen options
97
- add_action( 'wp_ajax_ws_ame_save_screen_options', array(&$this,'ajax_save_screen_options') );
 
 
 
 
 
 
 
 
 
 
98
  }
99
 
100
  /**
@@ -148,6 +162,16 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
148
  array('jquery', 'jquery-ui-sortable', 'jquery-ui-dialog', 'jquery-form'),
149
  '1.1'
150
  );
 
 
 
 
 
 
 
 
 
 
151
  }
152
 
153
  /**
@@ -156,7 +180,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
156
  * @return void
157
  */
158
  function enqueue_styles(){
159
- wp_enqueue_style('menu-editor-style', $this->plugin_dir_url . '/css/menu-editor.css', array(), '1.1');
160
  }
161
 
162
  /**
@@ -168,7 +192,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
168
  global $menu, $submenu;
169
 
170
  //Menu reset (for emergencies). Executed by accessing http://example.com/wp-admin/?reset_admin_menu=1
171
- $reset_requested = isset($_GET['reset_admin_menu']) && $_GET['reset_admin_menu'];
172
  if ( $reset_requested && $this->current_user_can_edit_menu() ){
173
  $this->options['custom_menu'] = null;
174
  $this->save_options();
@@ -446,7 +470,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
446
  */
447
  function menu_merge($tree, $menu, $submenu){
448
  list($menu_defaults, $submenu_defaults) = $this->build_lookups($menu, $submenu);
449
-
450
  //Iterate over all menus and submenus and look up default values
451
  foreach ($tree as &$topmenu){
452
  $topfile = $this->get_menu_field($topmenu, 'file');
@@ -470,7 +494,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
470
  }
471
  }
472
 
473
- if (is_array($topmenu['items'])) {
474
  //Iterate over submenu items
475
  foreach ($topmenu['items'] as $file => &$item){
476
  $uid = $this->unique_submenu_id($item, $topfile);
@@ -588,10 +612,10 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
588
  //Attach submenu items
589
  $parent = $tree_item['defaults']['file'];
590
  if ( isset($submenu[$parent]) ){
591
- foreach($submenu[$parent] as $pos => $subitem){
592
  $tree_item['items'][$subitem[2]] = array_merge(
593
  $this->templates['blank_item'],
594
- array('defaults' => $this->submenu2assoc($subitem, $pos, $parent))
595
  );
596
  }
597
  }
@@ -865,25 +889,17 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
865
  die("Access denied");
866
  }
867
 
868
- $post = $_POST;
869
- $get = $_GET;
870
- if ( function_exists('wp_magic_quotes') ){
871
- //Ceterum censeo, WP shouldn't mangle superglobals.
872
- $post = stripslashes_deep($post);
873
- $get = stripslashes_deep($get);
874
- }
875
-
876
- $action = isset($post['action'])?$post['action']:(isset($get['action'])?$get['action']:'');
877
  do_action('admin_menu_editor_header', $action);
878
 
879
  //Handle form submissions
880
- if (isset($post['data'])){
881
  check_admin_referer('menu-editor-form');
882
 
883
  //Try to decode a menu tree encoded as JSON
884
- $data = $this->json_decode($post['data'], true);
885
  if (!$data || (count($data) < 2) ){
886
- $fixed = stripslashes($post['data']);
887
  $data = $this->json_decode( $fixed, true );
888
  }
889
 
@@ -916,7 +932,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
916
  }
917
 
918
  //Handle the survey notice
919
- if ( isset($_GET['hide_survey_notice']) && !empty($_GET['hide_survey_notice']) ) {
920
  $this->options['display_survey_notice'] = false;
921
  $this->save_options();
922
  }
@@ -942,10 +958,10 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
942
 
943
  <?php
944
 
945
- if ( !empty($_GET['message']) ){
946
- if ( intval($_GET['message']) == 1 ){
947
  echo '<div id="message" class="updated fade"><p><strong>Settings saved.</strong></p></div>';
948
- } elseif ( intval($_GET['message']) == 2 ) {
949
  echo '<div id="message" class="error"><p><strong>Failed to decode input! The menu wasn\'t modified.</strong></p></div>';
950
  }
951
  }
@@ -1055,6 +1071,30 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
1055
  ?>
1056
  </div>
1057
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1058
  </div>
1059
 
1060
  <?php
@@ -1262,10 +1302,57 @@ window.wsMenuEditorPro = false; //Will be overwritten if extras are loaded
1262
  )));
1263
  }
1264
 
1265
- $this->options['hide_advanced_settings'] = !empty($_POST['hide_advanced_settings']);
1266
  $this->save_options();
1267
  die('1');
1268
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1269
 
1270
  /**
1271
  * A callback for the stub meta box added to the plugin's page. Does nothing.
@@ -1275,7 +1362,23 @@ window.wsMenuEditorPro = false; //Will be overwritten if extras are loaded
1275
  function noop(){
1276
  //nihil
1277
  }
1278
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1279
  } //class
1280
 
1281
  endif;
27
 
28
  private $templates = null; //Template arrays for various menu structures. See the constructor for details.
29
 
30
+ //Our personal copy of the request vars, without any "magic quotes".
31
+ private $post = array();
32
+ private $get = array();
33
+
34
  function init(){
35
  //Determine if the plugin is active network-wide (i.e. either installed in
36
  //the /mu-plugins/ directory or activated "network wide" by the super admin.
45
  $this->defaults = array(
46
  'hide_advanced_settings' => true,
47
  'menu_format_version' => 0,
48
+ 'display_survey_notice' => false,
49
  );
50
  $this->serialize_with_json = false; //(Don't) store the options in JSON format
51
 
98
  );
99
 
100
  //AJAXify screen options
101
+ add_action( 'wp_ajax_ws_ame_save_screen_options', array(&$this,'ajax_save_screen_options') );
102
+
103
+ //AJAXify hints
104
+ add_action('wp_ajax_ws_ame_hide_hint', array($this, 'ajax_hide_hint'));
105
+
106
+ //Make sure we have access to the original, un-mangled request data.
107
+ //This is necessary because WordPress will stupidly apply "magic quotes"
108
+ //to the request vars even if this PHP misfeature is disabled.
109
+ add_action('plugins_loaded', array($this, 'capture_request_vars'));
110
+
111
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_menu_fix_script'));
112
  }
113
 
114
  /**
162
  array('jquery', 'jquery-ui-sortable', 'jquery-ui-dialog', 'jquery-form'),
163
  '1.1'
164
  );
165
+
166
+ //The editor will need access to some of the plugin data and WP data.
167
+ wp_localize_script(
168
+ 'menu-editor',
169
+ 'wsEditorData',
170
+ array(
171
+ 'adminAjaxUrl' => admin_url('admin-ajax.php'),
172
+ 'showHints' => $this->get_hint_visibility(),
173
+ )
174
+ );
175
  }
176
 
177
  /**
180
  * @return void
181
  */
182
  function enqueue_styles(){
183
+ wp_enqueue_style('menu-editor-style', $this->plugin_dir_url . '/css/menu-editor.css', array(), '20120626');
184
  }
185
 
186
  /**
192
  global $menu, $submenu;
193
 
194
  //Menu reset (for emergencies). Executed by accessing http://example.com/wp-admin/?reset_admin_menu=1
195
+ $reset_requested = isset($this->get['reset_admin_menu']) && $this->get['reset_admin_menu'];
196
  if ( $reset_requested && $this->current_user_can_edit_menu() ){
197
  $this->options['custom_menu'] = null;
198
  $this->save_options();
470
  */
471
  function menu_merge($tree, $menu, $submenu){
472
  list($menu_defaults, $submenu_defaults) = $this->build_lookups($menu, $submenu);
473
+
474
  //Iterate over all menus and submenus and look up default values
475
  foreach ($tree as &$topmenu){
476
  $topfile = $this->get_menu_field($topmenu, 'file');
494
  }
495
  }
496
 
497
+ if (isset($topmenu['items']) && is_array($topmenu['items'])) {
498
  //Iterate over submenu items
499
  foreach ($topmenu['items'] as $file => &$item){
500
  $uid = $this->unique_submenu_id($item, $topfile);
612
  //Attach submenu items
613
  $parent = $tree_item['defaults']['file'];
614
  if ( isset($submenu[$parent]) ){
615
+ foreach($submenu[$parent] as $subitem_pos => $subitem){
616
  $tree_item['items'][$subitem[2]] = array_merge(
617
  $this->templates['blank_item'],
618
+ array('defaults' => $this->submenu2assoc($subitem, $subitem_pos, $parent))
619
  );
620
  }
621
  }
889
  die("Access denied");
890
  }
891
 
892
+ $action = isset($this->post['action']) ? $this->post['action'] : (isset($this->get['action']) ? $this->get['action'] : '');
 
 
 
 
 
 
 
 
893
  do_action('admin_menu_editor_header', $action);
894
 
895
  //Handle form submissions
896
+ if (isset($this->post['data'])){
897
  check_admin_referer('menu-editor-form');
898
 
899
  //Try to decode a menu tree encoded as JSON
900
+ $data = $this->json_decode($this->post['data'], true);
901
  if (!$data || (count($data) < 2) ){
902
+ $fixed = stripslashes($this->post['data']);
903
  $data = $this->json_decode( $fixed, true );
904
  }
905
 
932
  }
933
 
934
  //Handle the survey notice
935
+ if ( isset($this->get['hide_survey_notice']) && !empty($this->get['hide_survey_notice']) ) {
936
  $this->options['display_survey_notice'] = false;
937
  $this->save_options();
938
  }
958
 
959
  <?php
960
 
961
+ if ( !empty($this->get['message']) ){
962
+ if ( intval($this->get['message']) == 1 ){
963
  echo '<div id="message" class="updated fade"><p><strong>Settings saved.</strong></p></div>';
964
+ } elseif ( intval($this->get['message']) == 2 ) {
965
  echo '<div id="message" class="error"><p><strong>Failed to decode input! The menu wasn\'t modified.</strong></p></div>';
966
  }
967
  }
1071
  ?>
1072
  </div>
1073
 
1074
+ <?php
1075
+ $show_hints = $this->get_hint_visibility();
1076
+ $hint_id = 'ws_sidebar_pro_ad';
1077
+ $show_pro_benefits = !apply_filters('admin_menu_editor_is_pro', false) && (!isset($show_hints[$hint_id]) || $show_hints[$hint_id]);
1078
+ if ( $show_pro_benefits ):
1079
+ ?>
1080
+ <div class="clear"></div>
1081
+
1082
+ <div class="ws_hint" id="<?php echo esc_attr($hint_id); ?>">
1083
+ <div class="ws_hint_close" title="Close">x</div>
1084
+ <div class="ws_hint_content">
1085
+ <strong>Upgrade to Pro:</strong>
1086
+ <ul>
1087
+ <li>Menu export & import.</li>
1088
+ <li>Per-role menu permissions.</li>
1089
+ <li>Drag items between menu levels.</li>
1090
+ </ul>
1091
+ <a href="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&utm_campaign=Plugins" target="_blank">Learn more</a>
1092
+ </div>
1093
+ </div>
1094
+ <?php
1095
+ endif;
1096
+ ?>
1097
+
1098
  </div>
1099
 
1100
  <?php
1302
  )));
1303
  }
1304
 
1305
+ $this->options['hide_advanced_settings'] = !empty($this->post['hide_advanced_settings']);
1306
  $this->save_options();
1307
  die('1');
1308
  }
1309
+
1310
+ public function ajax_hide_hint() {
1311
+ if ( !isset($this->post['hint']) || !$this->current_user_can_edit_menu() ){
1312
+ die("You're not allowed to do that!");
1313
+ }
1314
+
1315
+ $show_hints = $this->get_hint_visibility();
1316
+ $show_hints[strval($this->post['hint'])] = false;
1317
+ $this->set_hint_visibility($show_hints);
1318
+
1319
+ die("OK");
1320
+ }
1321
+
1322
+ private function get_hint_visibility() {
1323
+ $user = wp_get_current_user();
1324
+ $show_hints = get_user_meta($user->ID, 'ame_show_hints', true);
1325
+ if ( !is_array($show_hints) ) {
1326
+ $show_hints = array();
1327
+ }
1328
+
1329
+ $defaults = array(
1330
+ 'ws_sidebar_pro_ad' => true,
1331
+ //'ws_whats_new_120' => true, //Set upon activation, default not needed.
1332
+ 'ws_hint_menu_permissions' => true,
1333
+ );
1334
+
1335
+ return array_merge($defaults, $show_hints);
1336
+ }
1337
+
1338
+ private function set_hint_visibility($show_hints) {
1339
+ $user = wp_get_current_user();
1340
+ update_user_meta($user->ID, 'ame_show_hints', $show_hints);
1341
+ }
1342
+
1343
+ /**
1344
+ * Enqueue a script that fixes a bug where pages moved to a different menu
1345
+ * would not be highlighted properly when the user visits them.
1346
+ */
1347
+ public function enqueue_menu_fix_script() {
1348
+ wp_enqueue_script(
1349
+ 'ame-menu-fix',
1350
+ $this->plugin_dir_url . '/js/menu-highlight-fix.js',
1351
+ array('jquery'),
1352
+ '20120519',
1353
+ true
1354
+ );
1355
+ }
1356
 
1357
  /**
1358
  * A callback for the stub meta box added to the plugin's page. Does nothing.
1362
  function noop(){
1363
  //nihil
1364
  }
1365
+
1366
+ /**
1367
+ * Capture $_GET and $_POST in $this->get and $this->post.
1368
+ * Slashes added by "magic quotes" will be stripped.
1369
+ *
1370
+ * @return void
1371
+ */
1372
+ function capture_request_vars(){
1373
+ $this->post = $_POST;
1374
+ $this->get = $_GET;
1375
+
1376
+ if ( function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() ) {
1377
+ $this->post = stripslashes_deep($this->post);
1378
+ $this->get = stripslashes_deep($this->get);
1379
+ }
1380
+ }
1381
+
1382
  } //class
1383
 
1384
  endif;
js/menu-editor.js CHANGED
@@ -1,5 +1,7 @@
1
  //(c) W-Shadow
2
 
 
 
3
  var wsIdCounter = 0;
4
 
5
  (function ($){
@@ -150,7 +152,7 @@ function buildSubmenu(items){
150
 
151
  //Only show menus that have items.
152
  //Skip arrays (with a length) because filled menus are encoded as custom objects.
153
- var entry = null
154
  if (items && (typeof items != 'Array')){
155
  for (var item_file in items){
156
  entry = buildMenuItem(items[item_file]);
@@ -1415,8 +1417,21 @@ $(document).ready(function(){
1415
  }
1416
 
1417
  }
1418
- });
1419
-
 
 
 
 
 
 
 
 
 
 
 
 
 
1420
 
1421
  //Finally, show the menu
1422
  outputWpMenu(customMenu);
1
  //(c) W-Shadow
2
 
3
+ /** @namespace wsEditorData */
4
+
5
  var wsIdCounter = 0;
6
 
7
  (function ($){
152
 
153
  //Only show menus that have items.
154
  //Skip arrays (with a length) because filled menus are encoded as custom objects.
155
+ var entry = null;
156
  if (items && (typeof items != 'Array')){
157
  for (var item_file in items){
158
  entry = buildMenuItem(items[item_file]);
1417
  }
1418
 
1419
  }
1420
+ });
1421
+
1422
+ //Flag closed hints as hidden by sending the appropriate AJAX request to the backend.
1423
+ $('.ws_hint_close').click(function() {
1424
+ var hint = $(this).parents('.ws_hint').first();
1425
+ hint.hide();
1426
+ wsEditorData.showHints[hint.attr('id')] = false;
1427
+ $.post(
1428
+ wsEditorData.adminAjaxUrl,
1429
+ {
1430
+ 'action' : 'ws_ame_hide_hint',
1431
+ 'hint' : hint.attr('id')
1432
+ }
1433
+ );
1434
+ });
1435
 
1436
  //Finally, show the menu
1437
  outputWpMenu(customMenu);
js/menu-highlight-fix.js ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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,
8
+ m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
9
+ uri = {},
10
+ i = 14;
11
+
12
+ while (i--) uri[o.key[i]] = m[i] || "";
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;
20
+ }
21
+
22
+ parseUri.options = {
23
+ strictMode: false,
24
+ key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
25
+ q: {
26
+ name: "queryKey",
27
+ parser: /(?:^|&)([^&=]*)=?([^&]*)/g
28
+ },
29
+ parser: {
30
+ strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
31
+ loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
32
+ }
33
+ };
34
+
35
+ // --- parseUri ends ---
36
+
37
+ //Find the menu item whose URL best matches the currently open page.
38
+ var currentUri = parseUri(location.href);
39
+ var bestMatch = {
40
+ uri : null,
41
+ link : null,
42
+ matchingParams : -1,
43
+ differentParams : 10000
44
+ };
45
+ $('#adminmenu li > a').each(function(index, link) {
46
+ var uri = parseUri(link.href);
47
+
48
+ //Check for a close match - everything but query and #anchor.
49
+ var components = ['protocol', 'host', 'port', 'user', 'password', 'path'];
50
+ var isCloseMatch = true;
51
+ for (var i = 0; (i < components.length) && isCloseMatch; i++) {
52
+ isCloseMatch = isCloseMatch && (uri[components[i]] == currentUri[components[i]]);
53
+ }
54
+
55
+ if (!isCloseMatch) {
56
+ return true; //Skip to the next link.
57
+ }
58
+
59
+ //Calculate the number of matching and different query parameters.
60
+ var matchingParams = 0, differentParams = 0, param;
61
+ for(param in uri.queryKey) {
62
+ if (uri.queryKey.hasOwnProperty(param)) {
63
+ if (currentUri.queryKey.hasOwnProperty(param) && (uri.queryKey[param] == currentUri.queryKey[param])) {
64
+ matchingParams++;
65
+ } else {
66
+ differentParams++;
67
+ }
68
+ }
69
+ }
70
+ for(param in currentUri.queryKey) {
71
+ if (currentUri.queryKey.hasOwnProperty(param) && !uri.queryKey.hasOwnProperty(param)) {
72
+ differentParams++;
73
+ }
74
+ }
75
+
76
+ //Note: We're not checking for #anchor matches since it's extremely unlikely we'll ever encounter
77
+ //a case where two menu pages are identical except for the anchor.
78
+
79
+ if (
80
+ (matchingParams > bestMatch.matchingParams)
81
+ ||
82
+ (
83
+ (matchingParams == bestMatch.matchingParams) &&
84
+ (differentParams < bestMatch.differentParams)
85
+ )
86
+ ||
87
+ (
88
+ //Prefer sub-menu links.
89
+ (matchingParams == bestMatch.matchingParams) &&
90
+ (differentParams == bestMatch.differentParams) &&
91
+ !$(link).hasClass('menu-top')
92
+ )
93
+ ) {
94
+ bestMatch.uri = uri;
95
+ bestMatch.link = link;
96
+ bestMatch.matchingParams = matchingParams;
97
+ bestMatch.differentParams = differentParams;
98
+ }
99
+ });
100
+
101
+ //Highlight and/or expand the best matching menu.
102
+ if (bestMatch.link !== null) {
103
+ var bestMatchLink = $(bestMatch.link);
104
+ var parentMenu = bestMatchLink.closest('li.menu-top');
105
+ //console.log('Best match is: ', bestMatchLink);
106
+
107
+ var otherHighlightedMenus = $('li.wp-has-current-submenu, li.menu-top.current', '#adminmenu').not(parentMenu);
108
+
109
+ var isWrongItemHighlighted = !bestMatchLink.hasClass('current');
110
+ var isWrongMenuHighlighted = !parentMenu.is('.wp-has-current-submenu, .current') ||
111
+ (otherHighlightedMenus.length > 0);
112
+
113
+ if (isWrongMenuHighlighted) {
114
+ //Account for users who use a plugin to keep all menus expanded.
115
+ var shouldCloseOtherMenus = $('li.wp-has-current-submenu', '#adminmenu').length <= 1;
116
+ if (shouldCloseOtherMenus) {
117
+ otherHighlightedMenus.removeClass('wp-menu-open');
118
+ otherHighlightedMenus.removeClass('wp-has-current-submenu current').addClass('wp-not-current-submenu');
119
+ }
120
+
121
+ var parentMenuAndLink = parentMenu.add('> a.menu-top', parentMenu);
122
+ parentMenuAndLink.removeClass('wp-not-current-submenu');
123
+ if (parentMenu.hasClass('wp-has-submenu')) {
124
+ parentMenuAndLink.addClass('wp-has-current-submenu wp-menu-open');
125
+ }
126
+ }
127
+
128
+ if (isWrongItemHighlighted) {
129
+ $('#adminmenu .current').removeClass('current');
130
+ bestMatchLink.addClass('current').closest('li').addClass('current');
131
+ }
132
+ }
133
+ });
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.6.1
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/blog/
9
  */
@@ -12,8 +12,7 @@ Author URI: http://w-shadow.com/blog/
12
  if ( is_admin() ) {
13
 
14
  //Load the plugin
15
- require 'includes/menu-editor-core.php';
16
  $wp_menu_editor = new WPMenuEditor(__FILE__, 'ws_menu_editor');
17
 
18
  }//is_admin()
19
- ?>
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.7
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/blog/
9
  */
12
  if ( is_admin() ) {
13
 
14
  //Load the plugin
15
+ require dirname(__FILE__) . '/includes/menu-editor-core.php';
16
  $wp_menu_editor = new WPMenuEditor(__FILE__, 'ws_menu_editor');
17
 
18
  }//is_admin()
 
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.0
6
- Tested up to: 3.3.2
7
- Stable tag: 1.1.6.1
8
 
9
  Lets you directly edit the WordPress admin menu. You can re-order, hide or rename existing menus, add custom menus and more.
10
 
@@ -61,6 +61,12 @@ Plugins installed in the `mu-plugins` directory are treated as "always on", so y
61
 
62
  == Changelog ==
63
 
 
 
 
 
 
 
64
  = 1.1.6.1 =
65
  * Tested on WP 3.3.2
66
  * Added a user survey.
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.0
6
+ Tested up to: 3.4
7
+ Stable tag: 1.1.7
8
 
9
  Lets you directly edit the WordPress admin menu. You can re-order, hide or rename existing menus, add custom menus and more.
10
 
61
 
62
  == Changelog ==
63
 
64
+ = 1.1.7 =
65
+ * Tested on WP 3.4
66
+ * Fixed a rare "failed to decode input" error.
67
+ * Fixed menus not being expanded/collapsed properly when the current menu item has been moved to a different sub-menu.
68
+ * Added a shortlist of Pro version benefits to the editor page (can be hidden).
69
+
70
  = 1.1.6.1 =
71
  * Tested on WP 3.3.2
72
  * Added a user survey.
uninstall.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  * @author W-Shadow
5
- * @copyright 2009
6
  *
7
  * The uninstallation script.
8
  */
@@ -14,7 +14,9 @@ if( defined( 'ABSPATH') && defined('WP_UNINSTALL_PLUGIN') ) {
14
  if ( function_exists('delete_site_option') ){
15
  delete_site_option('ws_menu_editor');
16
  }
17
-
18
- }
19
 
20
- ?>
 
 
 
 
2
 
3
  /**
4
  * @author W-Shadow
5
+ * @copyright 2012
6
  *
7
  * The uninstallation script.
8
  */
14
  if ( function_exists('delete_site_option') ){
15
  delete_site_option('ws_menu_editor');
16
  }
 
 
17
 
18
+ //Remove hint visibility flags
19
+ if ( function_exists('delete_metadata') ) {
20
+ delete_metadata('user', 0, 'ame_show_hints', '', true);
21
+ }
22
+ }