Make it much easier to filter contact methods from user profiles adding and removing at will. Fixes #10240 props joostdevalk.

git-svn-id: http://svn.automattic.com/wordpress/trunk@11784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2009-08-06 21:59:52 +00:00
parent 07c88e581e
commit 8aa2598b6a
3 changed files with 43 additions and 34 deletions

View File

@ -105,12 +105,11 @@ function edit_user( $user_id = 0 ) {
$user->display_name = esc_html( trim( $_POST['display_name'] ));
if ( isset( $_POST['description'] ))
$user->description = trim( $_POST['description'] );
if ( isset( $_POST['jabber'] ))
$user->jabber = esc_html( trim( $_POST['jabber'] ));
if ( isset( $_POST['aim'] ))
$user->aim = esc_html( trim( $_POST['aim'] ));
if ( isset( $_POST['yim'] ))
$user->yim = esc_html( trim( $_POST['yim'] ));
$user_contactmethods = _wp_get_user_contactmethods();
foreach ($user_contactmethods as $method => $name) {
if ( isset( $_POST[$method] ))
$user->$method = esc_html( trim( $_POST[$method] ) );
}
if ( !$update )
$user->rich_editing = 'true'; // Default to true for new users.
else if ( isset( $_POST['rich_editing'] ) )
@ -378,9 +377,12 @@ function get_user_to_edit( $user_id ) {
$user->last_name = esc_attr($user->last_name);
$user->display_name = esc_attr($user->display_name);
$user->nickname = esc_attr($user->nickname);
$user->aim = isset( $user->aim ) && !empty( $user->aim ) ? esc_attr($user->aim) : '';
$user->yim = isset( $user->yim ) && !empty( $user->yim ) ? esc_attr($user->yim) : '';
$user->jabber = isset( $user->jabber ) && !empty( $user->jabber ) ? esc_attr($user->jabber) : '';
$user_contactmethods = _wp_get_user_contactmethods();
foreach ($user_contactmethods as $method => $name) {
$user->{$method} = isset( $user->{$method} ) && !empty( $user->{$method} ) ? esc_attr($user->{$method}) : '';
}
$user->description = isset( $user->description ) && !empty( $user->description ) ? esc_html($user->description) : '';
return $user;
@ -835,4 +837,21 @@ function default_password_nag() {
echo '</p></div>';
}
/**
* Setup the default contact methods
*
* @access private
* @since
*
* @return array $user_contactmethods Array of contact methods and their labels.
*/
function _wp_get_user_contactmethods() {
$user_contactmethods = array(
'aim' => __('AIM'),
'yim' => __('Yahoo IM'),
'jabber' => __('Jabber / Google Talk')
);
return apply_filters('user_contactmethods',$user_contactmethods);
}
?>

View File

@ -267,20 +267,16 @@ else
<td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td>
</tr>
<?php
foreach (_wp_get_user_contactmethods() as $name => $desc) {
?>
<tr>
<th><label for="aim"><?php echo apply_filters('user_aim_label', __('AIM')); ?></label></th>
<td><input type="text" name="aim" id="aim" value="<?php echo esc_attr($profileuser->aim) ?>" class="regular-text" /></td>
</tr>
<tr>
<th><label for="yim"><?php echo apply_filters('user_yim_label', __('Yahoo IM')); ?></label></th>
<td><input type="text" name="yim" id="yim" value="<?php echo esc_attr($profileuser->yim) ?>" class="regular-text" /></td>
</tr>
<tr>
<th><label for="jabber"><?php echo apply_filters('user_jabber_label', __('Jabber / Google Talk')); ?></label></th>
<td><input type="text" name="jabber" id="jabber" value="<?php echo esc_attr($profileuser->jabber) ?>" class="regular-text" /></td>
</tr>
<th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
<td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
</tr>
<?php
}
?>
</table>
<h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>

View File

@ -164,15 +164,6 @@ function wp_insert_user($userdata) {
if ( empty($use_ssl) )
$use_ssl = 0;
if ( empty($jabber) )
$jabber = '';
if ( empty($aim) )
$aim = '';
if ( empty($yim) )
$yim = '';
if ( empty($user_registered) )
$user_registered = gmdate('Y-m-d H:i:s');
@ -203,13 +194,16 @@ function wp_insert_user($userdata) {
update_usermeta( $user_id, 'last_name', $last_name);
update_usermeta( $user_id, 'nickname', $nickname );
update_usermeta( $user_id, 'description', $description );
update_usermeta( $user_id, 'jabber', $jabber );
update_usermeta( $user_id, 'aim', $aim );
update_usermeta( $user_id, 'yim', $yim );
update_usermeta( $user_id, 'rich_editing', $rich_editing);
update_usermeta( $user_id, 'comment_shortcuts', $comment_shortcuts);
update_usermeta( $user_id, 'admin_color', $admin_color);
update_usermeta( $user_id, 'use_ssl', $use_ssl);
foreach (_wp_get_user_contactmethods() as $method => $name) {
if ( empty($$method) )
$$method = '';
update_usermeta( $user_id, $method, $$method );
}
if ( isset($role) ) {
$user = new WP_User($user_id);