Version Description
- Fixed a bug where closing the menu properties of a custom menu item could set "extra capability" to "read".
- Added a workaround for WooCommerce 2.6.8 to display the number of new orders in the "Orders" menu title.
- Minor cosmetic changes.
- Tested with WP 4.7 and 4.8-alpha.
Download this release
Release Info
| Developer | whiteshadow |
| Plugin | |
| Version | 1.7.3 |
| Comparing to | |
| See all releases | |
Code changes from version 1.7.2 to 1.7.3
- css/menu-editor.css +18 -8
- css/menu-editor.scss +19 -4
- includes/.htaccess +5 -5
- includes/editor-page.php +23 -0
- includes/menu-editor-core.php +46 -1
- includes/menu.php +22 -1
- js/actor-manager.ts +0 -1
- js/menu-editor.js +128 -5
- menu-editor.php +1 -1
- readme.txt +8 -2
css/menu-editor.css
CHANGED
|
@@ -11,10 +11,11 @@
|
|
| 11 |
float: left;
|
| 12 |
display: block;
|
| 13 |
border: 1px solid #cdd5d5;
|
|
|
|
| 14 |
background-color: #FFFFFF;
|
| 15 |
-
border-radius:
|
| 16 |
-
-moz-border-radius:
|
| 17 |
-
-webkit-border-radius:
|
| 18 |
|
| 19 |
.ws_box {
|
| 20 |
min-height: 30px;
|
|
@@ -1270,6 +1271,11 @@ a#ws-ame-delete-color-preset:hover {
|
|
| 1270 |
#ws_plugin_settings_form .ws_tooltip_trigger .dashicons {
|
| 1271 |
font-size: 18px; }
|
| 1272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1273 |
.ws_wide_tooltip {
|
| 1274 |
max-width: 450px; }
|
| 1275 |
|
|
@@ -1308,14 +1314,14 @@ a#ws-ame-delete-color-preset:hover {
|
|
| 1308 |
list-style-position: inside;
|
| 1309 |
margin-left: 0.5em; }
|
| 1310 |
|
| 1311 |
-
.ws_ame_doc_box .hndle {
|
| 1312 |
cursor: default !important; }
|
| 1313 |
-
.ws_ame_doc_box ul {
|
| 1314 |
list-style: disc outside;
|
| 1315 |
margin-left: 1em; }
|
| 1316 |
-
.ws_ame_doc_box li > ul {
|
| 1317 |
margin-top: 6px; }
|
| 1318 |
-
.ws_ame_doc_box .button-link .toggle-indicator::before {
|
| 1319 |
margin-top: 4px;
|
| 1320 |
width: 20px;
|
| 1321 |
-webkit-border-radius: 50%;
|
|
@@ -1327,9 +1333,13 @@ a#ws-ame-delete-color-preset:hover {
|
|
| 1327 |
-webkit-font-smoothing: antialiased;
|
| 1328 |
-moz-osx-font-smoothing: grayscale;
|
| 1329 |
text-decoration: none !important; }
|
| 1330 |
-
.ws_ame_doc_box.closed .button-link .toggle-indicator::before {
|
| 1331 |
content: "\f140"; }
|
| 1332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1333 |
/************************************
|
| 1334 |
Copy Permissions dialog
|
| 1335 |
*************************************/
|
| 11 |
float: left;
|
| 12 |
display: block;
|
| 13 |
border: 1px solid #cdd5d5;
|
| 14 |
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
|
| 15 |
background-color: #FFFFFF;
|
| 16 |
+
border-radius: 0px;
|
| 17 |
+
-moz-border-radius: 0px;
|
| 18 |
+
-webkit-border-radius: 0px; }
|
| 19 |
|
| 20 |
.ws_box {
|
| 21 |
min-height: 30px;
|
| 1271 |
#ws_plugin_settings_form .ws_tooltip_trigger .dashicons {
|
| 1272 |
font-size: 18px; }
|
| 1273 |
|
| 1274 |
+
.ws_ame_custom_postbox .ws_tooltip_trigger .dashicons {
|
| 1275 |
+
font-size: 18px;
|
| 1276 |
+
height: 18px;
|
| 1277 |
+
vertical-align: bottom; }
|
| 1278 |
+
|
| 1279 |
.ws_wide_tooltip {
|
| 1280 |
max-width: 450px; }
|
| 1281 |
|
| 1314 |
list-style-position: inside;
|
| 1315 |
margin-left: 0.5em; }
|
| 1316 |
|
| 1317 |
+
.ws_ame_doc_box .hndle, .ws_ame_custom_postbox .hndle {
|
| 1318 |
cursor: default !important; }
|
| 1319 |
+
.ws_ame_doc_box ul, .ws_ame_custom_postbox ul {
|
| 1320 |
list-style: disc outside;
|
| 1321 |
margin-left: 1em; }
|
| 1322 |
+
.ws_ame_doc_box li > ul, .ws_ame_custom_postbox li > ul {
|
| 1323 |
margin-top: 6px; }
|
| 1324 |
+
.ws_ame_doc_box .button-link .toggle-indicator::before, .ws_ame_custom_postbox .button-link .toggle-indicator::before {
|
| 1325 |
margin-top: 4px;
|
| 1326 |
width: 20px;
|
| 1327 |
-webkit-border-radius: 50%;
|
| 1333 |
-webkit-font-smoothing: antialiased;
|
| 1334 |
-moz-osx-font-smoothing: grayscale;
|
| 1335 |
text-decoration: none !important; }
|
| 1336 |
+
.ws_ame_doc_box.closed .button-link .toggle-indicator::before, .ws_ame_custom_postbox.closed .button-link .toggle-indicator::before {
|
| 1337 |
content: "\f140"; }
|
| 1338 |
|
| 1339 |
+
.ws_basic_container .ws_ame_custom_postbox {
|
| 1340 |
+
margin-left: 2px;
|
| 1341 |
+
margin-right: 2px; }
|
| 1342 |
+
|
| 1343 |
/************************************
|
| 1344 |
Copy Permissions dialog
|
| 1345 |
*************************************/
|
css/menu-editor.scss
CHANGED
|
@@ -10,6 +10,7 @@
|
|
| 10 |
|
| 11 |
$mainContainerWidth: 310px;
|
| 12 |
$mainContainerBorderWidth: 1px;
|
|
|
|
| 13 |
|
| 14 |
.ws_main_container {
|
| 15 |
margin: 2px;
|
|
@@ -18,11 +19,12 @@ $mainContainerBorderWidth: 1px;
|
|
| 18 |
display:block;
|
| 19 |
|
| 20 |
border: $mainContainerBorderWidth solid #cdd5d5;
|
|
|
|
| 21 |
background-color: #FFFFFF;
|
| 22 |
|
| 23 |
-
border-radius:
|
| 24 |
-
-moz-border-radius:
|
| 25 |
-
-webkit-border-radius:
|
| 26 |
}
|
| 27 |
|
| 28 |
.ws_box {
|
|
@@ -1790,6 +1792,13 @@ $userSelectionPanelPadding: 10px;
|
|
| 1790 |
font-size: 18px;
|
| 1791 |
}
|
| 1792 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1793 |
.ws_wide_tooltip {
|
| 1794 |
max-width: 450px;
|
| 1795 |
}
|
|
@@ -1837,7 +1846,7 @@ $userSelectionPanelPadding: 10px;
|
|
| 1837 |
margin-left: 0.5em;
|
| 1838 |
}
|
| 1839 |
|
| 1840 |
-
.ws_ame_doc_box {
|
| 1841 |
.hndle {
|
| 1842 |
cursor: default !important;
|
| 1843 |
}
|
|
@@ -1872,6 +1881,12 @@ $userSelectionPanelPadding: 10px;
|
|
| 1872 |
}
|
| 1873 |
}
|
| 1874 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1875 |
/************************************
|
| 1876 |
Copy Permissions dialog
|
| 1877 |
*************************************/
|
| 10 |
|
| 11 |
$mainContainerWidth: 310px;
|
| 12 |
$mainContainerBorderWidth: 1px;
|
| 13 |
+
$mainContainerBorderRadius: 0px;
|
| 14 |
|
| 15 |
.ws_main_container {
|
| 16 |
margin: 2px;
|
| 19 |
display:block;
|
| 20 |
|
| 21 |
border: $mainContainerBorderWidth solid #cdd5d5;
|
| 22 |
+
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
| 23 |
background-color: #FFFFFF;
|
| 24 |
|
| 25 |
+
border-radius: $mainContainerBorderRadius;
|
| 26 |
+
-moz-border-radius: $mainContainerBorderRadius;
|
| 27 |
+
-webkit-border-radius: $mainContainerBorderRadius;
|
| 28 |
}
|
| 29 |
|
| 30 |
.ws_box {
|
| 1792 |
font-size: 18px;
|
| 1793 |
}
|
| 1794 |
|
| 1795 |
+
//And in other boxes.
|
| 1796 |
+
.ws_ame_custom_postbox .ws_tooltip_trigger .dashicons {
|
| 1797 |
+
font-size: 18px;
|
| 1798 |
+
height: 18px;
|
| 1799 |
+
vertical-align: bottom;
|
| 1800 |
+
}
|
| 1801 |
+
|
| 1802 |
.ws_wide_tooltip {
|
| 1803 |
max-width: 450px;
|
| 1804 |
}
|
| 1846 |
margin-left: 0.5em;
|
| 1847 |
}
|
| 1848 |
|
| 1849 |
+
.ws_ame_doc_box, .ws_ame_custom_postbox {
|
| 1850 |
.hndle {
|
| 1851 |
cursor: default !important;
|
| 1852 |
}
|
| 1881 |
}
|
| 1882 |
}
|
| 1883 |
|
| 1884 |
+
.ws_basic_container .ws_ame_custom_postbox {
|
| 1885 |
+
//Match .ws_main_container's horizontal margins for proper alignment.
|
| 1886 |
+
margin-left: 2px;
|
| 1887 |
+
margin-right: 2px;
|
| 1888 |
+
}
|
| 1889 |
+
|
| 1890 |
/************************************
|
| 1891 |
Copy Permissions dialog
|
| 1892 |
*************************************/
|
includes/.htaccess
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
# Apache < 2.3
|
| 2 |
-
|
| 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>
|
| 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/editor-page.php
CHANGED
|
@@ -266,6 +266,29 @@ function ame_output_sort_buttons($icons) {
|
|
| 266 |
</div>
|
| 267 |
|
| 268 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
$hint_id = 'ws_sidebar_pro_ad';
|
| 270 |
$show_pro_benefits = !apply_filters('admin_menu_editor_is_pro', false) && (!isset($editor_data['show_hints'][$hint_id]) || $editor_data['show_hints'][$hint_id]);
|
| 271 |
|
| 266 |
</div>
|
| 267 |
|
| 268 |
<?php
|
| 269 |
+
if ( apply_filters('admin_menu_editor-show_general_box', false) ) :
|
| 270 |
+
$is_general_box_open = true;
|
| 271 |
+
if ( isset($_COOKIE['ame_vis_box_open']) ) {
|
| 272 |
+
$is_general_box_open = ($_COOKIE['ame_vis_box_open'] === '1');
|
| 273 |
+
}
|
| 274 |
+
$box_class = $is_general_box_open ? '' : 'closed';
|
| 275 |
+
|
| 276 |
+
?>
|
| 277 |
+
<div class="clear"></div>
|
| 278 |
+
<div class="metabox-holder">
|
| 279 |
+
<div class="postbox ws_ame_custom_postbox <?php echo $box_class; ?>" id="ws_ame_general_vis_box">
|
| 280 |
+
<button type="button" class="handlediv button-link">
|
| 281 |
+
<span class="toggle-indicator"></span>
|
| 282 |
+
</button>
|
| 283 |
+
<h2 class="hndle">General</h2>
|
| 284 |
+
<div class="inside">
|
| 285 |
+
<?php do_action('admin_menu_editor-general_box'); ?>
|
| 286 |
+
</div>
|
| 287 |
+
</div>
|
| 288 |
+
</div>
|
| 289 |
+
<?php
|
| 290 |
+
endif;
|
| 291 |
+
|
| 292 |
$hint_id = 'ws_sidebar_pro_ad';
|
| 293 |
$show_pro_benefits = !apply_filters('admin_menu_editor_is_pro', false) && (!isset($editor_data['show_hints'][$hint_id]) || $editor_data['show_hints'][$hint_id]);
|
| 294 |
|
includes/menu-editor-core.php
CHANGED
|
@@ -202,6 +202,8 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
|
|
| 202 |
'index.php?page=nf-changelog' => true,
|
| 203 |
'index.php?page=nf-getting-started' => true,
|
| 204 |
'index.php?page=nf-credits' => true,
|
|
|
|
|
|
|
| 205 |
);
|
| 206 |
|
| 207 |
//AJAXify screen options
|
|
@@ -407,7 +409,10 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
|
|
| 407 |
//Make a placeholder for our screen options (hacky)
|
| 408 |
add_meta_box("ws-ame-screen-options", "[AME placeholder]", '__return_false', $page);
|
| 409 |
}
|
| 410 |
-
|
|
|
|
|
|
|
|
|
|
| 411 |
//Store the "original" menus for later use in the editor
|
| 412 |
$this->default_wp_menu = $menu;
|
| 413 |
$this->default_wp_submenu = $submenu;
|
|
@@ -3148,6 +3153,46 @@ class WPMenuEditor extends MenuEd_ShadowPluginFramework {
|
|
| 3148 |
}
|
| 3149 |
}
|
| 3150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3151 |
/**
|
| 3152 |
* Compatibility fix for WordPress Mu Domain Mapping 0.5.4.3.
|
| 3153 |
*
|
| 202 |
'index.php?page=nf-changelog' => true,
|
| 203 |
'index.php?page=nf-getting-started' => true,
|
| 204 |
'index.php?page=nf-credits' => true,
|
| 205 |
+
//All in One SEO Pack 2.3.9.2
|
| 206 |
+
'index.php?page=aioseop-about' => true,
|
| 207 |
);
|
| 208 |
|
| 209 |
//AJAXify screen options
|
| 409 |
//Make a placeholder for our screen options (hacky)
|
| 410 |
add_meta_box("ws-ame-screen-options", "[AME placeholder]", '__return_false', $page);
|
| 411 |
}
|
| 412 |
+
|
| 413 |
+
//Compatibility fix for the WooCommerce order count bubble. Must be run before storing or processing $submenu.
|
| 414 |
+
$this->apply_woocommerce_order_count_fix();
|
| 415 |
+
|
| 416 |
//Store the "original" menus for later use in the editor
|
| 417 |
$this->default_wp_menu = $menu;
|
| 418 |
$this->default_wp_submenu = $submenu;
|
| 3153 |
}
|
| 3154 |
}
|
| 3155 |
|
| 3156 |
+
/**
|
| 3157 |
+
* Compatibility fix for WooCommerce 2.6.8+.
|
| 3158 |
+
*
|
| 3159 |
+
* Summary: The "WooCommerce -> Orders" menu item includes an info bubble showing the number of new orders.
|
| 3160 |
+
* When AME is active, this number doesn't show up. This workaround re-adds the info bubble.
|
| 3161 |
+
*
|
| 3162 |
+
* For some inexplicable reason, WooCommerce first creates the "Orders" menu item without the info bubble.
|
| 3163 |
+
* Then it adds the number of new orders later by modifying the global $submenu array in a separate "admin_head"
|
| 3164 |
+
* hook. However, by that time AME has already processed the admin menu, so it doesn't see the change.
|
| 3165 |
+
*
|
| 3166 |
+
* Workaround: Run the relevant WooCommerce callback during the "admin_menu" action (before processing the menu).
|
| 3167 |
+
* The now-redundant"admin_head" hook is then removed.
|
| 3168 |
+
*/
|
| 3169 |
+
private function apply_woocommerce_order_count_fix() {
|
| 3170 |
+
global $wp_filter;
|
| 3171 |
+
if ( !class_exists('WC_Admin_Menus', false) || !isset($wp_filter['admin_head'][10]) || did_action('admin_head') ) {
|
| 3172 |
+
return;
|
| 3173 |
+
}
|
| 3174 |
+
|
| 3175 |
+
//Find the WooCommerce callback that adds order count to the menu.
|
| 3176 |
+
//It's the menu_order_count method defined in /woocommerce/includes/admin/class-wc-admin-menus.php.
|
| 3177 |
+
foreach($wp_filter['admin_head'][10] as $key => $filter) {
|
| 3178 |
+
if (!isset($filter['function']) || !is_array($filter['function'])) {
|
| 3179 |
+
continue;
|
| 3180 |
+
}
|
| 3181 |
+
|
| 3182 |
+
$callback = $filter['function'];
|
| 3183 |
+
if (
|
| 3184 |
+
(count($callback) === 2)
|
| 3185 |
+
&& ($callback[1] === 'menu_order_count')
|
| 3186 |
+
&& (get_class($callback[0]) === 'WC_Admin_Menus')
|
| 3187 |
+
) {
|
| 3188 |
+
//Run it now, not in admin_head.
|
| 3189 |
+
call_user_func($callback);
|
| 3190 |
+
remove_action('admin_head', $callback, 10);
|
| 3191 |
+
break;
|
| 3192 |
+
}
|
| 3193 |
+
}
|
| 3194 |
+
}
|
| 3195 |
+
|
| 3196 |
/**
|
| 3197 |
* Compatibility fix for WordPress Mu Domain Mapping 0.5.4.3.
|
| 3198 |
*
|
includes/menu.php
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
abstract class ameMenu {
|
| 3 |
const format_name = 'Admin Menu Editor menu';
|
| 4 |
-
const format_version = '
|
| 5 |
|
| 6 |
/**
|
| 7 |
* Load an admin menu from a JSON string.
|
|
@@ -121,6 +121,27 @@ abstract class ameMenu {
|
|
| 121 |
}
|
| 122 |
}
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
return $menu;
|
| 125 |
}
|
| 126 |
|
| 1 |
<?php
|
| 2 |
abstract class ameMenu {
|
| 3 |
const format_name = 'Admin Menu Editor menu';
|
| 4 |
+
const format_version = '7.0';
|
| 5 |
|
| 6 |
/**
|
| 7 |
* Load an admin menu from a JSON string.
|
| 121 |
}
|
| 122 |
}
|
| 123 |
|
| 124 |
+
//Copy component visibility.
|
| 125 |
+
if ( isset($arr['component_visibility']) ) {
|
| 126 |
+
$visibility = array();
|
| 127 |
+
|
| 128 |
+
foreach(array('toolbar', 'adminMenu') as $component) {
|
| 129 |
+
if (
|
| 130 |
+
isset($arr['component_visibility'][$component])
|
| 131 |
+
&& is_array($arr['component_visibility'][$component])
|
| 132 |
+
&& !empty($arr['component_visibility'][$component])
|
| 133 |
+
) {
|
| 134 |
+
//Expected: actorId => boolean.
|
| 135 |
+
$visibility[$component] = array();
|
| 136 |
+
foreach($arr['component_visibility'][$component] as $actorId => $allow) {
|
| 137 |
+
$visibility[$component][strval($actorId)] = (bool)($allow);
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
$menu['component_visibility'] = $visibility;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
return $menu;
|
| 146 |
}
|
| 147 |
|
js/actor-manager.ts
CHANGED
|
@@ -73,7 +73,6 @@ class AmeRole extends AmeBaseActor {
|
|
| 73 |
this.name = roleId;
|
| 74 |
}
|
| 75 |
|
| 76 |
-
|
| 77 |
hasOwnCap(capability: string): boolean {
|
| 78 |
//In WordPress, a role name is also a capability name. Users that have the role "foo" always
|
| 79 |
//have the "foo" capability. It's debatable whether the role itself actually has that capability
|
| 73 |
this.name = roleId;
|
| 74 |
}
|
| 75 |
|
|
|
|
| 76 |
hasOwnCap(capability: string): boolean {
|
| 77 |
//In WordPress, a role name is also a capability name. Users that have the role "foo" always
|
| 78 |
//have the "foo" capability. It's debatable whether the role itself actually has that capability
|
js/menu-editor.js
CHANGED
|
@@ -266,7 +266,7 @@ function loadMenuConfiguration(adminMenu) {
|
|
| 266 |
//There are some menu properties that need to be objects, but PHP JSON-encodes empty associative
|
| 267 |
//arrays as numeric arrays. We want them to be empty objects instead.
|
| 268 |
if (adminMenu.hasOwnProperty('color_presets') && !$.isPlainObject(adminMenu.color_presets)) {
|
| 269 |
-
adminMenu.
|
| 270 |
}
|
| 271 |
|
| 272 |
var objectProperties = ['grant_access', 'hidden_from_actor'];
|
|
@@ -295,6 +295,10 @@ function loadMenuConfiguration(adminMenu) {
|
|
| 295 |
//Load capabilities.
|
| 296 |
AmeCapabilityManager.setGrantedCapabilities(_.get(adminMenu, 'granted_capabilities', {}));
|
| 297 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
//Display the new admin menu.
|
| 299 |
outputWpMenu(adminMenu.tree);
|
| 300 |
}
|
|
@@ -1301,6 +1305,11 @@ function updateItemEditor(containerNode) {
|
|
| 1301 |
|
| 1302 |
setInputValue(input, displayValue);
|
| 1303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1304 |
if (typeof (knownMenuFields[fieldName].visible) === 'function') {
|
| 1305 |
var isFieldVisible = knownMenuFields[fieldName].visible(menuItem, fieldName);
|
| 1306 |
if (isFieldVisible) {
|
|
@@ -1555,7 +1564,8 @@ function readMenuTreeState(){
|
|
| 1555 |
return {
|
| 1556 |
tree: tree,
|
| 1557 |
color_presets: $.extend(true, {}, colorPresets),
|
| 1558 |
-
granted_capabilities: AmeCapabilityManager.getGrantedCapabilities()
|
|
|
|
| 1559 |
};
|
| 1560 |
}
|
| 1561 |
|
|
@@ -1946,6 +1956,9 @@ var ws_paste_count = 0;
|
|
| 1946 |
var colorPresets = {},
|
| 1947 |
wasPresetDropdownPopulated = false;
|
| 1948 |
|
|
|
|
|
|
|
|
|
|
| 1949 |
//Combined DOM-ready event handler.
|
| 1950 |
var isDomReadyDone = false;
|
| 1951 |
|
|
@@ -2137,6 +2150,7 @@ function ameOnDomReady() {
|
|
| 2137 |
var menuItem = containerNode.data('menu_item');
|
| 2138 |
|
| 2139 |
var oldValue = menuItem[fieldName];
|
|
|
|
| 2140 |
var value = getInputValue(input);
|
| 2141 |
var defaultValue = getDefaultValue(menuItem, fieldName, null, containerNode);
|
| 2142 |
var hasADefaultValue = (defaultValue !== null);
|
|
@@ -2152,7 +2166,7 @@ function ameOnDomReady() {
|
|
| 2152 |
}
|
| 2153 |
|
| 2154 |
//Ignore changes where the new value is the same as the old one.
|
| 2155 |
-
if (value === oldValue) {
|
| 2156 |
return;
|
| 2157 |
}
|
| 2158 |
|
|
@@ -3828,8 +3842,11 @@ function ameOnDomReady() {
|
|
| 3828 |
//Populate source/destination lists.
|
| 3829 |
sourceActorList.find('option').not('[disabled]').remove();
|
| 3830 |
destinationActorList.find('option').not('[disabled]').remove();
|
| 3831 |
-
$.each(
|
| 3832 |
-
var option = $('<option>', {
|
|
|
|
|
|
|
|
|
|
| 3833 |
sourceActorList.append(option);
|
| 3834 |
destinationActorList.append(option.clone());
|
| 3835 |
});
|
|
@@ -3878,6 +3895,8 @@ function ameOnDomReady() {
|
|
| 3878 |
}
|
| 3879 |
});
|
| 3880 |
|
|
|
|
|
|
|
| 3881 |
//If the user is currently looking at the destination actor, force the UI to refresh
|
| 3882 |
//so that they can see the new permissions.
|
| 3883 |
if (actorSelectorWidget.selectedActor === destinationActor) {
|
|
@@ -4473,6 +4492,110 @@ function ameOnDomReady() {
|
|
| 4473 |
});
|
| 4474 |
}
|
| 4475 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4476 |
/******************************************************************
|
| 4477 |
Tooltips and hints
|
| 4478 |
******************************************************************/
|
| 266 |
//There are some menu properties that need to be objects, but PHP JSON-encodes empty associative
|
| 267 |
//arrays as numeric arrays. We want them to be empty objects instead.
|
| 268 |
if (adminMenu.hasOwnProperty('color_presets') && !$.isPlainObject(adminMenu.color_presets)) {
|
| 269 |
+
adminMenu.color_presets = {};
|
| 270 |
}
|
| 271 |
|
| 272 |
var objectProperties = ['grant_access', 'hidden_from_actor'];
|
| 295 |
//Load capabilities.
|
| 296 |
AmeCapabilityManager.setGrantedCapabilities(_.get(adminMenu, 'granted_capabilities', {}));
|
| 297 |
|
| 298 |
+
//Load general menu visibility.
|
| 299 |
+
generalComponentVisibility = _.get(adminMenu, 'component_visibility', {});
|
| 300 |
+
AmeEditorApi.refreshComponentVisibility();
|
| 301 |
+
|
| 302 |
//Display the new admin menu.
|
| 303 |
outputWpMenu(adminMenu.tree);
|
| 304 |
}
|
| 1305 |
|
| 1306 |
setInputValue(input, displayValue);
|
| 1307 |
|
| 1308 |
+
//Store the value to help with change detection.
|
| 1309 |
+
if (input.length > 0) {
|
| 1310 |
+
$.data(input.get(0), 'ame_last_display_value', displayValue);
|
| 1311 |
+
}
|
| 1312 |
+
|
| 1313 |
if (typeof (knownMenuFields[fieldName].visible) === 'function') {
|
| 1314 |
var isFieldVisible = knownMenuFields[fieldName].visible(menuItem, fieldName);
|
| 1315 |
if (isFieldVisible) {
|
| 1564 |
return {
|
| 1565 |
tree: tree,
|
| 1566 |
color_presets: $.extend(true, {}, colorPresets),
|
| 1567 |
+
granted_capabilities: AmeCapabilityManager.getGrantedCapabilities(),
|
| 1568 |
+
component_visibility: $.extend(true, {}, generalComponentVisibility)
|
| 1569 |
};
|
| 1570 |
}
|
| 1571 |
|
| 1956 |
var colorPresets = {},
|
| 1957 |
wasPresetDropdownPopulated = false;
|
| 1958 |
|
| 1959 |
+
//General admin menu visibility.
|
| 1960 |
+
var generalComponentVisibility = {};
|
| 1961 |
+
|
| 1962 |
//Combined DOM-ready event handler.
|
| 1963 |
var isDomReadyDone = false;
|
| 1964 |
|
| 2150 |
var menuItem = containerNode.data('menu_item');
|
| 2151 |
|
| 2152 |
var oldValue = menuItem[fieldName];
|
| 2153 |
+
var oldDisplayValue = $.data(this, 'ame_last_display_value');
|
| 2154 |
var value = getInputValue(input);
|
| 2155 |
var defaultValue = getDefaultValue(menuItem, fieldName, null, containerNode);
|
| 2156 |
var hasADefaultValue = (defaultValue !== null);
|
| 2166 |
}
|
| 2167 |
|
| 2168 |
//Ignore changes where the new value is the same as the old one.
|
| 2169 |
+
if ((value === oldValue) || (value === oldDisplayValue)) {
|
| 2170 |
return;
|
| 2171 |
}
|
| 2172 |
|
| 3842 |
//Populate source/destination lists.
|
| 3843 |
sourceActorList.find('option').not('[disabled]').remove();
|
| 3844 |
destinationActorList.find('option').not('[disabled]').remove();
|
| 3845 |
+
$.each(actorSelectorWidget.getVisibleActors(), function(index, actor) {
|
| 3846 |
+
var option = $('<option>', {
|
| 3847 |
+
val: actor.id,
|
| 3848 |
+
text: actorSelectorWidget.getNiceName(actor)
|
| 3849 |
+
});
|
| 3850 |
sourceActorList.append(option);
|
| 3851 |
destinationActorList.append(option.clone());
|
| 3852 |
});
|
| 3895 |
}
|
| 3896 |
});
|
| 3897 |
|
| 3898 |
+
//todo: copy granted permissions like CPTs.
|
| 3899 |
+
|
| 3900 |
//If the user is currently looking at the destination actor, force the UI to refresh
|
| 3901 |
//so that they can see the new permissions.
|
| 3902 |
if (actorSelectorWidget.selectedActor === destinationActor) {
|
| 4492 |
});
|
| 4493 |
}
|
| 4494 |
|
| 4495 |
+
/******************************************************************
|
| 4496 |
+
Component visibility settings
|
| 4497 |
+
******************************************************************/
|
| 4498 |
+
|
| 4499 |
+
var $generalVisBox = $('#ws_ame_general_vis_box'),
|
| 4500 |
+
$showAdminMenu = $('#ws_ame_show_admin_menu'),
|
| 4501 |
+
$showWpToolbar = $('#ws_ame_show_toolbar');
|
| 4502 |
+
|
| 4503 |
+
AmeEditorApi.actorCanSeeComponent = function(component, actorId) {
|
| 4504 |
+
if (actorId === null) {
|
| 4505 |
+
return _.some(actorSelectorWidget.getVisibleActors(), function(actor) {
|
| 4506 |
+
return AmeEditorApi.actorCanSeeComponent(component, actor.id);
|
| 4507 |
+
});
|
| 4508 |
+
}
|
| 4509 |
+
|
| 4510 |
+
var actorSpecificSetting = _.get(generalComponentVisibility, [component, actorId], null);
|
| 4511 |
+
if (actorSpecificSetting !== null) {
|
| 4512 |
+
return actorSpecificSetting;
|
| 4513 |
+
}
|
| 4514 |
+
|
| 4515 |
+
//Super Admin can see everything by default.
|
| 4516 |
+
if (actorId === AmeSuperAdmin.permanentActorId) {
|
| 4517 |
+
return _.get(generalComponentVisibility, [component, AmeSuperAdmin.permanentActorId], true);
|
| 4518 |
+
}
|
| 4519 |
+
|
| 4520 |
+
var actor = AmeActors.getActor(actorId);
|
| 4521 |
+
if (actor instanceof AmeUser) {
|
| 4522 |
+
var grants = _.get(generalComponentVisibility, component, {});
|
| 4523 |
+
|
| 4524 |
+
//Super Admin has priority.
|
| 4525 |
+
if (actor.isSuperAdmin) {
|
| 4526 |
+
return AmeEditorApi.actorCanSeeComponent(component, AmeSuperAdmin.permanentActorId);
|
| 4527 |
+
}
|
| 4528 |
+
|
| 4529 |
+
//The user can see the admin menu/Toolbar if at least one of their roles can see it.
|
| 4530 |
+
var result = null;
|
| 4531 |
+
_.forEach(actor.roles, function(roleName) {
|
| 4532 |
+
var allow = _.get(grants, 'role:' + roleName, true);
|
| 4533 |
+
if (result === null) {
|
| 4534 |
+
result = allow;
|
| 4535 |
+
} else {
|
| 4536 |
+
result = result || allow;
|
| 4537 |
+
}
|
| 4538 |
+
});
|
| 4539 |
+
|
| 4540 |
+
if (result !== null) {
|
| 4541 |
+
return result;
|
| 4542 |
+
}
|
| 4543 |
+
}
|
| 4544 |
+
|
| 4545 |
+
//Everyone can see the admin menu and the Toolbar by default.
|
| 4546 |
+
return true;
|
| 4547 |
+
};
|
| 4548 |
+
|
| 4549 |
+
AmeEditorApi.refreshComponentVisibility = function() {
|
| 4550 |
+
if ($generalVisBox.length < 1) {
|
| 4551 |
+
return;
|
| 4552 |
+
}
|
| 4553 |
+
|
| 4554 |
+
var actorId = actorSelectorWidget.selectedActor;
|
| 4555 |
+
$showAdminMenu.prop('checked', AmeEditorApi.actorCanSeeComponent('adminMenu', actorId));
|
| 4556 |
+
$showWpToolbar.prop('checked', AmeEditorApi.actorCanSeeComponent('toolbar', actorId));
|
| 4557 |
+
};
|
| 4558 |
+
|
| 4559 |
+
AmeEditorApi.setComponentVisibility = function(section, actorId, enabled) {
|
| 4560 |
+
if (actorId === null) {
|
| 4561 |
+
_.forEach(actorSelectorWidget.getVisibleActors(), function(actor) {
|
| 4562 |
+
_.set(generalComponentVisibility, [section, actor.id], enabled);
|
| 4563 |
+
});
|
| 4564 |
+
} else {
|
| 4565 |
+
_.set(generalComponentVisibility, [section, actorId], enabled);
|
| 4566 |
+
}
|
| 4567 |
+
};
|
| 4568 |
+
|
| 4569 |
+
if ($generalVisBox.length > 0) {
|
| 4570 |
+
$showAdminMenu.click(function() {
|
| 4571 |
+
AmeEditorApi.setComponentVisibility(
|
| 4572 |
+
'adminMenu',
|
| 4573 |
+
actorSelectorWidget.selectedActor,
|
| 4574 |
+
$(this).is(':checked')
|
| 4575 |
+
);
|
| 4576 |
+
});
|
| 4577 |
+
$showWpToolbar.click(function () {
|
| 4578 |
+
AmeEditorApi.setComponentVisibility(
|
| 4579 |
+
'toolbar',
|
| 4580 |
+
actorSelectorWidget.selectedActor,
|
| 4581 |
+
$(this).is(':checked')
|
| 4582 |
+
);
|
| 4583 |
+
});
|
| 4584 |
+
|
| 4585 |
+
$generalVisBox.find('.handlediv').click(function() {
|
| 4586 |
+
$generalVisBox.toggleClass('closed');
|
| 4587 |
+
$.cookie(
|
| 4588 |
+
'ame_vis_box_open',
|
| 4589 |
+
($generalVisBox.hasClass('closed') ? '0' : '1'),
|
| 4590 |
+
{ expires: 90 }
|
| 4591 |
+
);
|
| 4592 |
+
});
|
| 4593 |
+
|
| 4594 |
+
actorSelectorWidget.onChange(function() {
|
| 4595 |
+
AmeEditorApi.refreshComponentVisibility();
|
| 4596 |
+
});
|
| 4597 |
+
}
|
| 4598 |
+
|
| 4599 |
/******************************************************************
|
| 4600 |
Tooltips and hints
|
| 4601 |
******************************************************************/
|
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.7.
|
| 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.7.3
|
| 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: 4.1
|
| 6 |
-
Tested up to: 4.
|
| 7 |
-
Stable tag: 1.7.
|
| 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,12 @@ Plugins installed in the `mu-plugins` directory are treated as "always on", so y
|
|
| 63 |
|
| 64 |
== Changelog ==
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
= 1.7.2 =
|
| 67 |
* Added capability suggestions and access preview to the "Extra capability" dropdown.
|
| 68 |
* The plugin now remembers the last selected menu item and re-selects it after you save changes.
|
| 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.7
|
| 7 |
+
Stable tag: 1.7.3
|
| 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.7.3 =
|
| 67 |
+
* Fixed a bug where closing the menu properties of a custom menu item could set "extra capability" to "read".
|
| 68 |
+
* Added a workaround for WooCommerce 2.6.8 to display the number of new orders in the "Orders" menu title.
|
| 69 |
+
* Minor cosmetic changes.
|
| 70 |
+
* Tested with WP 4.7 and 4.8-alpha.
|
| 71 |
+
|
| 72 |
= 1.7.2 =
|
| 73 |
* Added capability suggestions and access preview to the "Extra capability" dropdown.
|
| 74 |
* The plugin now remembers the last selected menu item and re-selects it after you save changes.
|
