| | 1 | <?php |
| | 2 | /** |
| | 3 | * User advanced form for inclusion in the administration panels. |
| | 4 | * |
| | 5 | * @package WordPress |
| | 6 | * @subpackage Administration |
| | 7 | */ |
| | 8 | |
| | 9 | // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). |
| | 10 | |
| | 11 | /** |
| | 12 | * Display user submit form fields. |
| | 13 | * |
| | 14 | * @since 2.8.0 |
| | 15 | * |
| | 16 | * @param object $user |
| | 17 | */ |
| | 18 | function user_submit_meta_box($profileuser) { |
| | 19 | ?> |
| | 20 | <div class="submitbox" id="submituser"> |
| | 21 | <div id="minor-publishing"> |
| | 22 | <div id="misc-publishing-actions"> |
| | 23 | <br /><br /> |
| | 24 | </div> |
| | 25 | <div id="minor-publishing-actions"> |
| | 26 | |
| | 27 | </div> |
| | 28 | <div class="clear"></div> |
| | 29 | </div> |
| | 30 | <div id="major-publishing-actions"> |
| | 31 | <div id="delete-action"> |
| | 32 | </div> |
| | 33 | <div id="publishing-action"> |
| | 34 | <input type="submit" class="button-primary" value="<?php _e('Update'); ?>" /> |
| | 35 | </div> |
| | 36 | <div class="clear"></div> |
| | 37 | </div> |
| | 38 | </div> |
| | 39 | <?php |
| | 40 | } |
| | 41 | add_meta_box('submitdiv', $is_profile_page? __('Update Profile') : __('Update User'), 'user_submit_meta_box', $screen, 'side', 'core'); |
| | 42 | |
| | 43 | /** |
| | 44 | * Display user personal options form fields. |
| | 45 | * |
| | 46 | * @since 2.8.0 |
| | 47 | * |
| | 48 | * @param object $user |
| | 49 | */ |
| | 50 | function user_personal_options_meta_box($profileuser) { |
| | 51 | global $_wp_admin_css_colors; |
| | 52 | ?> |
| | 53 | <div class="personal_options_box" id="personal_options_user"> |
| | 54 | <table class="form-table"> |
| | 55 | <?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?> |
| | 56 | <tr> |
| | 57 | <th scope="row"> |
| | 58 | <?php _e('Visual Editor')?> |
| | 59 | </th> |
| | 60 | <td> |
| | 61 | <label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked('false', $profileuser->rich_editing); ?> /> |
| | 62 | <?php _e('Disable the visual editor when writing'); ?> |
| | 63 | </label> |
| | 64 | </td> |
| | 65 | </tr> |
| | 66 | <?php endif; ?> |
| | 67 | <?php if (count($_wp_admin_css_colors) > 1 ) : ?> |
| | 68 | <tr> |
| | 69 | <th scope="row"><?php _e('Admin Color Scheme')?></th> |
| | 70 | <td><fieldset><legend class="hidden"><?php _e('Admin Color Scheme')?></legend> |
| | 71 | <?php |
| | 72 | $current_color = get_user_option('admin_color', $user_id); |
| | 73 | if ( empty($current_color) ) |
| | 74 | $current_color = 'fresh'; |
| | 75 | foreach ( $_wp_admin_css_colors as $color => $color_info ): ?> |
| | 76 | <div class="color-option"><input name="admin_color" id="admin_color_<?php echo $color; ?>" type="radio" value="<?php echo $color ?>" class="tog" <?php checked($color, $current_color); ?> /> |
| | 77 | <table class="color-palette"> |
| | 78 | <tr> |
| | 79 | <?php foreach ( $color_info->colors as $html_color ): ?> |
| | 80 | <td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>"> </td> |
| | 81 | <?php endforeach; ?> |
| | 82 | </tr> |
| | 83 | </table> |
| | 84 | |
| | 85 | <label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label> |
| | 86 | </div> |
| | 87 | <?php endforeach; ?> |
| | 88 | </fieldset></td> |
| | 89 | </tr> |
| | 90 | <tr> |
| | 91 | <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> |
| | 92 | <td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation. '); ?></label><?php _e('<a href="http://codex.wordpress.org/Keyboard_Shortcuts">More information</a>'); ?></td> |
| | 93 | </tr> |
| | 94 | <?php |
| | 95 | endif; |
| | 96 | do_action('personal_options', $profileuser); |
| | 97 | ?> |
| | 98 | </table> |
| | 99 | <?php |
| | 100 | $is_profile_page = ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE ) ? true : false; |
| | 101 | if ( $is_profile_page ) |
| | 102 | do_action('profile_personal_options', $profileuser); |
| | 103 | ?> |
| | 104 | |
| | 105 | </div> |
| | 106 | <?php |
| | 107 | } |
| | 108 | add_meta_box('personal_options_div', __('Personal Options'), 'user_personal_options_meta_box', $screen, 'normal', 'core'); |
| | 109 | |
| | 110 | /** |
| | 111 | * Display user contact info form fields. |
| | 112 | * |
| | 113 | * @since 2.8.0 |
| | 114 | * |
| | 115 | * @param object $user |
| | 116 | */ |
| | 117 | function user_contact_infos_meta_box($profileuser) { |
| | 118 | ?> |
| | 119 | <div class="contact_infos_box" id="contact_infos_user"> |
| | 120 | <table class="form-table"> |
| | 121 | <tr> |
| | 122 | <th><label for="email"><?php _e('E-mail') ?></label></th> |
| | 123 | <td><input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" class="regular-text" /><br /><span class='setting-description'><?php _e('Required.');?></span></td> |
| | 124 | </tr> |
| | 125 | |
| | 126 | <tr> |
| | 127 | <th><label for="url"><?php _e('Website') ?></label></th> |
| | 128 | <td><input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" class="regular-text code" /></td> |
| | 129 | </tr> |
| | 130 | |
| | 131 | <tr> |
| | 132 | <th><label for="aim"><?php echo apply_filters('user_aim_label', __('AIM')); ?></label></th> |
| | 133 | <td><input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" class="regular-text" /></td> |
| | 134 | </tr> |
| | 135 | |
| | 136 | <tr> |
| | 137 | <th><label for="yim"><?php echo apply_filters('user_yim_label', __('Yahoo IM')); ?></label></th> |
| | 138 | <td><input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" class="regular-text" /></td> |
| | 139 | </tr> |
| | 140 | |
| | 141 | <tr> |
| | 142 | <th><label for="jabber"><?php echo apply_filters('user_jabber_label', __('Jabber / Google Talk')); ?></label></th> |
| | 143 | <td><input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" class="regular-text" /></td> |
| | 144 | </tr> |
| | 145 | </table> |
| | 146 | </div> |
| | 147 | <?php |
| | 148 | } |
| | 149 | add_meta_box('contact_infos_div', __('Contact Info'), 'user_contact_infos_meta_box', $screen, 'normal', 'core'); |
| | 150 | |
| | 151 | /** |
| | 152 | * Display user about yourself form fields. |
| | 153 | * |
| | 154 | * @since 2.8.0 |
| | 155 | * |
| | 156 | * @param object $user |
| | 157 | */ |
| | 158 | function user_about_yourself_meta_box($profileuser) { |
| | 159 | ?> |
| | 160 | <div class="about_yourself_box" id="about_yourself_user"> |
| | 161 | <table class="form-table"> |
| | 162 | <tr> |
| | 163 | <th><label for="description"><?php _e('Biographical Info'); ?></label></th> |
| | 164 | <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea><br /><span class='setting-description'><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td> |
| | 165 | </tr> |
| | 166 | </table> |
| | 167 | </div> |
| | 168 | <?php |
| | 169 | } |
| | 170 | add_meta_box('about_yourself_div', $is_profile_page? __('About Yourself') : __('About the user'), 'user_about_yourself_meta_box', $screen, 'normal', 'core'); |
| | 171 | |
| | 172 | /** |
| | 173 | * Display user Additional Capabilities form fields. |
| | 174 | * |
| | 175 | * @since 2.8.0 |
| | 176 | * |
| | 177 | * @param object $user |
| | 178 | */ |
| | 179 | function user_additional_capabilities_meta_box($profileuser) { |
| | 180 | ?> |
| | 181 | <div class="additional_capabilities_box" id="additional_capabilities_user"> |
| | 182 | <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform"> |
| | 183 | <tr> |
| | 184 | <th scope="row"><?php _e('Additional Capabilities') ?></th> |
| | 185 | <td><?php |
| | 186 | $output = ''; |
| | 187 | foreach($profileuser->caps as $cap => $value) { |
| | 188 | if(!$wp_roles->is_role($cap)) { |
| | 189 | if($output != '') $output .= ', '; |
| | 190 | $output .= $value ? $cap : "Denied: {$cap}"; |
| | 191 | } |
| | 192 | } |
| | 193 | echo $output; |
| | 194 | ?></td> |
| | 195 | </tr> |
| | 196 | </table> |
| | 197 | </div> |
| | 198 | <?php |
| | 199 | } |
| | 200 | if (count($profileuser->caps) > count($profileuser->roles) && apply_filters('additional_capabilities_display', true)) |
| | 201 | add_meta_box('additional_capabilities_div', __('Additional Capabilities'), 'user_additional_capabilities_meta_box', $screen, 'normal', 'core'); |
| | 202 | |
| | 203 | /** |
| | 204 | * Display user password form fields. |
| | 205 | * |
| | 206 | * @since 2.8.0 |
| | 207 | * |
| | 208 | * @param object $user |
| | 209 | */ |
| | 210 | function user_password_meta_box($profileuser) { |
| | 211 | $is_profile_page = ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE ) ? true : false; |
| | 212 | ?> |
| | 213 | <div class="password_box" id="password_user"> |
| | 214 | <table class="form-table"> |
| | 215 | <tr> |
| | 216 | <th><label for="pass1"><?php _e('Type a new one'); ?></label></th> |
| | 217 | <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /></td> |
| | 218 | </tr> |
| | 219 | <tr> |
| | 220 | <th><label for="pass2"><?php _e('Type again'); ?></label></th> |
| | 221 | <td><input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /></td> |
| | 222 | </tr> |
| | 223 | <?php if ( $is_profile_page ): ?> |
| | 224 | <tr> |
| | 225 | <th><div id="pass-strength-result"><?php _e('Strength indicator'); ?></div></th> |
| | 226 | <td><label for="pass2"><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).'); ?></label></td> |
| | 227 | </tr> |
| | 228 | <?php endif; ?> |
| | 229 | </table> |
| | 230 | </div> |
| | 231 | <?php |
| | 232 | } |
| | 233 | $show_password_fields = apply_filters('show_password_fields', true); |
| | 234 | if ( $show_password_fields ) |
| | 235 | add_meta_box('password_div', __('Change Password'), 'user_password_meta_box', $screen, 'side', 'core'); |
| | 236 | |
| | 237 | /** |
| | 238 | * Profile page starts here |
| | 239 | * |
| | 240 | * @since 2.8.0 |
| | 241 | * |
| | 242 | */ |
| | 243 | |
| | 244 | do_action('do_meta_boxes', $screen, 'normal', $profileuser); |
| | 245 | do_action('do_meta_boxes', $screen, 'side', $profileuser); |
| | 246 | |
| | 247 | include ('admin-header.php'); |
| | 248 | ?> |
| | 249 | <?php if ( isset($_GET['updated']) ) : ?> |
| | 250 | <div id="message" class="updated fade"> |
| | 251 | <p> |
| | 252 | <strong> |
| | 253 | <?php _e('User updated.') ?> |
| | 254 | </strong> |
| | 255 | </p> |
| | 256 | <?php if ( $wp_http_referer && !$is_profile_page ) : ?> |
| | 257 | <p> |
| | 258 | <a href="users.php"> |
| | 259 | <?php _e('← Back to Authors and Users'); ?> |
| | 260 | </a> |
| | 261 | </p> |
| | 262 | <?php endif; ?> |
| | 263 | </div> |
| | 264 | <?php endif; ?> |
| | 265 | <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?> |
| | 266 | <div class="error"> |
| | 267 | <ul> |
| | 268 | <?php foreach( $errors->get_error_messages() as $message ) echo "<li>$message</li>"; ?> |
| | 269 | </ul> |
| | 270 | </div> |
| | 271 | <?php endif; ?> |
| | 272 | <div class="wrap" id="profile-page"> |
| | 273 | <?php screen_icon(); ?> |
| | 274 | <h2><?php echo wp_specialchars( $title ); ?></h2> |
| | 275 | |
| | 276 | <form id="your-profile" action="" method="post"> |
| | 277 | <input type="hidden" name="action" value="update" /> |
| | 278 | <input type="hidden" name="from" value="profile" /> |
| | 279 | <input type="hidden" id="screen" value="<?php echo $screen; ?>" /> |
| | 280 | <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> |
| | 281 | <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" /> |
| | 282 | <?php if ( $wp_http_referer ) : ?> |
| | 283 | <input type="hidden" name="wp_http_referer" value="<?php echo clean_url($wp_http_referer); ?>" /> |
| | 284 | <?php endif; ?> |
| | 285 | <?php wp_nonce_field('update-user_' . $user_id) ?> |
| | 286 | <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
| | 287 | <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
| | 288 | |
| | 289 | <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>"> |
| | 290 | <div id="side-info-column" class="inner-sidebar"> |
| | 291 | <?php $side_meta_boxes = do_meta_boxes($screen, 'side', $profileuser); ?> |
| | 292 | </div> |
| | 293 | <div id="post-body"> |
| | 294 | <div id="post-body-content"> |
| | 295 | <table class="form-table"> |
| | 296 | <tr> |
| | 297 | <th><label for="user_login"><?php _e('Username'); ?></label></th> |
| | 298 | <td><input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" class="regular-text" /><br /><span class='setting-description'><?php _e('Your username cannot be changed.'); ?></span></td> |
| | 299 | </tr> |
| | 300 | <?php if ( !$is_profile_page ): ?> |
| | 301 | <tr> |
| | 302 | <th> |
| | 303 | <label for="role"> |
| | 304 | <?php _e('Role:') ?> |
| | 305 | </label> |
| | 306 | </th> |
| | 307 | <td> |
| | 308 | <select name="role" id="role"> |
| | 309 | <?php |
| | 310 | // Get the highest/primary role for this user |
| | 311 | // TODO: create a function that does this: wp_get_user_role() |
| | 312 | |
| | 313 | $user_roles = $profileuser->roles; |
| | 314 | $user_role = array_shift($user_roles); |
| | 315 | wp_dropdown_roles($user_role); |
| | 316 | |
| | 317 | // print the 'no role' option. Make it selected if the user has no role yet. |
| | 318 | if ( $user_role ) echo '<option value="">' . __('— No role for this blog —') . '</option>'; |
| | 319 | else echo '<option value="" selected="selected">' . __('— No role for this blog —') . '</option>'; |
| | 320 | ?> |
| | 321 | |
| | 322 | </select> |
| | 323 | </td> |
| | 324 | </tr> |
| | 325 | <?php endif; //!$is_profile_page ?> |
| | 326 | <tr> |
| | 327 | <th><label for="first_name"><?php _e('First name') ?></label></th> |
| | 328 | <td><input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" class="regular-text" /></td> |
| | 329 | </tr> |
| | 330 | <tr> |
| | 331 | <th><label for="last_name"><?php _e('Last name') ?></label></th> |
| | 332 | <td><input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" class="regular-text" /></td> |
| | 333 | </tr> |
| | 334 | <tr> |
| | 335 | <th><label for="nickname"><?php _e('Nickname') ?></label></th> |
| | 336 | <td><input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" class="regular-text" /></td> |
| | 337 | </tr> |
| | 338 | <tr> |
| | 339 | <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th> |
| | 340 | <td> |
| | 341 | <select name="display_name" id="display_name"> |
| | 342 | <?php |
| | 343 | $public_display = array(); |
| | 344 | $public_display['display_displayname'] = $profileuser->display_name; |
| | 345 | $public_display['display_nickname'] = $profileuser->nickname; |
| | 346 | $public_display['display_username'] = $profileuser->user_login; |
| | 347 | $public_display['display_firstname'] = $profileuser->first_name; |
| | 348 | $public_display['display_firstlast'] = $profileuser->first_name.' '.$profileuser->last_name; |
| | 349 | $public_display['display_lastfirst'] = $profileuser->last_name.' '.$profileuser->first_name; |
| | 350 | $public_display = array_unique(array_filter(array_map('trim', $public_display))); |
| | 351 | foreach($public_display as $id => $item) { |
| | 352 | ?> |
| | 353 | <option id="<?php echo $id; ?>" value="<?php echo $item; ?>"><?php echo $item; ?></option> |
| | 354 | <?php |
| | 355 | } |
| | 356 | ?> |
| | 357 | </select> |
| | 358 | </td> |
| | 359 | </tr> |
| | 360 | </table> |
| | 361 | <br /> |
| | 362 | <?php do_meta_boxes($screen, 'normal', $profileuser); ?> |
| | 363 | <?php |
| | 364 | if ( $is_profile_page ) { |
| | 365 | do_action('show_user_profile'); |
| | 366 | } else { |
| | 367 | do_action('edit_user_profile'); |
| | 368 | } |
| | 369 | ?> |
| | 370 | </div> |
| | 371 | </div> |
| | 372 | </div><!-- /poststuff --> |
| | 373 | </form> |
| | 374 | </div> |
| | 375 | No newline at end of file |