Ticket #17302: 17302.2.diff
File 17302.2.diff, 5.5 KB (added by , 12 years ago) |
---|
-
wp-includes/link-template.php
function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $pr 1128 1128 } 1129 1129 1130 1130 $excluded_categories = array_map( 'intval', $excluded_categories ); 1131 1131 1132 1132 if ( ! empty( $cat_array ) ) { 1133 1133 $excluded_categories = array_diff($excluded_categories, $cat_array); 1134 1134 $posts_in_ex_cats_sql = ''; … … function get_boundary_post( $in_same_cat = false, $excluded_categories = '', $st 1276 1276 $cat_array = array(); 1277 1277 if( ! is_array( $excluded_categories ) ) 1278 1278 $excluded_categories = explode( ',', $excluded_categories ); 1279 1279 1280 1280 if ( $in_same_cat || ! empty( $excluded_categories ) ) { 1281 1281 if ( $in_same_cat ) 1282 1282 $cat_array = wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) ); … … function parent_post_rel_link($title = '%title') { 1410 1410 } 1411 1411 1412 1412 /** 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 */ 1423 function 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 /** 1413 1428 * Display previous post link that is adjacent to the current post. 1414 1429 * 1415 1430 * @since 1.5.0 1431 * @uses get_previous_post_link() 1416 1432 * 1417 1433 * @param string $format Optional. Link anchor format. 1418 1434 * @param string $link Optional. Link permalink format. … … function parent_post_rel_link($title = '%title') { 1420 1436 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 1421 1437 */ 1422 1438 function 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 */ 1453 function 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); 1424 1455 } 1425 1456 1426 1457 /** 1427 1458 * Display next post link that is adjacent to the current post. 1428 1459 * 1429 1460 * @since 1.5.0 1461 * @uses get_next_post_link() 1430 1462 * 1431 1463 * @param string $format Optional. Link anchor format. 1432 1464 * @param string $link Optional. Link permalink format. … … function previous_post_link($format='« %link', $link='%title', $in_same_ca 1434 1466 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 1435 1467 */ 1436 1468 function 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); 1438 1470 } 1439 1471 1440 1472 /** 1441 * Displayadjacent post link.1473 * Get adjacent post link. 1442 1474 * 1443 1475 * Can be either next post link or previous. 1444 1476 * 1445 * @since 2.5.01477 * @since 3.3.0 1446 1478 * 1447 1479 * @param string $format Link anchor format. 1448 1480 * @param string $link Link permalink format. 1449 1481 * @param bool $in_same_cat Optional. Whether link should be in same category. 1450 1482 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 1451 1483 * @param bool $previous Optional, default is true. Whether display link to previous post. 1484 * @return string 1452 1485 */ 1453 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {1486 function get_adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { 1454 1487 if ( $previous && is_attachment() ) 1455 1488 $post = & get_post($GLOBALS['post']->post_parent); 1456 1489 else … … function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_cate 1476 1509 $format = str_replace('%link', $link, $format); 1477 1510 1478 1511 $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 */ 1530 function 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 ); 1480 1532 } 1481 1533 1482 1534 /**