WordPress.org

Make WordPress Core

Changeset 20565


Ignore:
Timestamp:
04/23/2012 09:34:07 PM (6 years ago)
Author:
ryan
Message:

Remove key mangling code from get_the_author_meta(). Make it more inline with get_user_option(). Handle collision with old users table columns that are on old schema, particularly user_description.

Props scribu, fredwu.
Fixes #20285

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/author-template.php

    r19712 r20565  
    9797 * @return string The author's field from the current author's DB object.
    9898 */
    99 function get_the_author_meta($field = '', $user_id = false) {
    100     if ( ! $user_id )
     99function get_the_author_meta( $field = '', $user_id = false ) {
     100    if ( ! $user_id ) {
    101101        global $authordata;
    102     else
     102        $user_id = $authordata->ID;
     103    } else {
    103104        $authordata = get_userdata( $user_id );
    104 
    105     // Keys used as object vars cannot have dashes.
    106     $field = str_replace('-', '', $field);
    107     $field = strtolower($field);
    108     $user_field = "user_$field";
    109 
    110     if ( 'id' == $field )
    111         $value = isset($authordata->ID) ? (int)$authordata->ID : 0;
    112     elseif ( isset($authordata->$user_field) )
    113         $value = $authordata->$user_field;
    114     else
    115         $value = isset($authordata->$field) ? $authordata->$field : '';
    116 
    117     return apply_filters('get_the_author_' . $field, $value, $user_id);
     105    }
     106
     107    if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) )
     108        $field = 'user_' . $field;
     109
     110    $value = isset( $authordata->$field ) ? $authordata->$field : '';
     111
     112    return apply_filters( 'get_the_author_' . $field, $value, $user_id );
    118113}
    119114
Note: See TracChangeset for help on using the changeset viewer.