Issues (2010)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

wp-admin/user-edit.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Edit user administration panel.
4
 *
5
 * @package WordPress
6
 * @subpackage Administration
7
 */
8
9
/** WordPress Administration Bootstrap */
10
require_once( dirname( __FILE__ ) . '/admin.php' );
11
12
wp_reset_vars( array( 'action', 'user_id', 'wp_http_referer' ) );
13
14
$user_id = (int) $user_id;
15
$current_user = wp_get_current_user();
16
if ( ! defined( 'IS_PROFILE_PAGE' ) )
17
	define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) );
18
19
if ( ! $user_id && IS_PROFILE_PAGE )
20
	$user_id = $current_user->ID;
21
elseif ( ! $user_id && ! IS_PROFILE_PAGE )
22
	wp_die(__( 'Invalid user ID.' ) );
23
elseif ( ! get_userdata( $user_id ) )
24
	wp_die( __('Invalid user ID.') );
25
26
wp_enqueue_script('user-profile');
27
28
$title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User');
29
if ( current_user_can('edit_users') && !IS_PROFILE_PAGE )
30
	$submenu_file = 'users.php';
31
else
32
	$submenu_file = 'profile.php';
33
34
if ( current_user_can('edit_users') && !is_user_admin() )
35
	$parent_file = 'users.php';
36
else
37
	$parent_file = 'profile.php';
38
39
$profile_help = '<p>' . __('Your profile contains information about you (your &#8220;account&#8221;) as well as some personal options related to using WordPress.') . '</p>' .
40
	'<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.') . '</p>' .
41
	'<p>' . __('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.') . '</p>' .
42
	'<p>' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.' ) . '</p>' .
43
	'<p>' . __('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.') . '</p>' .
44
	'<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>';
45
46
get_current_screen()->add_help_tab( array(
47
	'id'      => 'overview',
48
	'title'   => __('Overview'),
49
	'content' => $profile_help,
50
) );
51
52
get_current_screen()->set_help_sidebar(
53
    '<p><strong>' . __('For more information:') . '</strong></p>' .
54
    '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen" target="_blank">Documentation on User Profiles</a>') . '</p>' .
55
    '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
56
);
57
58
$wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer );
59
60
$user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
61
62
/**
63
 * Filters whether to allow administrators on Multisite to edit every user.
64
 *
65
 * Enabling the user editing form via this filter also hinges on the user holding
66
 * the 'manage_network_users' cap, and the logged-in user not matching the user
67
 * profile open for editing.
68
 *
69
 * The filter was introduced to replace the EDIT_ANY_USER constant.
70
 *
71
 * @since 3.0.0
72
 *
73
 * @param bool $allow Whether to allow editing of any user. Default true.
74
 */
75
if ( is_multisite()
76
	&& ! current_user_can( 'manage_network_users' )
77
	&& $user_id != $current_user->ID
78
	&& ! apply_filters( 'enable_edit_any_user_configuration', true )
79
) {
80
	wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
81
}
82
83
// Execute confirmed email change. See send_confirmation_on_profile_email().
84
if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
85
	$new_email = get_user_meta( $current_user->ID, '_new_email', true );
86
	if ( $new_email && hash_equals( $new_email[ 'hash' ], $_GET[ 'newuseremail' ] ) ) {
87
		$user = new stdClass;
88
		$user->ID = $current_user->ID;
89
		$user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) );
90
		if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) {
91
			$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
92
		}
93
		wp_update_user( $user );
94
		delete_user_meta( $current_user->ID, '_new_email' );
95
		wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) );
96
		die();
97
	} else {
98
		wp_redirect( add_query_arg( array( 'error' => 'new-email' ), self_admin_url( 'profile.php' ) ) );
99
	}
100
} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) {
101
	check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' );
102
	delete_user_meta( $current_user->ID, '_new_email' );
103
	wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
104
	die();
105
}
106
107
switch ($action) {
108
case 'update':
109
110
check_admin_referer('update-user_' . $user_id);
111
112
if ( !current_user_can('edit_user', $user_id) )
113
	wp_die(__('Sorry, you are not allowed to edit this user.'));
114
115
if ( IS_PROFILE_PAGE ) {
116
	/**
117
	 * Fires before the page loads on the 'Your Profile' editing screen.
118
	 *
119
	 * The action only fires if the current user is editing their own profile.
120
	 *
121
	 * @since 2.0.0
122
	 *
123
	 * @param int $user_id The user ID.
124
	 */
125
	do_action( 'personal_options_update', $user_id );
126
} else {
127
	/**
128
	 * Fires before the page loads on the 'Edit User' screen.
129
	 *
130
	 * @since 2.7.0
131
	 *
132
	 * @param int $user_id The user ID.
133
	 */
134
	do_action( 'edit_user_profile_update', $user_id );
135
}
136
137
// Update the email address in signups, if present.
138
if ( is_multisite() ) {
139
	$user = get_userdata( $user_id );
140
141
	if ( $user->user_login && isset( $_POST[ 'email' ] ) && is_email( $_POST[ 'email' ] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) {
142
		$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) );
143
	}
144
}
145
146
// Update the user.
147
$errors = edit_user( $user_id );
148
149
// Grant or revoke super admin status if requested.
150
if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) ) {
151
	empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
152
}
153
154
if ( !is_wp_error( $errors ) ) {
155
	$redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) );
156
	if ( $wp_http_referer )
157
		$redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
158
	wp_redirect($redirect);
159
	exit;
160
}
161
162
default:
163
$profileuser = get_user_to_edit($user_id);
164
165
if ( !current_user_can('edit_user', $user_id) )
166
	wp_die(__('Sorry, you are not allowed to edit this user.'));
167
168
$sessions = WP_Session_Tokens::get_instance( $profileuser->ID );
169
170
include(ABSPATH . 'wp-admin/admin-header.php');
171
?>
172
173
<?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
174
	<div class="updated"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div>
175
<?php } ?>
176
<?php if ( isset($_GET['updated']) ) : ?>
177
<div id="message" class="updated notice is-dismissible">
178
	<?php if ( IS_PROFILE_PAGE ) : ?>
179
	<p><strong><?php _e('Profile updated.') ?></strong></p>
180
	<?php else: ?>
181
	<p><strong><?php _e('User updated.') ?></strong></p>
182
	<?php endif; ?>
183
	<?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
184
	<p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('&larr; Back to Users'); ?></a></p>
0 ignored issues
show
It seems like $wp_http_referer defined by remove_query_arg(array('...id'), $wp_http_referer) on line 58 can also be of type boolean; however, esc_url() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
185
	<?php endif; ?>
186
</div>
187
<?php endif; ?>
188
<?php if ( isset( $_GET['error'] ) ) : ?>
189
<div class="notice notice-error">
190
	<?php if ( 'new-email' == $_GET['error'] ) : ?>
191
	<p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
192
	<?php endif; ?>
193
</div>
194
<?php endif; ?>
195
<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
196
<div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div>
197
<?php endif; ?>
198
199
<div class="wrap" id="profile-page">
200
<h1>
201
<?php
202
echo esc_html( $title );
203
if ( ! IS_PROFILE_PAGE ) {
204 View Code Duplication
	if ( current_user_can( 'create_users' ) ) { ?>
205
		<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
206
	<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
207
		<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
208
	<?php }
209
} ?>
210
</h1>
211
<form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate"<?php
212
	/**
213
	 * Fires inside the your-profile form tag on the user editing screen.
214
	 *
215
	 * @since 3.0.0
216
	 */
217
	do_action( 'user_edit_form_tag' );
218
?>>
219
<?php wp_nonce_field('update-user_' . $user_id) ?>
220
<?php if ( $wp_http_referer ) : ?>
221
	<input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" />
0 ignored issues
show
It seems like $wp_http_referer defined by remove_query_arg(array('...id'), $wp_http_referer) on line 58 can also be of type boolean; however, esc_url() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
222
<?php endif; ?>
223
<p>
224
<input type="hidden" name="from" value="profile" />
225
<input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" />
226
</p>
227
228
<h2><?php _e( 'Personal Options' ); ?></h2>
229
230
<table class="form-table">
231 View Code Duplication
<?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
232
	<tr class="user-rich-editing-wrap">
233
		<th scope="row"><?php _e( 'Visual Editor' ); ?></th>
234
		<td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) checked( 'false', $profileuser->rich_editing ); ?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td>
235
	</tr>
236
<?php endif; ?>
237
<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
238
<tr class="user-admin-color-wrap">
239
<th scope="row"><?php _e('Admin Color Scheme')?></th>
240
<td><?php
241
	/**
242
	 * Fires in the 'Admin Color Scheme' section of the user editing screen.
243
	 *
244
	 * The section is only enabled if a callback is hooked to the action,
245
	 * and if there is more than one defined color scheme for the admin.
246
	 *
247
	 * @since 3.0.0
248
	 * @since 3.8.1 Added `$user_id` parameter.
249
	 *
250
	 * @param int $user_id The user ID.
251
	 */
252
	do_action( 'admin_color_scheme_picker', $user_id );
253
?></td>
254
</tr>
255
<?php
256
endif; // $_wp_admin_css_colors
257 View Code Duplication
if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
258
<tr class="user-comment-shortcuts-wrap">
259
<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
260
<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="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td>
261
</tr>
262
<?php endif; ?>
263
<tr class="show-admin-bar user-admin-bar-front-wrap">
264
<th scope="row"><?php _e( 'Toolbar' ); ?></th>
265
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend>
266
<label for="admin_bar_front">
267
<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
268
<?php _e( 'Show Toolbar when viewing site' ); ?></label><br />
269
</fieldset>
270
</td>
271
</tr>
272
<?php
273
/**
274
 * Fires at the end of the 'Personal Options' settings table on the user editing screen.
275
 *
276
 * @since 2.7.0
277
 *
278
 * @param WP_User $profileuser The current WP_User object.
279
 */
280
do_action( 'personal_options', $profileuser );
281
?>
282
283
</table>
284
<?php
285
	if ( IS_PROFILE_PAGE ) {
286
		/**
287
		 * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen.
288
		 *
289
		 * The action only fires if the current user is editing their own profile.
290
		 *
291
		 * @since 2.0.0
292
		 *
293
		 * @param WP_User $profileuser The current WP_User object.
294
		 */
295
		do_action( 'profile_personal_options', $profileuser );
296
	}
297
?>
298
299
<h2><?php _e( 'Name' ); ?></h2>
300
301
<table class="form-table">
302
	<tr class="user-user-login-wrap">
303
		<th><label for="user_login"><?php _e('Username'); ?></label></th>
304
		<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>
305
	</tr>
306
307
<?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?>
308
<tr class="user-role-wrap"><th><label for="role"><?php _e('Role') ?></label></th>
309
<td><select name="role" id="role">
310
<?php
311
// Compare user role against currently editable roles
312
$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
313
$user_role  = reset( $user_roles );
314
315
// print the full list of roles with the primary one selected.
316
wp_dropdown_roles($user_role);
317
318
// print the 'no role' option. Make it selected if the user has no role yet.
319
if ( $user_role )
320
	echo '<option value="">' . __('&mdash; No role for this site &mdash;') . '</option>';
321
else
322
	echo '<option value="" selected="selected">' . __('&mdash; No role for this site &mdash;') . '</option>';
323
?>
324
</select></td></tr>
325
<?php endif; //!IS_PROFILE_PAGE
326
327
if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
328
<tr class="user-super-admin-wrap"><th><?php _e('Super Admin'); ?></th>
329
<td>
330
<?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?>
331
<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>
332
<?php else : ?>
333
<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
334
<?php endif; ?>
335
</td></tr>
336
<?php } ?>
337
338
<tr class="user-first-name-wrap">
339
	<th><label for="first_name"><?php _e('First Name') ?></label></th>
340
	<td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td>
341
</tr>
342
343
<tr class="user-last-name-wrap">
344
	<th><label for="last_name"><?php _e('Last Name') ?></label></th>
345
	<td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
346
</tr>
347
348
<tr class="user-nickname-wrap">
349
	<th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
350
	<td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
351
</tr>
352
353
<tr class="user-display-name-wrap">
354
	<th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
355
	<td>
356
		<select name="display_name" id="display_name">
357
		<?php
358
			$public_display = array();
359
			$public_display['display_nickname']  = $profileuser->nickname;
360
			$public_display['display_username']  = $profileuser->user_login;
361
362
			if ( !empty($profileuser->first_name) )
363
				$public_display['display_firstname'] = $profileuser->first_name;
364
365
			if ( !empty($profileuser->last_name) )
366
				$public_display['display_lastname'] = $profileuser->last_name;
367
368
			if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
369
				$public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
370
				$public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
371
			}
372
373
			if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere
374
				$public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
375
376
			$public_display = array_map( 'trim', $public_display );
377
			$public_display = array_unique( $public_display );
378
379
			foreach ( $public_display as $id => $item ) {
380
		?>
381
			<option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
382
		<?php
383
			}
384
		?>
385
		</select>
386
	</td>
387
</tr>
388
</table>
389
390
<h2><?php _e( 'Contact Info' ); ?></h2>
391
392
<table class="form-table">
393
<tr class="user-email-wrap">
394
	<th><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
395
	<td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" />
396
	<?php
397
	$new_email = get_user_meta( $current_user->ID, '_new_email', true );
398
	if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
399
	<div class="updated inline">
400
	<p><?php
401
		printf(
402
			/* translators: %s: new email */
403
			__( 'There is a pending change of your email to %s.' ),
404
			'<code>' . esc_html( $new_email['newemail'] ) . '</code>'
405
		);
406
		printf(
407
			' <a href="%1$s">%2$s</a>',
408
			esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
409
			__( 'Cancel' )
410
		);
411
	?></p>
412
	</div>
413
	<?php endif; ?>
414
	</td>
415
</tr>
416
417
<tr class="user-url-wrap">
418
	<th><label for="url"><?php _e('Website') ?></label></th>
419
	<td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ) ?>" class="regular-text code" /></td>
420
</tr>
421
422
<?php
423
	foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
0 ignored issues
show
It seems like $profileuser defined by get_user_to_edit($user_id) on line 163 can also be of type false; however, wp_get_user_contact_methods() does only seem to accept object<WP_User>|null, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
424
?>
425
<tr class="user-<?php echo $name; ?>-wrap">
426
	<th><label for="<?php echo $name; ?>">
427
		<?php
428
		/**
429
		 * Filters a user contactmethod label.
430
		 *
431
		 * The dynamic portion of the filter hook, `$name`, refers to
432
		 * each of the keys in the contactmethods array.
433
		 *
434
		 * @since 2.9.0
435
		 *
436
		 * @param string $desc The translatable label for the contactmethod.
437
		 */
438
		echo apply_filters( "user_{$name}_label", $desc );
439
		?>
440
	</label></th>
441
	<td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
442
</tr>
443
<?php
444
	}
445
?>
446
</table>
447
448
<h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2>
449
450
<table class="form-table">
451
<tr class="user-description-wrap">
452
	<th><label for="description"><?php _e('Biographical Info'); ?></label></th>
453
	<td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea>
454
	<p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p></td>
455
</tr>
456
457
<?php if ( get_option( 'show_avatars' ) ) : ?>
458
<tr class="user-profile-picture">
459
	<th><?php _e( 'Profile Picture' ); ?></th>
460
	<td>
461
		<?php echo get_avatar( $user_id ); ?>
462
		<p class="description"><?php
463
			if ( IS_PROFILE_PAGE ) {
464
				/* translators: %s: Gravatar URL */
465
				$description = sprintf( __( 'You can change your profile picture on <a href="%s">Gravatar</a>.' ),
466
					__( 'https://en.gravatar.com/' )
467
				);
468
			} else {
469
				$description = '';
470
			}
471
472
			/**
473
			 * Filters the user profile picture description displayed under the Gravatar.
474
			 *
475
			 * @since 4.4.0
476
			 *
477
			 * @param string $description The description that will be printed.
478
			 */
479
			echo apply_filters( 'user_profile_picture_description', $description );
480
		?></p>
481
	</td>
482
</tr>
483
<?php endif; ?>
484
485
<?php
486
/**
487
 * Filters the display of the password fields.
488
 *
489
 * @since 1.5.1
490
 * @since 2.8.0 Added the `$profileuser` parameter.
491
 * @since 4.4.0 Now evaluated only in user-edit.php.
492
 *
493
 * @param bool    $show        Whether to show the password fields. Default true.
494
 * @param WP_User $profileuser User object for the current user to edit.
495
 */
496
if ( $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser ) ) :
497
?>
498
</table>
499
500
<h2><?php _e( 'Account Management' ); ?></h2>
501
<table class="form-table">
502
<tr id="password" class="user-pass1-wrap">
503
	<th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
504
	<td>
505
		<input class="hidden" value=" " /><!-- #24364 workaround -->
506
		<button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button>
507
		<div class="wp-pwd hide-if-js">
508
			<span class="password-input-wrapper">
509
				<input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" />
510
			</span>
511
			<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
512
				<span class="dashicons dashicons-hidden"></span>
513
				<span class="text"><?php _e( 'Hide' ); ?></span>
514
			</button>
515
			<button type="button" class="button button-secondary wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
516
				<span class="text"><?php _e( 'Cancel' ); ?></span>
517
			</button>
518
			<div style="display:none" id="pass-strength-result" aria-live="polite"></div>
519
		</div>
520
	</td>
521
</tr>
522
<tr class="user-pass2-wrap hide-if-js">
523
	<th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
524
	<td>
525
	<input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
526
	<p class="description"><?php _e( 'Type your new password again.' ); ?></p>
527
	</td>
528
</tr>
529
<tr class="pw-weak">
530
	<th><?php _e( 'Confirm Password' ); ?></th>
531
	<td>
532
		<label>
533
			<input type="checkbox" name="pw_weak" class="pw-checkbox" />
534
			<span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span>
535
		</label>
536
	</td>
537
</tr>
538
<?php endif; ?>
539
540
<?php
541
if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?>
542
	<tr class="user-sessions-wrap hide-if-no-js">
543
		<th><?php _e( 'Sessions' ); ?></th>
544
		<td aria-live="assertive">
545
			<div class="destroy-sessions"><button type="button" disabled class="button button-secondary"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
546
			<p class="description">
547
				<?php _e( 'You are only logged in at this location.' ); ?>
548
			</p>
549
		</td>
550
	</tr>
551
<?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?>
552
	<tr class="user-sessions-wrap hide-if-no-js">
553
		<th><?php _e( 'Sessions' ); ?></th>
554
		<td aria-live="assertive">
555
			<div class="destroy-sessions"><button type="button" class="button button-secondary" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
556
			<p class="description">
557
				<?php _e( 'Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.' ); ?>
558
			</p>
559
		</td>
560
	</tr>
561
<?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?>
562
	<tr class="user-sessions-wrap hide-if-no-js">
563
		<th><?php _e( 'Sessions' ); ?></th>
564
		<td>
565
			<p><button type="button" class="button button-secondary" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p>
566
			<p class="description">
567
				<?php
568
				/* translators: 1: User's display name. */
569
				printf( __( 'Log %s out of all locations.' ), $profileuser->display_name );
570
				?>
571
			</p>
572
		</td>
573
	</tr>
574
<?php endif; ?>
575
576
</table>
577
578
<?php
579
	if ( IS_PROFILE_PAGE ) {
580
		/**
581
		 * Fires after the 'About Yourself' settings table on the 'Your Profile' editing screen.
582
		 *
583
		 * The action only fires if the current user is editing their own profile.
584
		 *
585
		 * @since 2.0.0
586
		 *
587
		 * @param WP_User $profileuser The current WP_User object.
588
		 */
589
		do_action( 'show_user_profile', $profileuser );
590
	} else {
591
		/**
592
		 * Fires after the 'About the User' settings table on the 'Edit User' screen.
593
		 *
594
		 * @since 2.0.0
595
		 *
596
		 * @param WP_User $profileuser The current WP_User object.
597
		 */
598
		do_action( 'edit_user_profile', $profileuser );
599
	}
600
?>
601
602
<?php
603
/**
604
 * Filters whether to display additional capabilities for the user.
605
 *
606
 * The 'Additional Capabilities' section will only be enabled if
607
 * the number of the user's capabilities exceeds their number of
608
 * roles.
609
 *
610
 * @since 2.8.0
611
 *
612
 * @param bool    $enable      Whether to display the capabilities. Default true.
613
 * @param WP_User $profileuser The current WP_User object.
614
 */
615
if ( count( $profileuser->caps ) > count( $profileuser->roles )
616
	&& apply_filters( 'additional_capabilities_display', true, $profileuser )
617
) : ?>
618
<h2><?php _e( 'Additional Capabilities' ); ?></h2>
619
<table class="form-table">
620
<tr class="user-capabilities-wrap">
621
	<th scope="row"><?php _e( 'Capabilities' ); ?></th>
622
	<td>
623
<?php
624
	$output = '';
625
	foreach ( $profileuser->caps as $cap => $value ) {
626
		if ( ! $wp_roles->is_role( $cap ) ) {
627
			if ( '' != $output )
628
				$output .= ', ';
629
			$output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap );
630
		}
631
	}
632
	echo $output;
633
?>
634
	</td>
635
</tr>
636
</table>
637
<?php endif; ?>
638
639
<input type="hidden" name="action" value="update" />
640
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" />
641
642
<?php submit_button( IS_PROFILE_PAGE ? __('Update Profile') : __('Update User') ); ?>
643
644
</form>
645
</div>
646
<?php
647
break;
648
}
649
?>
650
<script type="text/javascript">
651
	if (window.location.hash == '#password') {
652
		document.getElementById('pass1').focus();
653
	}
654
</script>
655
<?php
656
include( ABSPATH . 'wp-admin/admin-footer.php');
657