Make WordPress Core

Ticket #17302: 17302.4.diff

File 17302.4.diff, 5.1 KB (added by yoavf, 12 years ago)

refreshed for 3.7

  • wp-includes/link-template.php

     
    13351335        return get_posts( array('numberposts' => 1, 'category' => $categories, 'order' => $order, 'update_post_term_cache' => false, 'update_post_meta_cache' => false) );
    13361336}
    13371337
     1338/*
     1339 * Get previous post link that is adjacent to the current post.
     1340 *
     1341 * @since 3.7.0
     1342 *
     1343 * @param string $format Optional. Link anchor format.
     1344 * @param string $link Optional. Link permalink format.
     1345 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1346 * @param string $excluded_categories Optional. Excluded categories IDs.
     1347 * @return string
     1348 */
     1349function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) {
     1350        return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, true );
     1351}
     1352
    13381353/**
    13391354 * Display previous post link that is adjacent to the current post.
    13401355 *
    13411356 * @since 1.5.0
     1357 * @uses get_previous_post_link()
    13421358 *
    13431359 * @param string $format Optional. Link anchor format.
    13441360 * @param string $link Optional. Link permalink format.
    13451361 * @param bool $in_same_cat Optional. Whether link should be in a same category.
    13461362 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
    13471363 */
    1348 function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    1349         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
     1364function previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) {
     1365        echo get_previous_post_link( $format, $link, $in_same_cat, $excluded_categories );
    13501366}
    13511367
    13521368/**
     1369 * Get previous post link that is adjacent to the current post.
     1370 *
     1371 * @since 3.7.0
     1372 * @uses get_next_post_link()
     1373 *
     1374 * @param string $format Optional. Link anchor format.
     1375 * @param string $link Optional. Link permalink format.
     1376 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1377 * @param string $excluded_categories Optional. Excluded categories IDs.
     1378 * @return string
     1379 */
     1380function get_next_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) {
     1381        return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, false );
     1382}
     1383
     1384/**
    13531385 * Display next post link that is adjacent to the current post.
    13541386 *
    13551387 * @since 1.5.0
     
    13591391 * @param bool $in_same_cat Optional. Whether link should be in a same category.
    13601392 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
    13611393 */
    1362 function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    1363         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
     1394function next_post_link( $format = '%link »', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) {
     1395         echo get_next_post_link( $format, $link, $in_same_cat, $excluded_categories );
    13641396}
    13651397
    13661398/**
    1367  * Display adjacent post link.
     1399 * Get adjacent post link.
    13681400 *
    13691401 * Can be either next post link or previous.
    13701402 *
    1371  * @since 2.5.0
     1403 * @since 3.7.0
    13721404 *
    13731405 * @param string $format Link anchor format.
    13741406 * @param string $link Link permalink format.
    13751407 * @param bool $in_same_cat Optional. Whether link should be in a same category.
    13761408 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
    13771409 * @param bool $previous Optional, default is true. Whether to display link to previous or next post.
     1410 * @return string
    13781411 */
    1379 function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) {
     1412function get_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) {
    13801413        if ( $previous && is_attachment() )
    13811414                $post = get_post( get_post()->post_parent );
    13821415        else
     
    14041437
    14051438        $adjacent = $previous ? 'previous' : 'next';
    14061439
    1407         echo apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post );
     1440        return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post );
    14081441}
    14091442
    14101443/**
     1444 * Display adjacent post link.
     1445 *
     1446 * Can be either next post link or previous.
     1447 *
     1448 * @since 2.5.0
     1449 * @uses get_adjacent_post_link()
     1450 *
     1451 * @param string $format Link anchor format.
     1452 * @param string $link Link permalink format.
     1453 * @param bool $in_same_cat Optional. Whether link should be in a same category.
     1454 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
     1455 * @param bool $previous Optional, default is true. Whether to display link to previous or next post.
     1456 * @return string
     1457 */
     1458function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) {
     1459        echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, $previous );
     1460}
     1461
     1462/**
    14111463 * Retrieve links for page numbers.
    14121464 *
    14131465 * @since 1.5.0