WordPress.org

Make WordPress Core

Ticket #17302: 17302.3.diff

File 17302.3.diff, 5.1 KB (added by SergeyBiryukov, 3 years ago)
  • wp-includes/link-template.php

     
    13261326        return get_posts( array('numberposts' => 1, 'category' => $categories, 'order' => $order, 'update_post_term_cache' => false, 'update_post_meta_cache' => false) ); 
    13271327} 
    13281328 
     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 */ 
     1340function 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 
    13291344/** 
    13301345 * Display previous post link that is adjacent to the current post. 
    13311346 * 
    13321347 * @since 1.5.0 
     1348 * @uses get_previous_post_link() 
    13331349 * 
    13341350 * @param string $format Optional. Link anchor format. 
    13351351 * @param string $link Optional. Link permalink format. 
    13361352 * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    13371353 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
    13381354 */ 
    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); 
     1355function 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 */ 
     1370function 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 ); 
    13411372} 
    13421373 
    13431374/** 
    13441375 * Display next post link that is adjacent to the current post. 
    13451376 * 
    13461377 * @since 1.5.0 
     1378 * @uses get_next_post_link() 
    13471379 * 
    13481380 * @param string $format Optional. Link anchor format. 
    13491381 * @param string $link Optional. Link permalink format. 
    13501382 * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    13511383 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
    13521384 */ 
    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); 
     1385function 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 ); 
    13551387} 
    13561388 
    13571389/** 
    1358  * Display adjacent post link. 
     1390 * Get adjacent post link. 
    13591391 * 
    13601392 * Can be either next post link or previous. 
    13611393 * 
    1362  * @since 2.5.0 
     1394 * @since 3.5.0 
    13631395 * 
    13641396 * @param string $format Link anchor format. 
    13651397 * @param string $link Link permalink format. 
    13661398 * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    13671399 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
    13681400 * @param bool $previous Optional, default is true. Whether to display link to previous or next post. 
     1401 * @return string 
    13691402 */ 
    1370 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { 
     1403function get_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) { 
    13711404        if ( $previous && is_attachment() ) 
    13721405                $post = & get_post($GLOBALS['post']->post_parent); 
    13731406        else 
     
    13931426        $format = str_replace('%link', $link, $format); 
    13941427 
    13951428        $adjacent = $previous ? 'previous' : 'next'; 
    1396         echo apply_filters( "{$adjacent}_post_link", $format, $link ); 
     1429        return apply_filters( "{$adjacent}_post_link", $format, $link ); 
    13971430} 
    13981431 
    13991432/** 
     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 */ 
     1446function 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/** 
    14001451 * Retrieve links for page numbers. 
    14011452 * 
    14021453 * @since 1.5.0