Make WordPress Core

Changeset 11138


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

Location:
trunk/wp-includes
Files:
2 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
  • trunk/wp-includes/deprecated.php

    r11109 r11138  
    13541354}
    13551355
     1356/**
     1357 * Retrieve the description of the author of the current post.
     1358 *
     1359 * @since 1.5
     1360 * @deprecated 2.8
     1361 * @uses $authordata The current author's DB object.
     1362 * @return string The author's description.
     1363 * @deprecated Use the_author_meta('description')
     1364 */
     1365function get_the_author_description() {
     1366    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'description\')' );
     1367    return get_the_author_meta('description');
     1368}
     1369
     1370/**
     1371 * Display the description of the author of the current post.
     1372 *
     1373 * @link http://codex.wordpress.org/Template_Tags/the_author_description
     1374 * @since 1.0.0
     1375 * @deprecated 2.8
     1376 * @deprecated Use the_author_meta('description')
     1377 */
     1378function the_author_description() {
     1379    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'description\')' );
     1380    the_author_meta('description');
     1381}
     1382
     1383/**
     1384 * Retrieve the login name of the author of the current post.
     1385 *
     1386 * @since 1.5
     1387 * @deprecated 2.8
     1388 * @uses $authordata The current author's DB object.
     1389 * @return string The author's login name (username).
     1390 * @deprecated Use the_author_meta('login')
     1391 */
     1392function get_the_author_login() {
     1393    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'login\')' );
     1394    return get_the_author_meta('login');
     1395}
     1396
     1397/**
     1398 * Display the login name of the author of the current post.
     1399 *
     1400 * @link http://codex.wordpress.org/Template_Tags/the_author_login
     1401 * @since 0.71
     1402 * @deprecated 2.8
     1403 * @deprecated Use the_author_meta('login')
     1404 */
     1405function the_author_login() {
     1406    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'login\')' );
     1407    the_author_meta('login');
     1408}
     1409
     1410/**
     1411 * Retrieve the first name of the author of the current post.
     1412 *
     1413 * @since 1.5
     1414 * @deprecated 2.8
     1415 * @uses $authordata The current author's DB object.
     1416 * @return string The author's first name.
     1417 * @deprecated Use the_author_meta('first_name')
     1418 */
     1419function get_the_author_firstname() {
     1420    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'first_name\')' );
     1421    return get_the_author_meta('first_name');
     1422}
     1423
     1424/**
     1425 * Display the first name of the author of the current post.
     1426 *
     1427 * @link http://codex.wordpress.org/Template_Tags/the_author_firstname
     1428 * @since 0.71
     1429 * @deprecated 2.8
     1430 * @deprecated Use the_author_meta('first_name')
     1431 */
     1432function the_author_firstname() {
     1433    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'first_name\')' );
     1434    the_author_meta('first_name');
     1435}
     1436
     1437/**
     1438 * Retrieve the last name of the author of the current post.
     1439 *
     1440 * @since 1.5
     1441 * @deprecated 2.8
     1442 * @uses $authordata The current author's DB object.
     1443 * @return string The author's last name.
     1444 * @deprecated Use the_author_meta('last_name')
     1445 */
     1446function get_the_author_lastname() {
     1447    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'last_name\')' );
     1448    return get_the_author_meta('last_name');
     1449}
     1450
     1451/**
     1452 * Display the last name of the author of the current post.
     1453 *
     1454 * @link http://codex.wordpress.org/Template_Tags/the_author_lastname
     1455 * @since 0.71
     1456 * @deprecated 2.8
     1457 * @deprecated Use the_author_meta('last_name')
     1458 */
     1459function the_author_lastname() {
     1460    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'last_name\')' );
     1461    the_author_meta('last_name');
     1462}
     1463
     1464/**
     1465 * Retrieve the nickname of the author of the current post.
     1466 *
     1467 * @since 1.5
     1468 * @deprecated 2.8
     1469 * @uses $authordata The current author's DB object.
     1470 * @return string The author's nickname.
     1471 * @deprecated Use the_author_meta('nickname')
     1472 */
     1473function get_the_author_nickname() {
     1474    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'nickname\')' );
     1475    return get_the_author_meta('nickname');
     1476}
     1477
     1478/**
     1479 * Display the nickname of the author of the current post.
     1480 *
     1481 * @link http://codex.wordpress.org/Template_Tags/the_author_nickname
     1482 * @since 0.71
     1483 * @deprecated 2.8
     1484 * @deprecated Use the_author_meta('nickname')
     1485 */
     1486function the_author_nickname() {
     1487    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'nickname\')' );
     1488    the_author_meta('nickname');
     1489}
     1490
     1491/**
     1492 * Retrieve the email of the author of the current post.
     1493 *
     1494 * @since 1.5
     1495 * @deprecated 2.8
     1496 * @uses $authordata The current author's DB object.
     1497 * @return string The author's username.
     1498 * @deprecated Use the_author_meta('email')
     1499 */
     1500function get_the_author_email() {
     1501    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'email\')' );
     1502    return get_the_author_meta('email');
     1503}
     1504
     1505/**
     1506 * Display the email of the author of the current post.
     1507 *
     1508 * @link http://codex.wordpress.org/Template_Tags/the_author_email
     1509 * @since 0.71
     1510 * @deprecated 2.8
     1511 * @deprecated Use the_author_meta('email')
     1512 */
     1513function the_author_email() {
     1514    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'email\')' );
     1515    the_author_meta('email');
     1516}
     1517
     1518/**
     1519 * Retrieve the ICQ number of the author of the current post.
     1520 *
     1521 * @since 1.5
     1522 * @deprecated 2.8
     1523 * @uses $authordata The current author's DB object.
     1524 * @return string The author's ICQ number.
     1525 * @deprecated Use the_author_meta('icq')
     1526 */
     1527function get_the_author_icq() {
     1528    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'icq\')' );
     1529    return get_the_author_meta('icq');
     1530}
     1531
     1532/**
     1533 * Display the ICQ number of the author of the current post.
     1534 *
     1535 * @link http://codex.wordpress.org/Template_Tags/the_author_icq
     1536 * @since 0.71
     1537 * @deprecated 2.8
     1538 * @see get_the_author_icq()
     1539 * @deprecated Use the_author_meta('icq')
     1540 */
     1541function the_author_icq() {
     1542    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'icq\')' );
     1543    the_author_meta('icq');
     1544}
     1545
     1546/**
     1547 * Retrieve the Yahoo! IM name of the author of the current post.
     1548 *
     1549 * @since 1.5
     1550 * @deprecated 2.8
     1551 * @uses $authordata The current author's DB object.
     1552 * @return string The author's Yahoo! IM name.
     1553 * @deprecated Use the_author_meta('yim')
     1554 */
     1555function get_the_author_yim() {
     1556    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'yim\')' );
     1557    return get_the_author_meta('yim');
     1558}
     1559
     1560/**
     1561 * Display the Yahoo! IM name of the author of the current post.
     1562 *
     1563 * @link http://codex.wordpress.org/Template_Tags/the_author_yim
     1564 * @since 0.71
     1565 * @deprecated 2.8
     1566 * @deprecated Use the_author_meta('yim')
     1567 */
     1568function the_author_yim() {
     1569    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'yim\')' );
     1570    the_author_meta('yim');
     1571}
     1572
     1573/**
     1574 * Retrieve the MSN address of the author of the current post.
     1575 *
     1576 * @since 1.5
     1577 * @deprecated 2.8
     1578 * @uses $authordata The current author's DB object.
     1579 * @return string The author's MSN address.
     1580 * @deprecated Use the_author_meta('msn')
     1581 */
     1582function get_the_author_msn() {
     1583    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'msn\')' );
     1584    return get_the_author_meta('msn');
     1585}
     1586
     1587/**
     1588 * Display the MSN address of the author of the current post.
     1589 *
     1590 * @link http://codex.wordpress.org/Template_Tags/the_author_msn
     1591 * @since 0.71
     1592 * @deprecated 2.8
     1593 * @see get_the_author_msn()
     1594 * @deprecated Use the_author_meta('msn')
     1595 */
     1596function the_author_msn() {
     1597    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'msn\')' );
     1598    the_author_meta('msn');
     1599}
     1600
     1601/**
     1602 * Retrieve the specified author's preferred display name.
     1603 *
     1604 * @since 1.0.0
     1605 * @deprecated 2.8
     1606 * @param int $auth_id The ID of the author.
     1607 * @return string The author's display name.
     1608 * @deprecated Use the_author_meta('display_name')
     1609 */
     1610function get_author_name( $auth_id = false ) {
     1611    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'display_name\')' );
     1612    return get_the_author_meta('display_name', $auth_id);
     1613}
     1614
     1615/**
     1616 * Retrieve the URL to the home page of the author of the current post.
     1617 *
     1618 * @since 1.5
     1619 * @deprecated 2.8
     1620 * @uses $authordata The current author's DB object.
     1621 * @return string The URL to the author's page.
     1622 */
     1623function get_the_author_url() {
     1624    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'url\')' );
     1625    return get_the_author_meta('url');
     1626}
     1627
     1628/**
     1629 * Display the URL to the home page of the author of the current post.
     1630 *
     1631 * @link http://codex.wordpress.org/Template_Tags/the_author_url
     1632 * @since 0.71
     1633 * @deprecated 2.8
     1634 */
     1635function the_author_url() {
     1636    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'url\')' );
     1637    the_author_meta('url');
     1638}
     1639
     1640/**
     1641 * Retrieve the ID of the author of the current post.
     1642 *
     1643 * @since 1.5
     1644 * @deprecated 2.8
     1645 * @return int The author's ID.
     1646 */
     1647function get_the_author_ID() { 
     1648    _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'ID\')' );
     1649    return get_the_author_meta('ID');
     1650}
     1651
     1652/**
     1653 * Display the ID of the author of the current post.
     1654 *
     1655 * @link http://codex.wordpress.org/Template_Tags/the_author_ID
     1656 * @since 0.71
     1657 * @deprecated 2.8
     1658 * @uses get_the_author_ID()
     1659*/
     1660function the_author_ID() { 
     1661    _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'ID\')' );
     1662    the_author_meta('ID');
     1663}
     1664
    13561665?>
Note: See TracChangeset for help on using the changeset viewer.