WordPress.org

Make WordPress Core

Ticket #8776: 8776-try-1.patch

File 8776-try-1.patch, 3.6 KB (added by thee17, 9 years ago)

I could not get to work but here is what I have.

  • author-template.php

     
    5353/**
    5454 * Retrieve the description of the author of the current post.
    5555 *
     56 * @since 2.8.0
     57 * @uses $authordata The current author's DB object.
     58 * @return string The author's field from the current author's DB object.
     59 */
     60function the_author_meta($field = '') {
     61        global $authordata;
     62        return isset($authordata->$field) ? $authordata->$field : '';
     63}
     64
     65
     66
     67/**
     68 * Retrieve the description of the author of the current post.
     69 *
    5670 * @since 1.5
    5771 * @uses $authordata The current author's DB object.
    5872 * @return string The author's description.
    5973 */
    6074function get_the_author_description() {
    61         global $authordata;
    62         return $authordata->description;
     75        echo the_author_meta('description');
    6376}
    6477
    6578/**
     
    7083 * @see get_the_author_description()
    7184 */
    7285function the_author_description() {
    73         echo get_the_author_description();
     86        echo the_author_meta('description');
    7487}
    7588
    7689/**
     
    8194 * @return string The author's login name (username).
    8295 */
    8396function get_the_author_login() {
    84         global $authordata;
    85         return $authordata->user_login;
     97        echo the_author_meta('user_login');
    8698}
    8799
    88100/**
     
    93105 * @see get_the_author_login()
    94106 */
    95107function the_author_login() {
    96         echo get_the_author_login();
     108        echo the_author_meta('user_login');
    97109}
    98110
    99111/**
     
    104116 * @return string The author's first name.
    105117 */
    106118function get_the_author_firstname() {
    107         global $authordata;
    108         return $authordata->first_name;
     119        echo the_author_meta('first_name');
    109120}
    110121
    111122/**
     
    116127 * @uses get_the_author_firstname()
    117128 */
    118129function the_author_firstname() {
    119         echo get_the_author_firstname();
     130        echo the_author_meta('first_name');
    120131}
    121132
    122133/**
     
    127138 * @return string The author's last name.
    128139 */
    129140function get_the_author_lastname() {
    130         global $authordata;
    131         return $authordata->last_name;
     141        echo the_author_meta('last_name');
    132142}
    133143
    134144/**
     
    139149 * @uses get_the_author_lastname()
    140150 */
    141151function the_author_lastname() {
    142         echo get_the_author_lastname();
     152        echo the_author_meta('last_name');
    143153}
    144154
    145155/**
     
    150160 * @return string The author's nickname.
    151161 */
    152162function get_the_author_nickname() {
    153         global $authordata;
    154         return $authordata->nickname;
     163        echo the_author_meta('nickname');
    155164}
    156165
    157166/**
     
    162171 * @uses get_the_author_nickname()
    163172 */
    164173function the_author_nickname() {
    165         echo get_the_author_nickname();
     174        echo the_author_meta('nickname');
    166175}
    167176
    168177/**
     
    173182 * @return int The author's ID.
    174183 */
    175184function get_the_author_ID() {
    176         global $authordata;
    177         return (int) $authordata->ID;
     185        echo the_author_meta('ID');
    178186}
    179187
    180188/**
     
    185193 * @uses get_the_author_ID()
    186194 */
    187195function the_author_ID() {
    188         echo get_the_author_id();
     196        echo the_author_meta('ID');
    189197}
    190198
    191199/**
     
    196204 * @return string The author's username.
    197205 */
    198206function get_the_author_email() {
    199         global $authordata;
    200         return $authordata->user_email;
     207        echo the_author_meta('user_email');
    201208}
    202209
    203210/**
     
    208215 * @uses get_the_author_email()
    209216 */
    210217function the_author_email() {
    211         echo apply_filters('the_author_email', get_the_author_email() );
     218        echo the_author_meta('user_email');
    212219}
    213220
    214221/**
     
    435442 * @return string The author's display name.
    436443 */
    437444function get_author_name( $auth_id ) {
    438         $authordata = get_userdata( $auth_id );
    439         return $authordata->display_name;
    440 }
     445        echo the_author_meta('display_name');
    441446
    442447/**
    443448 * List all the authors of the blog, with several options available.