| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Adminimize |
| 4 |
* @subpackage Backend Theme options |
| 5 |
* @author Frank Bültge |
| 6 |
*/ |
| 7 |
if ( ! function_exists( 'add_action' ) ) { |
| 8 |
echo "Hi there! I'm just a part of plugin, not much I can do when called directly."; |
| 9 |
exit; |
| 10 |
} |
| 11 |
?> |
| 12 |
<div id="poststuff" class="ui-sortable meta-box-sortables"> |
| 13 |
<div class="postbox"> |
| 14 |
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'adminimize' ); ?>"><br /></div> |
| 15 |
<h3 class="hndle" id="set_theme" title="<?php esc_attr_e( 'Click to toggle', 'adminimize' ); ?>"><?php |
| 16 |
esc_attr_e( 'Set Theme', 'adminimize' ) ?></h3> |
| 17 |
|
| 18 |
<div class="inside"> |
| 19 |
<br class="clear" /> |
| 20 |
|
| 21 |
<?php if ( ! isset( $_POST[ '_mw_adminimize_action' ] ) || ! ( $_POST[ '_mw_adminimize_action' ] === '_mw_adminimize_load_theme' ) ) { ?> |
| 22 |
<form name="set_theme" method="post" id="_mw_adminimize_set_theme" action="?page=<?php echo esc_attr( |
| 23 |
$_GET[ 'page' ] |
| 24 |
); ?>"> |
| 25 |
<?php wp_nonce_field( 'mw_adminimize_nonce' ); ?> |
| 26 |
<p><?php esc_attr_e( |
| 27 |
'For better peformance on sites with many users, you should load userlist data before making any changes in the theme options for users.', |
| 28 |
'adminimize' |
| 29 |
); ?></p> |
| 30 |
|
| 31 |
<p id="submitbutton"> |
| 32 |
<input type="hidden" name="_mw_adminimize_action" value="_mw_adminimize_load_theme" /> |
| 33 |
<input type="submit" name="_mw_adminimize_load" value="<?php esc_attr_e( |
| 34 |
'Load User Data', 'adminimize' |
| 35 |
); ?> »" class="button button-primary" /> |
| 36 |
</p> |
| 37 |
</form> |
| 38 |
<?php } |
| 39 |
if ( isset( $_POST[ '_mw_adminimize_action' ] ) && ( $_POST[ '_mw_adminimize_action' ] === '_mw_adminimize_load_theme' ) ) { ?> |
| 40 |
<form name="set_theme" method="post" id="_mw_adminimize_set_theme" action="?page=<?php echo esc_attr( |
| 41 |
$_GET[ 'page' ] |
| 42 |
); ?>"> |
| 43 |
<?php wp_nonce_field( 'mw_adminimize_nonce' ); ?> |
| 44 |
<table class="widefat usertheme"> |
| 45 |
<thead> |
| 46 |
<tr class="thead"> |
| 47 |
<th class="num"> </th> |
| 48 |
<th class="num"><?php esc_attr_e( 'User-ID', 'adminimize' ) ?></th> |
| 49 |
<th><?php esc_attr_e( 'Username', 'adminimize' ) ?></th> |
| 50 |
<th><?php esc_attr_e( 'Display name publicly as', 'adminimize' ) ?></th> |
| 51 |
<th><?php esc_attr_e( 'Admin Color Scheme', 'adminimize' ) ?></th> |
| 52 |
<th><?php esc_attr_e( 'User Level', 'adminimize' ) ?></th> |
| 53 |
<th><?php esc_attr_e( 'Role', 'adminimize' ) ?></th> |
| 54 |
</tr> |
| 55 |
</thead> |
| 56 |
<tbody id="users" class="list:user user-list"> |
| 57 |
<?php |
| 58 |
/** @var \WPDB $wpdb */ |
| 59 |
$wp_user_search = (array) $wpdb->get_results( |
| 60 |
"SELECT ID, user_login, display_name FROM $wpdb->users ORDER BY ID" |
| 61 |
); |
| 62 |
|
| 63 |
foreach ( $wp_user_search as $userid ) { |
| 64 |
$user_id = (int) $userid->ID; |
| 65 |
$user_login = stripslashes( $userid->user_login ); |
| 66 |
$display_name = stripslashes( $userid->display_name ); |
| 67 |
$current_color = get_user_option( 'admin_color', $user_id ); |
| 68 |
$user_level = (int) get_user_option( $table_prefix . 'user_level', $user_id ); |
| 69 |
$user_object = new WP_User( $user_id ); |
| 70 |
$roles = $user_object->roles; |
| 71 |
$role = array_shift( $roles ); |
| 72 |
/** @var \WP_Roles $wp_roles */ |
| 73 |
$role_name = ''; |
| 74 |
if ( isset( $wp_roles->role_names[ $role ] ) ) { |
| 75 |
$role_name = $wp_roles->role_names[ $role ]; |
| 76 |
} |
| 77 |
|
| 78 |
if ( function_exists( 'translate_user_role' ) ) { |
| 79 |
$role_name = translate_user_role( $role_name ); |
| 80 |
} elseif ( function_exists( 'before_last_bar' ) ) { |
| 81 |
$role_name = before_last_bar( $role_name ); |
| 82 |
} else { |
| 83 |
$role_name = strrpos( $role_name, '|' ); |
| 84 |
} |
| 85 |
|
| 86 |
$return = ''; |
| 87 |
$return .= '<tr>' . "\n"; |
| 88 |
$return .= "\t" . '<td class="num"><input type="checkbox" name="mw_adminimize_theme_items[]" value="' . $user_id . '" /></td>' . "\n"; |
| 89 |
$return .= "\t" . '<td class="num">' . $user_id . '</td>' . "\n"; |
| 90 |
$return .= "\t" . '<td>' . $user_login . '</td>' . "\n"; |
| 91 |
$return .= "\t" . '<td>' . $display_name . '</td>' . "\n"; |
| 92 |
$return .= "\t" . '<td>' . $current_color . '</td>' . "\n"; |
| 93 |
$return .= "\t" . '<td class="num">' . $user_level . '</td>' . "\n"; |
| 94 |
$return .= "\t" . '<td>' . $role_name . '</td>' . "\n"; |
| 95 |
$return .= '</tr>' . "\n"; |
| 96 |
|
| 97 |
echo $return; |
| 98 |
} |
| 99 |
?> |
| 100 |
<tr valign="top"> |
| 101 |
<td class="num"> </td> |
| 102 |
<td class="num"> </td> |
| 103 |
<td> </td> |
| 104 |
<td> </td> |
| 105 |
<td> |
| 106 |
<label for="_mw_adminimize_set_theme"></label> |
| 107 |
<select id="_mw_adminimize_set_theme" name="_mw_adminimize_set_theme"> |
| 108 |
<?php /** @var array $_wp_admin_css_colors */ |
| 109 |
foreach ( $_wp_admin_css_colors as $color => $color_info ): ?> |
| 110 |
<option value="<?php echo $color; ?>"><?php echo $color_info->name . ' (' . $color . ')' ?></option> |
| 111 |
<?php endforeach; ?> |
| 112 |
</select> |
| 113 |
</td> |
| 114 |
<td> </td> |
| 115 |
<td> </td> |
| 116 |
</tr> |
| 117 |
</tbody> |
| 118 |
</table> |
| 119 |
<p id="submitbutton"> |
| 120 |
<input type="hidden" name="_mw_adminimize_action" value="_mw_adminimize_set_theme" /> |
| 121 |
<input type="hidden" name="_mw_adminimize_load" value="_mw_adminimize_load_theme" /> |
| 122 |
<input type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e( |
| 123 |
'Set Theme', 'adminimize' |
| 124 |
); ?> »" class="button button-primary" /> |
| 125 |
</p> |
| 126 |
</form> |
| 127 |
<?php } ?> |
| 128 |
|
| 129 |
<p> |
| 130 |
<a class="alignright button" href="javascript:void(0);" onclick="window.scrollTo(0,0);" style="margin:3px 0 0 30px;"><?php esc_attr_e( |
| 131 |
'scroll to top', 'adminimize' |
| 132 |
); ?></a><br class="clear" /></p> |
| 133 |
</div> |
| 134 |
</div> |
| 135 |
</div> |
| 136 |
|