Plugin Directory

Changeset 1436433


Ignore:
Timestamp:
06/14/2016 01:41:30 PM (10 years ago)
Author:
scriptrunner
Message:

Added whitelist option for site administrator

Location:
wp-admin-no-show/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-admin-no-show/trunk/readme.txt

    r1329746 r1436433  
    44Tags: admin bar, admin menu, dashboard, disable, remove, hide
    55Requires at least: 3.1
    6 Tested up to: 4.4.1
    7 Stable tag: 1.6.3
     6Tested up to: 4.5.2
     7Stable tag: 1.7.0
    88License: MIT License
    99License URI: http://www.opensource.org/licenses/mit-license.php
     
    4040== Changelog ==
    4141
     42= 1.7.0 =
     43* Added whitelist setting. This is currently only for site administrator for cases where adminstrator may also have a secondary role that is blacklisted. This may be expanded to allow all roles to be whitelisted.
     44
    4245= 1.6.3 =
    43 * Updated "Tested up to"
     46* Updated "Tested up to."
    4447
    4548= 1.6.2 =
  • wp-admin-no-show/trunk/wp-admin-no-show.php

    r1329746 r1436433  
    44Plugin URI: http://www.dougsparling.org
    55Description: Efectively blocks admin portion of site for selected user roles. Any attempt to manually navigate to wp-admin section of site and user will be redirected to selected site page. Hides admin bar.
    6 Version: 1.6.3
     6Version: 1.7.0
    77Author: Doug Sparling
    88Author URI: http://www.dougsparling.org
    99License: MIT License - http://www.opensource.org/licenses/mit-license.php
    1010
    11 Copyright (c) 2012-2015 Doug Sparling
     11Copyright (c) 2012-2016 Doug Sparling
    1212Based on WP Hide Dashboard plugin by Kim Parsell and Admin Bar Disabler plugin by Scott Kingsley Clark
    1313
     
    5252    }
    5353
     54    // Check if user has a whitelisted role - site administrator only choice for now...
     55    $whitelist_roles = get_option( 'wp_admin_no_show_whitelist_roles', array() );
     56    if ( !empty( $whitelist_roles ) ) {
     57        if ( !is_array( $whitelist_roles ) ) {
     58            $whitelist_roles = array( $whitelist_roles );
     59        }
     60        foreach ( $whitelist_roles as $role ) {
     61            if ( wp_admin_no_show_check_user_role( $role ) ) {
     62                return;
     63            }
     64        }
     65    }
     66
    5467    if ( 'none' == get_option( 'wp_admin_no_show_redirect_type' ) ) {
    5568        return;
     
    111124    }
    112125
     126    // Check if user has a whitelisted role - site administrator only choice for now...
     127    $whitelist_roles = get_option( 'wp_admin_no_show_whitelist_roles', array() );
     128    if ( !empty( $whitelist_roles ) ) {
     129        if ( !is_array( $whitelist_roles ) ) {
     130            $whitelist_roles = array( $whitelist_roles );
     131        }
     132        foreach ( $whitelist_roles as $role ) {
     133            if ( wp_admin_no_show_check_user_role( $role ) ) {
     134                return;
     135            }
     136        }
     137    }
     138
    113139    $blacklist_roles = get_option( 'wp_admin_no_show_blacklist_roles', array() );
    114140    if ( false === $disable && !empty( $blacklist_roles ) ) {
     
    116142            $blacklist_roles = array( $blacklist_roles );
    117143        }
     144
    118145        foreach ( $blacklist_roles as $role ) {
    119146            if ( wp_admin_no_show_check_user_role( $role ) ) {
     
    163190function wp_admin_no_show_register_settings() {
    164191    register_setting( 'wp-admin-no-show-settings-group', 'wp_admin_no_show_blacklist_roles' );
     192    register_setting( 'wp-admin-no-show-settings-group', 'wp_admin_no_show_whitelist_roles' );
    165193    register_setting( 'wp-admin-no-show-settings-group', 'wp_admin_no_show_redirect_type' );
    166194    register_setting( 'wp-admin-no-show-settings-group', 'wp_admin_no_show_redirect_page' );
     
    190218                    <?php
    191219                    $blacklist_roles = get_option( 'wp_admin_no_show_blacklist_roles', array() );
    192                     if ( !is_array( $blacklist_roles ) )
     220                    if ( !is_array( $blacklist_roles ) ) {
    193221                        $blacklist_roles = array( $blacklist_roles );
     222                    }
    194223                    foreach ( $roles as $role => $name ) {
    195224                        if (preg_match("/administrator/i", $role )) {
     
    250279                        </ul>
    251280                        <em><?php _e( 'Redirect only applies to non-administrator blacklisted roles.<br />', 'wp-admin-no-show' ); ?></em>
    252                         <em><?php _e( 'Multisite super admin is whitelisted.', 'wp-admin-no-show' ); ?></em>
    253281                    </fieldset>
    254282                </td>
    255283            </tr>
    256284            <?php endif; ?>
     285
     286            <tr>
     287                <td>
     288                    <h3>User roles you want to whitelist</h3>
     289                    <?php
     290                    $whitelist_roles = get_option( 'wp_admin_no_show_whitelist_roles', array() );
     291                    if ( !is_array( $whitelist_roles ) ) {
     292                        $whitelist_roles = array( $whitelist_roles );
     293                    }
     294                    foreach ( $roles as $role => $name ) {
     295                // Only allow site administrator to be whitelisted for now.
     296                        if (! preg_match("/administrator/i", $role )) {
     297                            continue;
     298                        }
     299                    ?>
     300<input name="wp_admin_no_show_whitelist_roles[]" type="checkbox" id="<?php echo 'wp_admin_no_show_whitelist_role_' . $role; ?>" value="<?php echo $role; ?>" <?php checked('1', in_array( $role, $whitelist_roles )); ?> />
     301<label for="<?php echo 'wp_admin_no_show_whitelist_role_' . $role; ?>"><?php _e($name); ?></label>
     302<br />
     303                    <?php
     304                        }
     305                    ?>
     306            <br />
     307                    <em><?php _e( 'Multisite super admin is always whitelisted.', 'wp-admin-no-show' ); ?></em>
     308            <br />
     309                    <em><?php _e( 'Whitelist site administrator if user has a secondary role that is blacklisted.', 'wp-admin-no-show' ); ?></em>
     310                </td>
     311            </tr>
    257312
    258313        </table>
Note: See TracChangeset for help on using the changeset viewer.