Make WordPress Core

Ticket #17302: 17302.2.diff

File 17302.2.diff, 5.5 KB (added by markjaquith, 12 years ago)

return instead of echo in the get function

  • wp-includes/link-template.php

    function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $pr 
    11281128                        }
    11291129
    11301130                        $excluded_categories = array_map( 'intval', $excluded_categories );
    1131                                
     1131
    11321132                        if ( ! empty( $cat_array ) ) {
    11331133                                $excluded_categories = array_diff($excluded_categories, $cat_array);
    11341134                                $posts_in_ex_cats_sql = '';
    function get_boundary_post( $in_same_cat = false, $excluded_categories = '', $st 
    12761276        $cat_array = array();
    12771277        if( ! is_array( $excluded_categories ) )
    12781278                $excluded_categories = explode( ',', $excluded_categories );
    1279                
     1279
    12801280        if ( $in_same_cat || ! empty( $excluded_categories ) ) {
    12811281                if ( $in_same_cat )
    12821282                        $cat_array = wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) );
    function parent_post_rel_link($title = '%title') { 
    14101410}
    14111411
    14121412/**
     1413 * Get previous post link that is adjacent to the current post.
     1414 *
     1415 * @since 3.3.0
     1416 *
     1417 * @param string $format Optional. Link anchor format.
     1418 * @param string $link Optional. Link permalink format.
     1419 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1420 * @param string $excluded_categories Optional. Excluded categories IDs.
     1421 * @return string
     1422 */
     1423function get_previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
     1424        return get_adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
     1425}
     1426
     1427/**
    14131428 * Display previous post link that is adjacent to the current post.
    14141429 *
    14151430 * @since 1.5.0
     1431 * @uses get_previous_post_link()
    14161432 *
    14171433 * @param string $format Optional. Link anchor format.
    14181434 * @param string $link Optional. Link permalink format.
    function parent_post_rel_link($title = '%title') { 
    14201436 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
    14211437 */
    14221438function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    1423         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
     1439        echo get_previous_post_link($format, $link, $in_same_cat, $excluded_categories);
     1440}
     1441
     1442/**
     1443 * Get previous post link that is adjacent to the current post.
     1444 *
     1445 * @since 3.3.0
     1446 *
     1447 * @param string $format Optional. Link anchor format.
     1448 * @param string $link Optional. Link permalink format.
     1449 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1450 * @param string $excluded_categories Optional. Excluded categories IDs.
     1451 * @return string
     1452 */
     1453function get_next_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
     1454        return get_adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
    14241455}
    14251456
    14261457/**
    14271458 * Display next post link that is adjacent to the current post.
    14281459 *
    14291460 * @since 1.5.0
     1461 * @uses get_next_post_link()
    14301462 *
    14311463 * @param string $format Optional. Link anchor format.
    14321464 * @param string $link Optional. Link permalink format.
    function previous_post_link($format='« %link', $link='%title', $in_same_ca 
    14341466 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
    14351467 */
    14361468function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    1437         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
     1469        echo get_next_post_link($format, $link, $in_same_cat, $excluded_categories);
    14381470}
    14391471
    14401472/**
    1441  * Display adjacent post link.
     1473 * Get adjacent post link.
    14421474 *
    14431475 * Can be either next post link or previous.
    14441476 *
    1445  * @since 2.5.0
     1477 * @since 3.3.0
    14461478 *
    14471479 * @param string $format Link anchor format.
    14481480 * @param string $link Link permalink format.
    14491481 * @param bool $in_same_cat Optional. Whether link should be in same category.
    14501482 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
    14511483 * @param bool $previous Optional, default is true. Whether display link to previous post.
     1484 * @return string
    14521485 */
    1453 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
     1486function get_adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
    14541487        if ( $previous && is_attachment() )
    14551488                $post = & get_post($GLOBALS['post']->post_parent);
    14561489        else
    function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_cate 
    14761509        $format = str_replace('%link', $link, $format);
    14771510
    14781511        $adjacent = $previous ? 'previous' : 'next';
    1479         echo apply_filters( "{$adjacent}_post_link", $format, $link );
     1512        return apply_filters( "{$adjacent}_post_link", $format, $link );
     1513}
     1514
     1515
     1516/**
     1517 * Display adjacent post link.
     1518 *
     1519 * Can be either next post link or previous.
     1520 *
     1521 * @since 2.5.0
     1522 * @uses get_adjacent_post_link()
     1523 *
     1524 * @param string $format Link anchor format.
     1525 * @param string $link Link permalink format.
     1526 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1527 * @param string $excluded_categories Optional. Excluded categories IDs.
     1528 * @param bool $previous Optional, default is true. Whether display link to previous post.
     1529 */
     1530function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
     1531        echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, $previous );
    14801532}
    14811533
    14821534/**