From 34e9dc9f06e79edae875e08c6da71e40d80ea209 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 24 Sep 2013 18:13:18 +0000 Subject: [PATCH] Introduce wp_get_user_contact_methods() as a public version of _wp_get_user_contactmethods. props johnnyb. fixes #24273. git-svn-id: https://develop.svn.wordpress.org/trunk@25606 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/user.php | 2 +- src/wp-admin/user-edit.php | 2 +- src/wp-includes/user.php | 38 +++++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php index a2b02b208d..b61cb7ad35 100644 --- a/src/wp-admin/includes/user.php +++ b/src/wp-admin/includes/user.php @@ -85,7 +85,7 @@ function edit_user( $user_id = 0 ) { if ( isset( $_POST['description'] ) ) $user->description = trim( $_POST['description'] ); - foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) { + foreach ( wp_get_user_contact_methods( $user ) as $method => $name ) { if ( isset( $_POST[$method] )) $user->$method = sanitize_text_field( $_POST[$method] ); } diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index de0f9e4df7..ad17ffc3c0 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -350,7 +350,7 @@ if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_c $desc) { + foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) { ?> diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index b1d49f5c6b..c9fb60c53a 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -1539,30 +1539,48 @@ function wp_create_user($username, $password, $email = '') { */ function _get_additional_user_keys( $user ) { $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front' ); - return array_merge( $keys, array_keys( _wp_get_user_contactmethods( $user ) ) ); + return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) ); } /** - * Set up the contact methods. + * Set up the user contact methods. * * Default contact methods were removed in 3.6. A filter dictates contact methods. * - * @since 2.9.0 - * @access private + * @since 3.7.0 * - * @param object $user User data object (optional). - * @return array $user_contactmethods Array of contact methods and their labels. + * @param WP_User $user Optional. WP_User object. + * @return array Array of contact methods and their labels. */ -function _wp_get_user_contactmethods( $user = null ) { - $user_contactmethods = array(); +function wp_get_user_contact_methods( $user = null ) { + $methods = array(); if ( get_site_option( 'initial_db_version' ) < 23588 ) { - $user_contactmethods = array( + $methods = array( 'aim' => __( 'AIM' ), 'yim' => __( 'Yahoo IM' ), 'jabber' => __( 'Jabber / Google Talk' ) ); } - return apply_filters( 'user_contactmethods', $user_contactmethods, $user ); + + /** + * Filter the user contact methods. + * + * @since 2.9.0 + * + * @param array $methods Array of contact methods and their labels. + * @param WP_User $user Optional. WP_User object. + */ + return apply_filters( 'user_contactmethods', $methods, $user ); +} + +/** + * The old private function for setting up user contact methods. + * + * @since 2.9.0 + * @access private + */ +function _wp_get_user_contactmethods( $user = null ) { + return wp_get_user_contact_methods( $user ); } /**