Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bueltge/Adminimize
Browse files Browse the repository at this point in the history
  • Loading branch information
bueltge committed Jul 15, 2020
2 parents b84fd3f + b363262 commit 295040e
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 3 deletions.
55 changes: 55 additions & 0 deletions adminimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,11 @@ function _mw_adminimize_on_load_page() {

$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

wp_enqueue_style( 'select2-style', plugins_url( 'css/select2' . $suffix . '.css', __FILE__ ), [], false );
wp_register_style( 'adminimize-style', plugins_url( 'css/style' . $suffix . '.css', __FILE__ ) );
wp_enqueue_style( 'adminimize-style' );

wp_enqueue_script( 'select2-script', plugins_url( 'js/select2' . $suffix . '.js', __FILE__ ), array( 'jquery' ),'',false );
wp_register_script(
'adminimize-settings-script',
plugins_url( 'js/adminimize' . $suffix . '.js', __FILE__ ),
Expand Down Expand Up @@ -1273,6 +1275,10 @@ function _mw_adminimize_update_option( $options ) {
return FALSE;
}

if ( _mw_adminimize_is_roles_options_import( $options ) ){
$options = _mw_adminimize_roles_complete_options( $options );
}

// Remove slashes always.
foreach ( $options as $key => $value ) {
$options[ $key ] = stripslashes_deep( $value );
Expand Down Expand Up @@ -1772,3 +1778,52 @@ function _mw_adminimize_install() {
}
wp_cache_add( 'mw_adminimize', $adminimizeoptions );
}

/**
* Make sure adminimize option is complete when a role json file is imported
*
* @param array $roles_options
*
* @return array
*/
function _mw_adminimize_roles_complete_options( $roles_options ){

$adminimizeoption = _mw_adminimize_get_option_value();

foreach ( $roles_options as $role_option_name => $role_option_value ){
$adminimizeoption[$role_option_name] = $role_option_value;
}

return $adminimizeoption;
}

/**
* Check if options comes from roles adminimize settings export
*
* @param array $options
*
* @return bool
*/
function _mw_adminimize_is_roles_options_import( $options ){
global $wp_roles;

$roles_options = [];
foreach ( $wp_roles->role_names as $role_slug => $role_name ){

$role_options = array_filter(
$options, function ( $option_key ) use ( $role_slug ) {
return stripos( $option_key, '_' . $role_slug ) !== false;
}, ARRAY_FILTER_USE_KEY
);

if ( empty( $roles_options ) ){
$roles_options = $role_options;
} else {
$roles_options = array_merge( $roles_options, $role_options );
}
}

if ( count( $options ) === count( $roles_options ) ){
return true;
}
}
1 change: 1 addition & 0 deletions css/select2.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,57 @@ table.usertheme .num {

table.config_menu span.awaiting-mod{
display: none;
}

#adminimize-toggle{
border-width: 0;
color: #777;
cursor: not-allowed;
}

.switch {
position: relative;
display: inline-block;
width: 40px;
height: 20px;
background-color: #dedede;
border-radius: 20px;
}

.switch:after {
content: "";
position: absolute;
width: 18px;
height: 18px;
border-radius: 50%;
background-color: #fff;
top: 1px;
left: 1px;
-webkit-transition: all .3s;
transition: all .3s;
}

.adminimize-checkbox:checked + .switch::after {
left : 20px;
}

.adminimize-checkbox:checked + .switch {
background-color: #0d84e3;
}

.adminimize-checkbox {
visibility: hidden;
}

#adminimize-export-role {
display: none;
align-items: flex-end;
}

#adminimize-export-role select {
display: block;
}

#adminimize-export-role option {
padding: 5px;
}
2 changes: 1 addition & 1 deletion css/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 295040e

Please sign in to comment.