Make WordPress Core


Ignore:
Timestamp:
04/30/2009 04:27:17 PM (16 years ago)
Author:
ryan
Message:

get_the_author_meta() and the_author_meta(). Props DD32, thee17. fixes #8776

File:
1 edited

Legend:

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

    r11109 r11138  
    8181
    8282/**
    83  * Retrieve the description of the author of the current post.
    84  *
    85  * @since 1.5
    86  * @uses $authordata The current author's DB object.
    87  * @return string The author's description.
    88  */
    89 function get_the_author_description() {
    90     global $authordata;
    91     return $authordata->description;
    92 }
    93 
    94 /**
    95  * Display the description of the author of the current post.
    96  *
    97  * @link http://codex.wordpress.org/Template_Tags/the_author_description
    98  * @since 1.0.0
    99  * @see get_the_author_description()
    100  */
    101 function the_author_description() {
    102     echo get_the_author_description();
    103 }
    104 
    105 /**
    106  * Retrieve the login name of the author of the current post.
    107  *
    108  * @since 1.5
    109  * @uses $authordata The current author's DB object.
    110  * @return string The author's login name (username).
    111  */
    112 function get_the_author_login() {
    113     global $authordata;
    114     return $authordata->user_login;
    115 }
    116 
    117 /**
    118  * Display the login name of the author of the current post.
    119  *
    120  * @link http://codex.wordpress.org/Template_Tags/the_author_login
    121  * @since 0.71
    122  * @see get_the_author_login()
    123  */
    124 function the_author_login() {
    125     echo get_the_author_login();
    126 }
    127 
    128 /**
    129  * Retrieve the first name of the author of the current post.
    130  *
    131  * @since 1.5
    132  * @uses $authordata The current author's DB object.
    133  * @return string The author's first name.
    134  */
    135 function get_the_author_firstname() {
    136     global $authordata;
    137     return $authordata->first_name;
    138 }
    139 
    140 /**
    141  * Display the first name of the author of the current post.
    142  *
    143  * @link http://codex.wordpress.org/Template_Tags/the_author_firstname
    144  * @since 0.71
    145  * @uses get_the_author_firstname()
    146  */
    147 function the_author_firstname() {
    148     echo get_the_author_firstname();
    149 }
    150 
    151 /**
    152  * Retrieve the last name of the author of the current post.
    153  *
    154  * @since 1.5
    155  * @uses $authordata The current author's DB object.
    156  * @return string The author's last name.
    157  */
    158 function get_the_author_lastname() {
    159     global $authordata;
    160     return $authordata->last_name;
    161 }
    162 
    163 /**
    164  * Display the last name of the author of the current post.
    165  *
    166  * @link http://codex.wordpress.org/Template_Tags/the_author_lastname
    167  * @since 0.71
    168  * @uses get_the_author_lastname()
    169  */
    170 function the_author_lastname() {
    171     echo get_the_author_lastname();
    172 }
    173 
    174 /**
    175  * Retrieve the nickname of the author of the current post.
    176  *
    177  * @since 1.5
    178  * @uses $authordata The current author's DB object.
    179  * @return string The author's nickname.
    180  */
    181 function get_the_author_nickname() {
    182     global $authordata;
    183     return $authordata->nickname;
    184 }
    185 
    186 /**
    187  * Display the nickname of the author of the current post.
    188  *
    189  * @link http://codex.wordpress.org/Template_Tags/the_author_nickname
    190  * @since 0.71
    191  * @uses get_the_author_nickname()
    192  */
    193 function the_author_nickname() {
    194     echo get_the_author_nickname();
    195 }
    196 
    197 /**
    198  * Retrieve the ID of the author of the current post.
    199  *
    200  * @since 1.5
    201  * @uses $authordata The current author's DB object.
    202  * @return int The author's ID.
    203  */
    204 function get_the_author_ID() {
    205     global $authordata;
    206     return (int) $authordata->ID;
    207 }
    208 
    209 /**
    210  * Display the ID of the author of the current post.
    211  *
    212  * @link http://codex.wordpress.org/Template_Tags/the_author_ID
    213  * @since 0.71
    214  * @uses get_the_author_ID()
    215  */
    216 function the_author_ID() {
    217     echo get_the_author_id();
    218 }
    219 
    220 /**
    221  * Retrieve the email of the author of the current post.
    222  *
    223  * @since 1.5
    224  * @uses $authordata The current author's DB object.
    225  * @return string The author's username.
    226  */
    227 function get_the_author_email() {
    228     global $authordata;
    229     return $authordata->user_email;
    230 }
    231 
    232 /**
    233  * Display the email of the author of the current post.
    234  *
    235  * @link http://codex.wordpress.org/Template_Tags/the_author_email
    236  * @since 0.71
    237  * @uses get_the_author_email()
    238  */
    239 function the_author_email() {
    240     echo apply_filters('the_author_email', get_the_author_email() );
    241 }
    242 
    243 /**
    244  * Retrieve the URL to the home page of the author of the current post.
    245  *
    246  * @since 1.5
    247  * @uses $authordata The current author's DB object.
    248  * @return string The URL to the author's page.
    249  */
    250 function get_the_author_url() {
    251     global $authordata;
    252 
    253     if ( 'http://' == $authordata->user_url )
    254         return '';
    255 
    256     return $authordata->user_url;
    257 }
    258 
    259 /**
    260  * Display the URL to the home page of the author of the current post.
    261  *
    262  * @link http://codex.wordpress.org/Template_Tags/the_author_url
    263  * @since 0.71
    264  * @uses get_the_author_url()
    265  */
    266 function the_author_url() {
    267     echo get_the_author_url();
     83 * Retrieve the requested data of the author of the current post.
     84 * @link http://codex.wordpress.org/Template_Tags/the_author_meta
     85 * @since 2.8.0
     86 * @param string $field selects the field of the users record.
     87 * @return string The author's field from the current author's DB object.
     88 */
     89function get_the_author_meta($field = '', $user_id = false) {
     90    if ( ! $user_id )
     91        global $authordata;
     92    else
     93        $authordata = get_userdata( $auth_id );
     94
     95    $field = strtolower($field);
     96    $user_field = "user_$field";
     97   
     98    if ( 'id' == $field )
     99        $value = isset($authordata->ID) ? (int)$authordata->ID : 0;
     100    elseif ( isset($authordata->$user_field) )
     101        $value = $authordata->$user_field;
     102    else
     103        $value = isset($authordata->$field) ? $authordata->$field : '';
     104
     105    return apply_filters('get_the_author_' . $field, $value);
     106}
     107
     108/**
     109 * Retrieve the requested data of the author of the current post.
     110 * @link http://codex.wordpress.org/Template_Tags/the_author_meta
     111 * @since 2.8.0
     112 * @param string $field selects the field of the users record.
     113 * @echo string The author's field from the current author's DB object.
     114 */
     115function the_author_meta($field = '', $user_id = false) {
     116    echo apply_filters('the_author_' . $field, get_the_author_meta($field, $user_id));
    268117}
    269118
     
    285134        the_author();
    286135    }
    287 }
    288 
    289 /**
    290  * Retrieve the ICQ number of the author of the current post.
    291  *
    292  * @since 1.5
    293  * @uses $authordata The current author's DB object.
    294  * @return string The author's ICQ number.
    295  */
    296 function get_the_author_icq() {
    297     global $authordata;
    298     return $authordata->icq;
    299 }
    300 
    301 /**
    302  * Display the ICQ number of the author of the current post.
    303  *
    304  * @link http://codex.wordpress.org/Template_Tags/the_author_icq
    305  * @since 0.71
    306  * @see get_the_author_icq()
    307  */
    308 function the_author_icq() {
    309     echo get_the_author_icq();
    310 }
    311 
    312 /**
    313  * Retrieve the AIM name of the author of the current post.
    314  *
    315  * @since 1.5
    316  * @uses $authordata The current author's DB object.
    317  * @return string The author's AIM name.
    318  */
    319 function get_the_author_aim() {
    320     global $authordata;
    321     return str_replace(' ', '+', $authordata->aim);
    322 }
    323 
    324 /**
    325  * Display the AIM name of the author of the current post.
    326  *
    327  * @link http://codex.wordpress.org/Template_Tags/the_author_aim
    328  * @since 0.71
    329  * @see get_the_author_aim()
    330  */
    331 function the_author_aim() {
    332     echo get_the_author_aim();
    333 }
    334 
    335 /**
    336  * Retrieve the Yahoo! IM name of the author of the current post.
    337  *
    338  * @since 1.5
    339  * @uses $authordata The current author's DB object.
    340  * @return string The author's Yahoo! IM name.
    341  */
    342 function get_the_author_yim() {
    343     global $authordata;
    344     return $authordata->yim;
    345 }
    346 
    347 /**
    348  * Display the Yahoo! IM name of the author of the current post.
    349  *
    350  * @link http://codex.wordpress.org/Template_Tags/the_author_yim
    351  * @since 0.71
    352  * @see get_the_author_yim()
    353  */
    354 function the_author_yim() {
    355     echo get_the_author_yim();
    356 }
    357 
    358 /**
    359  * Retrieve the MSN address of the author of the current post.
    360  *
    361  * @since 1.5
    362  * @uses $authordata The current author's DB object.
    363  * @return string The author's MSN address.
    364  */
    365 function get_the_author_msn() {
    366     global $authordata;
    367     return $authordata->msn;
    368 }
    369 
    370 /**
    371  * Display the MSN address of the author of the current post.
    372  *
    373  * @link http://codex.wordpress.org/Template_Tags/the_author_msn
    374  * @since 0.71
    375  * @see get_the_author_msn()
    376  */
    377 function the_author_msn() {
    378     echo get_the_author_msn();
    379136}
    380137
     
    455212
    456213    return $link;
    457 }
    458 
    459 /**
    460  * Retrieve the specified author's preferred display name.
    461  *
    462  * @since 1.0.0
    463  * @param int $auth_id The ID of the author.
    464  * @return string The author's display name.
    465  */
    466 function get_author_name( $auth_id ) {
    467     $authordata = get_userdata( $auth_id );
    468     return $authordata->display_name;
    469214}
    470215
Note: See TracChangeset for help on using the changeset viewer.