Make WordPress Core

Ticket #17302: 17302.diff

File 17302.diff, 5.1 KB (added by wonderboymusic, 11 years ago)
  • src/wp-includes/link-template.php

     
    13371337        return get_posts( array('numberposts' => 1, 'category' => $categories, 'order' => $order, 'update_post_term_cache' => false, 'update_post_meta_cache' => false) );
    13381338}
    13391339
     1340/*
     1341 * Get previous post link that is adjacent to the current post.
     1342 *
     1343 * @since 3.7.0
     1344 *
     1345 * @param string $format Optional. Link anchor format.
     1346 * @param string $link Optional. Link permalink format.
     1347 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1348 * @param string $excluded_categories Optional. Excluded categories IDs.
     1349 * @return string
     1350 */
     1351function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) {
     1352        return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, true );
     1353}
     1354
    13401355/**
    13411356 * Display previous post link that is adjacent to the current post.
    13421357 *
    13431358 * @since 1.5.0
     1359 * @uses get_previous_post_link()
    13441360 *
    13451361 * @param string $format Optional. Link anchor format.
    13461362 * @param string $link Optional. Link permalink format.
    13471363 * @param bool $in_same_cat Optional. Whether link should be in a same category.
    13481364 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
    13491365 */
    1350 function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    1351         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
     1366function previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) {
     1367        echo get_previous_post_link( $format, $link, $in_same_cat, $excluded_categories );
    13521368}
    13531369
    13541370/**
     1371 * Get previous post link that is adjacent to the current post.
     1372 *
     1373 * @since 3.7.0
     1374 * @uses get_next_post_link()
     1375 *
     1376 * @param string $format Optional. Link anchor format.
     1377 * @param string $link Optional. Link permalink format.
     1378 * @param bool $in_same_cat Optional. Whether link should be in same category.
     1379 * @param string $excluded_categories Optional. Excluded categories IDs.
     1380 * @return string
     1381 */
     1382function get_next_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) {
     1383        return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, false );
     1384}
     1385
     1386/**
    13551387 * Display next post link that is adjacent to the current post.
    13561388 *
    13571389 * @since 1.5.0
     
    13611393 * @param bool $in_same_cat Optional. Whether link should be in a same category.
    13621394 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
    13631395 */
    1364 function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    1365         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
     1396function next_post_link( $format = '%link »', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) {
     1397         echo get_next_post_link( $format, $link, $in_same_cat, $excluded_categories );
    13661398}
    13671399
    13681400/**
    1369  * Display adjacent post link.
     1401 * Get adjacent post link.
    13701402 *
    13711403 * Can be either next post link or previous.
    13721404 *
    1373  * @since 2.5.0
     1405 * @since 3.7.0
    13741406 *
    13751407 * @param string $format Link anchor format.
    13761408 * @param string $link Link permalink format.
    13771409 * @param bool $in_same_cat Optional. Whether link should be in a same category.
    13781410 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
    13791411 * @param bool $previous Optional, default is true. Whether to display link to previous or next post.
     1412 * @return string
    13801413 */
    1381 function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) {
     1414function get_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) {
    13821415        if ( $previous && is_attachment() )
    13831416                $post = get_post( get_post()->post_parent );
    13841417        else
     
    14061439
    14071440        $adjacent = $previous ? 'previous' : 'next';
    14081441
    1409         echo apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post );
     1442        return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post );
    14101443}
    14111444
    14121445/**
     1446 * Display adjacent post link.
     1447 *
     1448 * Can be either next post link or previous.
     1449 *
     1450 * @since 2.5.0
     1451 * @uses get_adjacent_post_link()
     1452 *
     1453 * @param string $format Link anchor format.
     1454 * @param string $link Link permalink format.
     1455 * @param bool $in_same_cat Optional. Whether link should be in a same category.
     1456 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
     1457 * @param bool $previous Optional, default is true. Whether to display link to previous or next post.
     1458 * @return string
     1459 */
     1460function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) {
     1461        echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, $previous );
     1462}
     1463
     1464/**
    14131465 * Retrieve links for page numbers.
    14141466 *
    14151467 * @since 1.5.0