Admin Menu Editor - Version 1.1.10

Version Description

  • Added a new user survey. The notice will only appear for users who didn't complete or hide the previous one.
  • Fixed a number of bugs in the code that determines which menu should be expanded.
  • Fixed compatibility issues on sites running in SSL mode.
Download this release

Release Info

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

Code changes from version 1.1.9 to 1.1.10

.htaccess ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <IfModule mod_rewrite.c>
2
+ RewriteEngine on
3
+ RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]
4
+ </IfModule>
includes/menu-editor-core.php CHANGED
@@ -45,7 +45,8 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
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
 
@@ -109,6 +110,18 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
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
  /**
@@ -122,7 +135,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
122
  if ( !$this->load_options() ){
123
  $this->import_settings();
124
  }
125
-
126
  parent::activate();
127
  }
128
 
@@ -149,16 +162,16 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
149
  */
150
  function enqueue_scripts(){
151
  //jQuery JSON plugin
152
- wp_enqueue_script('jquery-json', $this->plugin_dir_url.'/js/jquery.json-1.3.js', array('jquery'), '1.3');
153
  //jQuery sort plugin
154
- wp_enqueue_script('jquery-sort', $this->plugin_dir_url.'/js/jquery.sort.js', array('jquery'));
155
  //jQuery UI Droppable
156
  wp_enqueue_script('jquery-ui-droppable');
157
 
158
  //Editor's scipts
159
  wp_enqueue_script(
160
- 'menu-editor',
161
- $this->plugin_dir_url.'/js/menu-editor.js',
162
  array('jquery', 'jquery-ui-sortable', 'jquery-ui-dialog', 'jquery-form'),
163
  '1.1'
164
  );
@@ -180,7 +193,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
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
  /**
@@ -888,7 +901,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
888
  if ( !$this->current_user_can_edit_menu() ){
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
 
@@ -930,26 +943,6 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
930
  if ( !apply_filters('admin_menu_editor_is_pro', false) ){
931
  $this->print_upgrade_notice();
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
- }
939
-
940
- if ( $this->options['display_survey_notice'] ) {
941
- $survey_url = 'https://docs.google.com/spreadsheet/viewform?formkey=dDVLOFM4V0JodUVTbWdUMkJtb2ZtZGc6MQ';
942
- $hide_url = add_query_arg('hide_survey_notice', 1);
943
- printf(
944
- '<div class="updated">
945
- <p><strong>Help improve this plugin - take the Admin Menu Editor user survey!</strong></p>
946
- <p><a href="%s" target="_blank" title="Opens in a new window">Take the survey</a></p>
947
- <p><a href="%s">Hide this notice</a></p>
948
- </div>',
949
- esc_attr($survey_url),
950
- esc_attr($hide_url)
951
- );
952
- }
953
  ?>
954
  <div class="wrap">
955
  <h2>
@@ -982,7 +975,7 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
982
  $custom_menu_js = $this->getMenuAsJS($custom_menu);
983
 
984
  $plugin_url = $this->plugin_dir_url;
985
- $images_url = $this->plugin_dir_url . '/images';
986
 
987
  //Create a list of all known capabilities and roles. Used for the dropdown list on the access field.
988
  $all_capabilities = $this->get_all_capabilities();
@@ -1347,9 +1340,9 @@ window.wsMenuEditorPro = false; //Will be overwritten if extras are loaded
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
  }
@@ -1363,6 +1356,43 @@ window.wsMenuEditorPro = false; //Will be overwritten if extras are loaded
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.
45
  $this->defaults = array(
46
  'hide_advanced_settings' => true,
47
  'menu_format_version' => 0,
48
+ 'display_survey_notice' => true,
49
+ 'first_install_time' => null,
50
  );
51
  $this->serialize_with_json = false; //(Don't) store the options in JSON format
52
 
110
  add_action('plugins_loaded', array($this, 'capture_request_vars'));
111
 
112
  add_action('admin_enqueue_scripts', array($this, 'enqueue_menu_fix_script'));
113
+
114
+ //User survey
115
+ add_action('admin_notices', array($this, 'display_survey_notice'));
116
+ }
117
+
118
+ function init_finish() {
119
+ parent::init_finish();
120
+
121
+ if ( !isset($this->options['first_install_time']) ) {
122
+ $this->options['first_install_time'] = time();
123
+ $this->save_options();
124
+ }
125
  }
126
 
127
  /**
135
  if ( !$this->load_options() ){
136
  $this->import_settings();
137
  }
138
+
139
  parent::activate();
140
  }
141
 
162
  */
163
  function enqueue_scripts(){
164
  //jQuery JSON plugin
165
+ wp_enqueue_script('jquery-json', plugins_url('js/jquery.json-1.3.js', $this->plugin_file), array('jquery'), '1.3');
166
  //jQuery sort plugin
167
+ wp_enqueue_script('jquery-sort', plugins_url('js/jquery.sort.js', $this->plugin_file), array('jquery'));
168
  //jQuery UI Droppable
169
  wp_enqueue_script('jquery-ui-droppable');
170
 
171
  //Editor's scipts
172
  wp_enqueue_script(
173
+ 'menu-editor',
174
+ plugins_url('js/menu-editor.js', $this->plugin_file),
175
  array('jquery', 'jquery-ui-sortable', 'jquery-ui-dialog', 'jquery-form'),
176
  '1.1'
177
  );
193
  * @return void
194
  */
195
  function enqueue_styles(){
196
+ wp_enqueue_style('menu-editor-style', plugins_url('css/menu-editor.css', $this->plugin_file), array(), '20120626');
197
  }
198
 
199
  /**
901
  if ( !$this->current_user_can_edit_menu() ){
902
  die("Access denied");
903
  }
904
+
905
  $action = isset($this->post['action']) ? $this->post['action'] : (isset($this->get['action']) ? $this->get['action'] : '');
906
  do_action('admin_menu_editor_header', $action);
907
 
943
  if ( !apply_filters('admin_menu_editor_is_pro', false) ){
944
  $this->print_upgrade_notice();
945
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
946
  ?>
947
  <div class="wrap">
948
  <h2>
975
  $custom_menu_js = $this->getMenuAsJS($custom_menu);
976
 
977
  $plugin_url = $this->plugin_dir_url;
978
+ $images_url = plugins_url('images', $this->plugin_file);
979
 
980
  //Create a list of all known capabilities and roles. Used for the dropdown list on the access field.
981
  $all_capabilities = $this->get_all_capabilities();
1340
  public function enqueue_menu_fix_script() {
1341
  wp_enqueue_script(
1342
  'ame-menu-fix',
1343
+ plugins_url('js/menu-highlight-fix.js', $this->plugin_file),
1344
  array('jquery'),
1345
+ '20120709',
1346
  true
1347
  );
1348
  }
1356
  //nihil
1357
  }
1358
 
1359
+ public function display_survey_notice() {
1360
+ //Handle the survey notice
1361
+ $hide_param_name = 'ame_hide_survey_notice';
1362
+ if ( isset($this->get[$hide_param_name]) ) {
1363
+ $this->options['display_survey_notice'] = empty($this->get[$hide_param_name]);
1364
+ $this->save_options();
1365
+ }
1366
+
1367
+ $display_notice = $this->options['display_survey_notice'] && $this->current_user_can_edit_menu();
1368
+ if ( isset($this->options['first_install_time']) ) {
1369
+ $minimum_usage_period = 3*24*3600;
1370
+ $display_notice = $display_notice && ((time() - $this->options['first_install_time']) > $minimum_usage_period);
1371
+ }
1372
+
1373
+ if ( $display_notice ) {
1374
+ $free_survey_url = 'https://docs.google.com/spreadsheet/viewform?formkey=dERyeDk0OWhlbkxYcEY4QTNaMnlTQUE6MQ';
1375
+ $pro_survey_url = 'https://docs.google.com/spreadsheet/viewform?formkey=dHl4MnlHaVI3NE5JdVFDWG01SkRKTWc6MA';
1376
+
1377
+ if ( apply_filters('admin_menu_editor_is_pro', false) ) {
1378
+ $survey_url = $pro_survey_url;
1379
+ } else {
1380
+ $survey_url = $free_survey_url;
1381
+ }
1382
+
1383
+ $hide_url = add_query_arg($hide_param_name, 1);
1384
+ printf(
1385
+ '<div class="updated">
1386
+ <p><strong>Help improve Admin Menu Editor - take the user survey!</strong></p>
1387
+ <p><a href="%s" target="_blank" title="Opens in a new window">Take the survey</a></p>
1388
+ <p><a href="%s">Hide this notice</a></p>
1389
+ </div>',
1390
+ esc_attr($survey_url),
1391
+ esc_attr($hide_url)
1392
+ );
1393
+ }
1394
+ }
1395
+
1396
  /**
1397
  * Capture $_GET and $_POST in $this->get and $this->post.
1398
  * Slashes added by "magic quotes" will be stripped.
includes/shadow_plugin_framework.php CHANGED
@@ -5,17 +5,6 @@
5
  * @copyright 2008-2011
6
  */
7
 
8
- //Make sure the needed constants are defined
9
- if ( ! defined( 'WP_CONTENT_URL' ) )
10
- define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
11
- if ( ! defined( 'WP_CONTENT_DIR' ) )
12
- define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
13
- if ( ! defined( 'WP_PLUGIN_URL' ) )
14
- define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
15
- if ( ! defined( 'WP_PLUGIN_DIR' ) )
16
- define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
17
-
18
-
19
  //Load JSON functions for PHP < 5.2
20
  if ( !(function_exists('json_encode') && function_exists('json_decode')) && !(class_exists('Services_JSON') || class_exists('Moxiecode_JSON')) ){
21
  $class_json_path = ABSPATH.WPINC.'/class-json.php';
@@ -67,12 +56,8 @@ class MenuEd_ShadowPluginFramework {
67
  $this->plugin_file = $plugin_file;
68
  $this->plugin_basename = plugin_basename($this->plugin_file);
69
 
70
- if ( $this->is_mu_plugin ){
71
- $this->plugin_dir_url = WPMU_PLUGIN_URL . '/' . dirname($this->plugin_basename);
72
- } else {
73
- $this->plugin_dir_url = WP_PLUGIN_URL . '/' . dirname($this->plugin_basename);
74
- }
75
-
76
  /************************************
77
  Add the default hooks
78
  ************************************/
5
  * @copyright 2008-2011
6
  */
7
 
 
 
 
 
 
 
 
 
 
 
 
8
  //Load JSON functions for PHP < 5.2
9
  if ( !(function_exists('json_encode') && function_exists('json_decode')) && !(class_exists('Services_JSON') || class_exists('Moxiecode_JSON')) ){
10
  $class_json_path = ABSPATH.WPINC.'/class-json.php';
56
  $this->plugin_file = $plugin_file;
57
  $this->plugin_basename = plugin_basename($this->plugin_file);
58
 
59
+ $this->plugin_dir_url = rtrim(plugin_dir_url($this->plugin_file), '/');
60
+
 
 
 
 
61
  /************************************
62
  Add the default hooks
63
  ************************************/
js/menu-highlight-fix.js CHANGED
@@ -40,9 +40,19 @@ jQuery(function($) {
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.
@@ -73,34 +83,55 @@ jQuery(function($) {
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
 
40
  uri : null,
41
  link : null,
42
  matchingParams : -1,
43
+ differentParams : 10000,
44
+ isAnchorMatch : false,
45
+ isTopMenu : false
46
  };
47
+
48
  $('#adminmenu li > a').each(function(index, link) {
49
+ var $link = $(link);
50
+
51
+ //Skip "#" links. Some plugins (e.g. S2Member 120703) use such no-op items as menu dividers.
52
+ if ($link.attr('href') == '#') {
53
+ return true;
54
+ }
55
+
56
  var uri = parseUri(link.href);
57
 
58
  //Check for a close match - everything but query and #anchor.
83
  }
84
  }
85
 
86
+ var isAnchorMatch = uri.anchor == currentUri.anchor;
87
+ var isTopMenu = $link.hasClass('menu-top');
88
+
89
+ //Figure out if the current link is better than the best found so far.
90
+ //To do that, we compare them by several criteria (in order of priority):
91
+ var comparisons = [
92
+ {
93
+ better : (matchingParams > bestMatch.matchingParams),
94
+ equal : (matchingParams == bestMatch.matchingParams)
95
+ },
96
+ {
97
+ better : (differentParams < bestMatch.differentParams),
98
+ equal : (differentParams == bestMatch.differentParams)
99
+ },
100
+ {
101
+ better : (isAnchorMatch && (!bestMatch.isAnchorMatch)),
102
+ equal : (isAnchorMatch == bestMatch.isAnchorMatch)
103
+ },
104
+ {
105
+ better : (!isTopMenu && bestMatch.isTopMenu),
106
+ equal : (isTopMenu == bestMatch.isTopMenu)
107
+ }
108
+ ];
109
+
110
+ var isBetterMatch = false,
111
+ isEquallyGood = true,
112
+ j = 0;
113
+
114
+ while (isEquallyGood && !isBetterMatch && (j < comparisons.length)) {
115
+ isBetterMatch = comparisons[j].better;
116
+ isEquallyGood = comparisons[j].equal;
117
+ j++;
118
+ }
119
+
120
+ if (isBetterMatch || isEquallyGood) {
121
+ bestMatch = {
122
+ uri : uri,
123
+ link : $link,
124
+ matchingParams : matchingParams,
125
+ differentParams : differentParams,
126
+ isAnchorMatch : isAnchorMatch,
127
+ isTopMenu : isTopMenu
128
+ }
129
  }
130
  });
131
 
132
  //Highlight and/or expand the best matching menu.
133
  if (bestMatch.link !== null) {
134
+ var bestMatchLink = bestMatch.link;
135
  var parentMenu = bestMatchLink.closest('li.menu-top');
136
  //console.log('Best match is: ', bestMatchLink);
137
 
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.9
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.10
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/
9
  */
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  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.4.1
7
- Stable tag: 1.1.9
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,11 @@ Plugins installed in the `mu-plugins` directory are treated as "always on", so y
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
66
  = 1.1.8 =
67
  * Fix author URL (was 404).
68
  * Tested on WP 3.4.1
2
  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.2
6
  Tested up to: 3.4.1
7
+ Stable tag: 1.1.10
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.10 =
67
+ * Added a new user survey. The notice will only appear for users who didn't complete or hide the previous one.
68
+ * Fixed a number of bugs in the code that determines which menu should be expanded.
69
+ * Fixed compatibility issues on sites running in SSL mode.
70
+
71
  = 1.1.8 =
72
  * Fix author URL (was 404).
73
  * Tested on WP 3.4.1