Ticket #17302: get_adjacent_post_link.diff
File get_adjacent_post_link.diff, 4.3 KB (added by , 13 years ago) |
---|
-
wp-includes/link-template.php
1400 1400 } 1401 1401 1402 1402 /** 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 */ 1413 function 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 /** 1403 1418 * Display previous post link that is adjacent to the current post. 1404 1419 * 1405 1420 * @since 1.5.0 1421 * @uses get_previous_post_link() 1406 1422 * 1407 1423 * @param string $format Optional. Link anchor format. 1408 1424 * @param string $link Optional. Link permalink format. … … 1410 1426 * @param string $excluded_categories Optional. Excluded categories IDs. 1411 1427 */ 1412 1428 function 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); 1414 1430 } 1415 1431 1416 1432 /** 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 */ 1443 function 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 /** 1417 1448 * Display next post link that is adjacent to the current post. 1418 1449 * 1419 1450 * @since 1.5.0 1451 * @uses get_next_post_link() 1420 1452 * 1421 1453 * @param string $format Optional. Link anchor format. 1422 1454 * @param string $link Optional. Link permalink format. … … 1424 1456 * @param string $excluded_categories Optional. Excluded categories IDs. 1425 1457 */ 1426 1458 function 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); 1428 1460 } 1429 1461 1430 1462 /** 1431 * Displayadjacent post link.1463 * Get adjacent post link. 1432 1464 * 1433 1465 * Can be either next post link or previous. 1434 1466 * 1435 * @since 2.5.01467 * @since 3.2.0 1436 1468 * 1437 1469 * @param string $format Link anchor format. 1438 1470 * @param string $link Link permalink format. 1439 1471 * @param bool $in_same_cat Optional. Whether link should be in same category. 1440 1472 * @param string $excluded_categories Optional. Excluded categories IDs. 1441 1473 * @param bool $previous Optional, default is true. Whether display link to previous post. 1474 * @return string 1442 1475 */ 1443 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {1476 function get_adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { 1444 1477 if ( $previous && is_attachment() ) 1445 1478 $post = & get_post($GLOBALS['post']->post_parent); 1446 1479 else … … 1469 1502 echo apply_filters( "{$adjacent}_post_link", $format, $link ); 1470 1503 } 1471 1504 1505 1472 1506 /** 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 */ 1520 function 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 /** 1473 1525 * Retrieve get links for page numbers. 1474 1526 * 1475 1527 * @since 1.5.0