diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f37782..216ef6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,15 @@ # Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased](https://github.com/bueltge/Adminimize/compare/1.10.4...HEAD) +## [Unreleased](https://github.com/bueltge/Adminimize/compare/1.10.5...HEAD) +* + +## [1.10.4](https://github.com/bueltge/Adminimize/compare/1.10.4...1.10.5) - 2016-06-28 ### Fixed * Fix PHP Warning * Fix check for active usage of Link Manager * Fix menu var type, if is object. +* Check for multiple roles on Menu Settings, that it works only, if the option is still active on each role of this user. ## [1.10.4](https://github.com/bueltge/Adminimize/compare/1.10.3...1.10.4) - 2016-06-03 ### Added diff --git a/adminimize.php b/adminimize.php index aea250e..3ecf60d 100755 --- a/adminimize.php +++ b/adminimize.php @@ -7,13 +7,13 @@ * Description: Visually compresses the administrative meta-boxes so that more admin page content can be initially seen. The plugin that lets you hide 'unnecessary' items from the WordPress administration menu, for all roles of your install. You can also hide post meta controls on the edit-area to simplify the interface. It is possible to simplify the admin in different for all roles. * Author: Frank Bültge * Author URI: http://bueltge.de/ - * Version: 1.10.5-dev + * Version: 1.10.5 * License: GPLv3+ * * @package WordPress * @author Frank Bültge * @license http://opensource.org/licenses/gpl-license.php GNU Public License - * @version 22016-06-24 + * @version 22016-06-28 */ /** @@ -22,6 +22,7 @@ * of differently user-right and a user-friendly range in admin-area via reduce areas. * :( grmpf i have so much wishes and hints form users, there use the plugin and * it is not easy to development this on my free time. + * Also I hate the source, old and harrd to maintain, no OOP. */ if ( ! function_exists( 'add_action' ) ) { @@ -581,9 +582,12 @@ function _mw_adminimize_set_menu_option() { _mw_adminimize_debug( $menu, 'Adminimize, WordPress Menu:' ); _mw_adminimize_debug( $submenu, 'Adminimize, WordPress Sub-Menu:' ); - $user_roles = _mw_adminimize_get_all_user_roles(); + //$user_roles = _mw_adminimize_get_all_user_roles(); $disabled_menu_ = array(); $disabled_submenu_ = array(); + $user = wp_get_current_user(); + $user_roles = $user->roles; + _mw_adminimize_debug( $user, 'Adminimize, Current User:' ); foreach ( $user_roles as $role ) { $disabled_menu_[ $role ] = (array) _mw_adminimize_get_option_value( @@ -596,8 +600,6 @@ function _mw_adminimize_set_menu_option() { $mw_adminimize_menu = array(); $mw_adminimize_submenu = array(); - $user = wp_get_current_user(); - _mw_adminimize_debug( $user, 'Adminimize, Current User:' ); // Set admin-menu. foreach ( $user_roles as $role ) { @@ -605,7 +607,7 @@ function _mw_adminimize_set_menu_option() { if ( in_array( $role, $user->roles, FALSE ) && _mw_adminimize_current_user_has_role( $role ) ) { - // Create array about all items with all affected roles, important for multiple roles. + // Create array about all items with all affected roles. foreach ( $disabled_menu_[ $role ] as $menu_item ) { $mw_adminimize_menu[] = $menu_item; } @@ -617,12 +619,17 @@ function _mw_adminimize_set_menu_option() { } // Support Multiple Roles for users. + // Leave only the items, there are active on each roles of the users. if ( _mw_adminimize_get_option_value( 'mw_adminimize_multiple_roles' ) && 1 < count( $user->roles ) ) { - $mw_adminimize_menu = _mw_adminimize_get_duplicate( $mw_adminimize_menu ); - $mw_adminimize_submenu = _mw_adminimize_get_duplicate( $mw_adminimize_submenu ); + $mw_adminimize_menu = _mw_adminimize_get_intersection( $disabled_menu_ ); + $mw_adminimize_submenu = _mw_adminimize_get_intersection( $disabled_submenu_ ); + } else { + // Alternative filter the array to remove duplicates, much faster. + $mw_adminimize_menu = array_unique( $mw_adminimize_menu ); + $mw_adminimize_submenu = array_unique( $mw_adminimize_submenu ); } - _mw_adminimize_debug( $mw_adminimize_menu, 'Adminimize, Settings Menu:' ); - _mw_adminimize_debug( $mw_adminimize_submenu, 'Adminimize, Settings Sub-Menu:' ); + _mw_adminimize_debug( $mw_adminimize_menu, 'Adminimize, Menu Slugs to hide after Filter.' ); + _mw_adminimize_debug( $mw_adminimize_menu, 'Adminimize, Sub-Menu Slugs to hide after Filter.' ); // Fallback on users.php on all user roles smaller admin. if ( in_array( 'users.php', $mw_adminimize_menu, FALSE ) ) { diff --git a/inc-setup/helping_hands.php b/inc-setup/helping_hands.php index 24c4ca6..78466e9 100644 --- a/inc-setup/helping_hands.php +++ b/inc-setup/helping_hands.php @@ -91,9 +91,9 @@ function _mw_adminimize_debug( $data, $description = '' ) { // Buffering to solve problems with WP core, header() etc. ob_start(); - $output = 'console.info(' . json_encode( $description ) . ');'; + $output = 'console.info(' . json_encode( $description ) . ');'; $output .= 'console.log(' . json_encode( $data ) . ');'; - $output = sprintf( '', $output ); + $output = sprintf( '', $output ); echo $output; } @@ -111,3 +111,17 @@ function _mw_adminimize_get_duplicate( $array ) { array_diff_assoc( $array, array_unique( $array ) ) ); } + +/** + * Get intersection of a multiple array. + * + * @since 2016-06-28 + * + * @param $array array Array with settings of all roles. + * + * @return array Data with only the data, there in each role active. + */ +function _mw_adminimize_get_intersection( $array ) { + + return (array) call_user_func_array( 'array_intersect', $array ); +} \ No newline at end of file diff --git a/package.json b/package.json index ad69ba3..06ad2a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Adminimize", - "version": "1.10.1", + "version": "1.10.5", "repository": { "type": "git", "url": "git@github.com:bueltge/Adminimize.git" diff --git a/readme.txt b/readme.txt index 3689f0e..278db2a 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: Bueltge, inpsyde Donate link: https://www.paypal.me/FrankBueltge Tags: color, scheme, theme, admin, dashboard, color scheme, plugin, interface, ui, metabox, hide, editor, minimal, menu, customization, interface, administration, lite, light, usability, lightweight, layout, zen Requires at least: 4.0 -Tested up to: 4.5.2 -Stable tag: 1.10.4 +Tested up to: 4.5.3 +Stable tag: 1.10.5 Adminimize that lets you hide 'unnecessary' items from the WordPress backend @@ -43,6 +43,12 @@ Use the installer via back-end of your install or ... 1. Settings area in WP 4.5-alpha == Changelog == += 1.10.5 (2016-06-28) = +* Fix PHP Warning +* Fix check for active usage of Link Manager +* Fix menu var type, if is object. +* Check for multiple roles on Menu Settings, that it works only, if the option is still active on each role of this user. + = 1.10.4 (2016-06-03) = * Add support for multiple roles to remove the Admin Bar via global options. * Add support for multiple roles to remove the Admin Bar Back end items.