Make WordPress Core

Ticket #17302: get_adjacent_post_link.diff

File get_adjacent_post_link.diff, 4.3 KB (added by yoavf, 13 years ago)
  • wp-includes/link-template.php

     
    14001400}
    14011401
    14021402/**
     1403 * Get previous post link that is adjacent to the current post.
     1404 *
     1405 * @since 3.2.0
     1406 *
     1407 * @param string $format Optional. Link anchor format.
     1408 * @param string $link Optional. Link permalink format.
     1409 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1410 * @param string $excluded_categories Optional. Excluded categories IDs.
     1411 * @return string
     1412 */
     1413function get_previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
     1414        return get_adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
     1415}
     1416
     1417/**
    14031418 * Display previous post link that is adjacent to the current post.
    14041419 *
    14051420 * @since 1.5.0
     1421 * @uses get_previous_post_link()
    14061422 *
    14071423 * @param string $format Optional. Link anchor format.
    14081424 * @param string $link Optional. Link permalink format.
     
    14101426 * @param string $excluded_categories Optional. Excluded categories IDs.
    14111427 */
    14121428function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    1413         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
     1429        echo get_previous_post_link($format, $link, $in_same_cat, $excluded_categories);
    14141430}
    14151431
    14161432/**
     1433 * Get previous post link that is adjacent to the current post.
     1434 *
     1435 * @since 3.2.0
     1436 *
     1437 * @param string $format Optional. Link anchor format.
     1438 * @param string $link Optional. Link permalink format.
     1439 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1440 * @param string $excluded_categories Optional. Excluded categories IDs.
     1441 * @return string
     1442 */
     1443function get_next_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
     1444        return get_adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
     1445}
     1446
     1447/**
    14171448 * Display next post link that is adjacent to the current post.
    14181449 *
    14191450 * @since 1.5.0
     1451 * @uses get_next_post_link()
    14201452 *
    14211453 * @param string $format Optional. Link anchor format.
    14221454 * @param string $link Optional. Link permalink format.
     
    14241456 * @param string $excluded_categories Optional. Excluded categories IDs.
    14251457 */
    14261458function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    1427         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
     1459        echo get_next_post_link($format, $link, $in_same_cat, $excluded_categories);
    14281460}
    14291461
    14301462/**
    1431  * Display adjacent post link.
     1463 * Get adjacent post link.
    14321464 *
    14331465 * Can be either next post link or previous.
    14341466 *
    1435  * @since 2.5.0
     1467 * @since 3.2.0
    14361468 *
    14371469 * @param string $format Link anchor format.
    14381470 * @param string $link Link permalink format.
    14391471 * @param bool $in_same_cat Optional. Whether link should be in same category.
    14401472 * @param string $excluded_categories Optional. Excluded categories IDs.
    14411473 * @param bool $previous Optional, default is true. Whether display link to previous post.
     1474 * @return string
    14421475 */
    1443 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
     1476function get_adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
    14441477        if ( $previous && is_attachment() )
    14451478                $post = & get_post($GLOBALS['post']->post_parent);
    14461479        else
     
    14691502        echo apply_filters( "{$adjacent}_post_link", $format, $link );
    14701503}
    14711504
     1505
    14721506/**
     1507 * Display adjacent post link.
     1508 *
     1509 * Can be either next post link or previous.
     1510 *
     1511 * @since 2.5.0
     1512 * @uses get_adjacent_post_link()
     1513 *
     1514 * @param string $format Link anchor format.
     1515 * @param string $link Link permalink format.
     1516 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1517 * @param string $excluded_categories Optional. Excluded categories IDs.
     1518 * @param bool $previous Optional, default is true. Whether display link to previous post.
     1519 */
     1520function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
     1521        echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, $previous );
     1522}
     1523
     1524/**
    14731525 * Retrieve get links for page numbers.
    14741526 *
    14751527 * @since 1.5.0