Ticket #12295: 12295.4.diff

File 12295.4.diff, 13.0 KB (added by JustinSainton, 6 months ago)
Line 
1Index: wp-admin/user-edit.php
2===================================================================
3--- wp-admin/user-edit.php      (revision 22397)
4+++ wp-admin/user-edit.php      (working copy)
5@@ -194,57 +194,75 @@
6 <?php if ( $wp_http_referer ) : ?>
7        <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" />
8 <?php endif; ?>
9-<p>
10+
11 <input type="hidden" name="from" value="profile" />
12 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
13-</p>
14 
15-<h3><?php _e('Personal Options'); ?></h3>
16+<?php
17+$user_personal_options = _wp_get_user_personal_options( $user_can_edit );
18 
19+if ( ! empty( $user_personal_options ) ) { ?>
20+
21+<div id="profile-personal-options">
22+       <h3 id="profile-personal-options-title"><?php _e( 'Personal Options' ); ?></h3>
23+
24 <table class="form-table">
25-<?php if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) : // don't bother showing the option if the editor has been removed ?>
26-       <tr>
27-               <th scope="row"><?php _e('Visual Editor')?></th>
28-               <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked('false', $profileuser->rich_editing); ?> /> <?php _e('Disable the visual editor when writing'); ?></label></td>
29-       </tr>
30-<?php endif; ?>
31-<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
32-<tr>
33-<th scope="row"><?php _e('Admin Color Scheme')?></th>
34-<td><?php do_action( 'admin_color_scheme_picker' ); ?></td>
35+
36+<?php
37+       foreach ( $user_personal_options as $code ) {
38+?>
39+<tr id="profile-personal-options-<?php echo esc_attr( $code['name'] ); ?>">
40+       <th<?php echo esc_attr( $code['scope'] ); ?>>
41+               <label for="<?php echo esc_attr( $code['name'] ); ?>"><?php echo apply_filters( 'user_' . $code['name'] . '_label', esc_html( $code['desc'] ) ); ?></label>
42+       </th>
43+       <td>
44+               <?php
45+                       if ( 'admin_color_scheme_picker' == $code['code'] )
46+                               do_action( 'admin_color_scheme_picker' );
47+                       else
48+                               echo $code['code'];
49+               ?>
50+       </td>
51 </tr>
52 <?php
53-endif; // $_wp_admin_css_colors
54-if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
55-<tr>
56-<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
57-<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" target="_blank">More information</a>'); ?></td>
58-</tr>
59-<?php endif; ?>
60-<tr class="show-admin-bar">
61-<th scope="row"><?php _e('Toolbar')?></th>
62-<td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend>
63-<label for="admin_bar_front">
64-<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
65-<?php _e( 'Show Toolbar when viewing site' ); ?></label><br />
66-</fieldset>
67-</td>
68-</tr>
69+       } //end foreach
70+?>
71 <?php do_action('personal_options', $profileuser); ?>
72 </table>
73 <?php
74        if ( IS_PROFILE_PAGE )
75                do_action('profile_personal_options', $profileuser);
76 ?>
77+</div><!-- #profile-personal-options -->
78 
79-<h3><?php _e('Name') ?></h3>
80+<?php
81+} //end if empty
82 
83-<table class="form-table">
84-       <tr>
85-               <th><label for="user_login"><?php _e('Username'); ?></label></th>
86-               <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td>
87-       </tr>
88+// For backwards compatibility
89+function user_label_add_required( $desc ) {
90+       return $desc . ' <span class="description">' . __( '(required)' ) . '</span>';
91+}
92+add_filter( 'user_user_email_label', 'user_label_add_required' );
93+add_filter( 'user_nickname_label', 'user_label_add_required' );
94+$user_namefields = _wp_get_user_namefields();
95 
96+if ( ! empty( $user_namefields ) ) { ?>
97+<div id="profile-name">
98+       <h3 id="profile-name-title"><?php _e( 'Name' ) ?></h3>
99+
100+       <table class="form-table">
101+
102+       <?php
103+       foreach ( $user_namefields as $name => $desc ) {
104+               ?>
105+               <tr id="profile-name-<?php echo esc_attr( $name ); ?>">
106+                       <th><label for="<?php echo esc_attr( $name ); ?>"><?php echo apply_filters( 'user_' . $name . '_label', esc_html( $desc ) ); ?></label></th>
107+                       <td><input type="text" name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
108+               </tr>
109+               <?php
110+       } //end foreach
111+       ?>
112+
113 <?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?>
114 <tr><th><label for="role"><?php _e('Role') ?></label></th>
115 <td><select name="role" id="role">
116@@ -264,35 +282,9 @@
117        echo '<option value="" selected="selected">' . __('&mdash; No role for this site &mdash;') . '</option>';
118 ?>
119 </select></td></tr>
120-<?php endif; //!IS_PROFILE_PAGE
121+<?php endif; //!IS_PROFILE_PAGE ?>
122 
123-if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
124-<tr><th><?php _e('Super Admin'); ?></th>
125-<td>
126-<?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?>
127-<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
128-<?php else : ?>
129-<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
130-<?php endif; ?>
131-</td></tr>
132-<?php } ?>
133-
134-<tr>
135-       <th><label for="first_name"><?php _e('First Name') ?></label></th>
136-       <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td>
137-</tr>
138-
139-<tr>
140-       <th><label for="last_name"><?php _e('Last Name') ?></label></th>
141-       <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
142-</tr>
143-
144-<tr>
145-       <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
146-       <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
147-</tr>
148-
149-<tr>
150+<tr id="profile-name-display-name">
151        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
152        <td>
153                <select name="display_name" id="display_name">
154@@ -328,11 +320,17 @@
155        </td>
156 </tr>
157 </table>
158+</div><!-- #profile-name-display-name -->
159 
160+<?php   
161+} //end if not empty
162+?>
163+
164+<div id="profile-contact">
165 <h3><?php _e('Contact Info') ?></h3>
166 
167 <table class="form-table">
168-<tr>
169+<tr id="profile-contact-email">
170        <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
171        <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" />
172        <?php
173@@ -345,37 +343,39 @@
174        </td>
175 </tr>
176 
177-<tr>
178+<tr id="profile-contact-website">
179        <th><label for="url"><?php _e('Website') ?></label></th>
180        <td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td>
181 </tr>
182 
183 <?php
184-       foreach (_wp_get_user_contactmethods( $profileuser ) as $name => $desc) {
185+       foreach ( _wp_get_user_contactmethods( $profileuser ) as $name => $desc ) {
186 ?>
187-<tr>
188-       <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
189-       <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
190+<tr id="profile-contact-<?php echo esc_attr( $name ); ?>">
191+       <th><label for="<?php echo esc_attr( $name ); ?>"><?php echo apply_filters( 'user_'.$name.'_label', esc_html( $desc ) ); ?></label></th>
192+       <td><input type="text" name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $profileuser->$name ) ?>" class="regular-text" /></td>
193 </tr>
194 <?php
195        }
196 ?>
197 </table>
198+</div><!-- #profile-contact -->
199 
200+<div id="profile-about">
201 <h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
202 
203 <table class="form-table">
204-<tr>
205+<tr id="profile-about-description">
206        <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
207        <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea><br />
208        <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
209 </tr>
210 
211 <?php
212-$show_password_fields = apply_filters('show_password_fields', true, $profileuser);
213+$show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
214 if ( $show_password_fields ) :
215 ?>
216-<tr id="password">
217+<tr id="profile-about-password">
218        <th><label for="pass1"><?php _e('New Password'); ?></label></th>
219        <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?></span><br />
220                <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("Type your new password again."); ?></span><br />
221@@ -385,6 +385,7 @@
222 </tr>
223 <?php endif; ?>
224 </table>
225+</div><!-- #profile-about -->
226 
227 <?php
228        if ( IS_PROFILE_PAGE )
229Index: wp-includes/user.php
230===================================================================
231--- wp-includes/user.php        (revision 22397)
232+++ wp-includes/user.php        (working copy)
233@@ -1541,3 +1541,77 @@
234        );
235        return apply_filters( 'user_contactmethods', $user_contactmethods, $user );
236 }
237+
238+/**
239+ * Setup the default name fields
240+ *
241+ * @access private
242+ * @since 3.5.0
243+ *
244+ * @return array $user_namefields Array of contact methods and their labels.
245+ */
246+function _wp_get_user_namefields() {
247+       $user_namefields = array(
248+               'user_login' => __( 'Username' ),
249+               'first_name' => __( 'First Name' ),
250+               'last_name'  => __( 'Last Name' ),
251+               'nickname'   => __( 'Nickname' ),
252+       );
253+       return apply_filters( 'user_namefields', $user_namefields );
254+}
255+
256+/**
257+ * Setup the default personal options
258+ *
259+ * @access private
260+ * @since 3.5.0
261+ *
262+ * @param bool $user_can_edit True if user has edit_posts or edit_pages cap
263+ * @return array $user_personal_options Array of personal options and their input code
264+ */
265+function _wp_get_user_personal_options( $user_can_edit ) {
266+       global $user_id;
267+       $profileuser = get_user_to_edit( $user_id );
268+
269+       if ( rich_edit_exists() && ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) { // don't bother showing the option if the editor has been removed
270+               $user_personal_options['rich_editing'] = array(
271+                       'name'  => 'rich_editing',
272+                       'desc'  => __( 'Visual Editor' ),
273+                       'code'  => '<label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" ' . checked( 'false', $profileuser->rich_editing, false ) . ' /> ' . __( 'Disable the visual editor when writing' ) . '</label>',
274+                       'scope' => ' scope="row"'
275+               );
276+       }
277+
278+       global $_wp_admin_css_colors;
279+       if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) {
280+               $user_personal_options['admin_color_scheme_picker'] = array(
281+                       'name'  => 'admin_color_scheme_picker',
282+                       'desc'  => __( 'Admin Color Scheme' ),
283+                       'code'  => 'admin_color_scheme_picker',
284+                       'scope' => ' scope="row"'
285+               );
286+       }
287+
288+       if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) {
289+               if ( ! empty( $profileuser->comment_shortcuts ) )
290+                       $checked = checked( 'true', $profileuser->comment_shortcuts, false );
291+               $user_personal_options['comment_shortcuts'] = array(
292+                       'name' => 'rich_editing',
293+                       'desc' => __( 'Keyboard Shortcuts' ),
294+                       'code' => '<label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" ' . $checked . ' /> ' . __( 'Enable keyboard shortcuts for comment moderation.' ) . '</label> ' . __( '<a href="http://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>' )
295+               );
296+       }
297+
298+       $user_personal_options['admin_bar'] = array(
299+               'name' => 'show-admin-bar',
300+               'desc' => __( 'Show Toolbar' ),
301+               'code' => '<fieldset><legend class="screen-reader-text"><span>' . __( 'Show Toolbar' ) . '</span></legend>
302+<label for="admin_bar_front">
303+       <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1" ' . checked( '1', _get_admin_bar_pref( 'front', $profileuser->ID ), false ) . ' />' . __( 'when viewing site' ) . '</label><br />
304+<label for="admin_bar_admin">
305+       <input name="admin_bar_admin" type="checkbox" id="admin_bar_admin" value="1" ' . checked( '1', _get_admin_bar_pref( 'admin', $profileuser->ID ), false ) . ' />' . __( 'in dashboard' ) . '</label>',
306+               'scope' => ' scope="row"'
307+       );
308+
309+       return apply_filters( 'user_personal_options', $user_personal_options );
310+}