Ticket #17302: 17302.3.diff
File 17302.3.diff, 5.1 KB (added by , 11 years ago) |
---|
-
wp-includes/link-template.php
1326 1326 return get_posts( array('numberposts' => 1, 'category' => $categories, 'order' => $order, 'update_post_term_cache' => false, 'update_post_meta_cache' => false) ); 1327 1327 } 1328 1328 1329 /* 1330 * Get previous post link that is adjacent to the current post. 1331 * 1332 * @since 3.5.0 1333 * 1334 * @param string $format Optional. Link anchor format. 1335 * @param string $link Optional. Link permalink format. 1336 * @param bool $in_same_cat Optional. Whether link should be in same category. 1337 * @param string $excluded_categories Optional. Excluded categories IDs. 1338 * @return string 1339 */ 1340 function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) { 1341 return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, true ); 1342 } 1343 1329 1344 /** 1330 1345 * Display previous post link that is adjacent to the current post. 1331 1346 * 1332 1347 * @since 1.5.0 1348 * @uses get_previous_post_link() 1333 1349 * 1334 1350 * @param string $format Optional. Link anchor format. 1335 1351 * @param string $link Optional. Link permalink format. 1336 1352 * @param bool $in_same_cat Optional. Whether link should be in a same category. 1337 1353 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 1338 1354 */ 1339 function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { 1340 adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true); 1355 function previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) { 1356 echo get_previous_post_link( $format, $link, $in_same_cat, $excluded_categories ); 1357 } 1358 1359 /** 1360 * Get previous post link that is adjacent to the current post. 1361 * 1362 * @since 3.5.0 1363 * 1364 * @param string $format Optional. Link anchor format. 1365 * @param string $link Optional. Link permalink format. 1366 * @param bool $in_same_cat Optional. Whether link should be in same category. 1367 * @param string $excluded_categories Optional. Excluded categories IDs. 1368 * @return string 1369 */ 1370 function get_next_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) { 1371 return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, false ); 1341 1372 } 1342 1373 1343 1374 /** 1344 1375 * Display next post link that is adjacent to the current post. 1345 1376 * 1346 1377 * @since 1.5.0 1378 * @uses get_next_post_link() 1347 1379 * 1348 1380 * @param string $format Optional. Link anchor format. 1349 1381 * @param string $link Optional. Link permalink format. 1350 1382 * @param bool $in_same_cat Optional. Whether link should be in a same category. 1351 1383 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 1352 1384 */ 1353 function next_post_link( $format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') {1354 adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);1385 function next_post_link( $format = '%link »', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) { 1386 echo get_next_post_link( $format, $link, $in_same_cat, $excluded_categories ); 1355 1387 } 1356 1388 1357 1389 /** 1358 * Displayadjacent post link.1390 * Get adjacent post link. 1359 1391 * 1360 1392 * Can be either next post link or previous. 1361 1393 * 1362 * @since 2.5.01394 * @since 3.5.0 1363 1395 * 1364 1396 * @param string $format Link anchor format. 1365 1397 * @param string $link Link permalink format. 1366 1398 * @param bool $in_same_cat Optional. Whether link should be in a same category. 1367 1399 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 1368 1400 * @param bool $previous Optional, default is true. Whether to display link to previous or next post. 1401 * @return string 1369 1402 */ 1370 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {1403 function get_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) { 1371 1404 if ( $previous && is_attachment() ) 1372 1405 $post = & get_post($GLOBALS['post']->post_parent); 1373 1406 else … … 1393 1426 $format = str_replace('%link', $link, $format); 1394 1427 1395 1428 $adjacent = $previous ? 'previous' : 'next'; 1396 echoapply_filters( "{$adjacent}_post_link", $format, $link );1429 return apply_filters( "{$adjacent}_post_link", $format, $link ); 1397 1430 } 1398 1431 1399 1432 /** 1433 * Display adjacent post link. 1434 * 1435 * Can be either next post link or previous. 1436 * 1437 * @since 2.5.0 1438 * @uses get_adjacent_post_link() 1439 * 1440 * @param string $format Link anchor format. 1441 * @param string $link Link permalink format. 1442 * @param bool $in_same_cat Optional. Whether link should be in same category. 1443 * @param string $excluded_categories Optional. Excluded categories IDs. 1444 * @param bool $previous Optional, default is true. Whether display link to previous post. 1445 */ 1446 function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) { 1447 echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, $previous ); 1448 } 1449 1450 /** 1400 1451 * Retrieve links for page numbers. 1401 1452 * 1402 1453 * @since 1.5.0