Changeset 1436433
- Timestamp:
- 06/14/2016 01:41:30 PM (10 years ago)
- Location:
- wp-admin-no-show/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
wp-admin-no-show.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-admin-no-show/trunk/readme.txt
r1329746 r1436433 4 4 Tags: admin bar, admin menu, dashboard, disable, remove, hide 5 5 Requires at least: 3.1 6 Tested up to: 4. 4.17 Stable tag: 1. 6.36 Tested up to: 4.5.2 7 Stable tag: 1.7.0 8 8 License: MIT License 9 9 License URI: http://www.opensource.org/licenses/mit-license.php … … 40 40 == Changelog == 41 41 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 42 45 = 1.6.3 = 43 * Updated "Tested up to "46 * Updated "Tested up to." 44 47 45 48 = 1.6.2 = -
wp-admin-no-show/trunk/wp-admin-no-show.php
r1329746 r1436433 4 4 Plugin URI: http://www.dougsparling.org 5 5 Description: 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.36 Version: 1.7.0 7 7 Author: Doug Sparling 8 8 Author URI: http://www.dougsparling.org 9 9 License: MIT License - http://www.opensource.org/licenses/mit-license.php 10 10 11 Copyright (c) 2012-201 5Doug Sparling11 Copyright (c) 2012-2016 Doug Sparling 12 12 Based on WP Hide Dashboard plugin by Kim Parsell and Admin Bar Disabler plugin by Scott Kingsley Clark 13 13 … … 52 52 } 53 53 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 54 67 if ( 'none' == get_option( 'wp_admin_no_show_redirect_type' ) ) { 55 68 return; … … 111 124 } 112 125 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 113 139 $blacklist_roles = get_option( 'wp_admin_no_show_blacklist_roles', array() ); 114 140 if ( false === $disable && !empty( $blacklist_roles ) ) { … … 116 142 $blacklist_roles = array( $blacklist_roles ); 117 143 } 144 118 145 foreach ( $blacklist_roles as $role ) { 119 146 if ( wp_admin_no_show_check_user_role( $role ) ) { … … 163 190 function wp_admin_no_show_register_settings() { 164 191 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' ); 165 193 register_setting( 'wp-admin-no-show-settings-group', 'wp_admin_no_show_redirect_type' ); 166 194 register_setting( 'wp-admin-no-show-settings-group', 'wp_admin_no_show_redirect_page' ); … … 190 218 <?php 191 219 $blacklist_roles = get_option( 'wp_admin_no_show_blacklist_roles', array() ); 192 if ( !is_array( $blacklist_roles ) ) 220 if ( !is_array( $blacklist_roles ) ) { 193 221 $blacklist_roles = array( $blacklist_roles ); 222 } 194 223 foreach ( $roles as $role => $name ) { 195 224 if (preg_match("/administrator/i", $role )) { … … 250 279 </ul> 251 280 <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>253 281 </fieldset> 254 282 </td> 255 283 </tr> 256 284 <?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> 257 312 258 313 </table>
Note: See TracChangeset
for help on using the changeset viewer.