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

git-svn-id: https://develop.svn.wordpress.org/trunk@11784 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood
2009-08-06 21:59:52 +00:00
parent 4d26de281a
commit 10360549ba
3 changed files with 43 additions and 34 deletions
+28 -9
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);
}
?>