WordPress.org

Make WordPress Core

Ticket #19652: 19652-patch.diff

File 19652-patch.diff, 2.8 KB (added by Master Jake, 4 years ago)
  • wp-includes/link-template.php

     
    13101310 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
    13111311 */ 
    13121312function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { 
    1313         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true); 
     1313        echo get_previous_post_link( $format, $link, $in_same_cat, $excluded_categories ); 
    13141314} 
    13151315 
    13161316/** 
     1317 * needs-docs if accepted... 
     1318 */ 
     1319function get_previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { 
     1320        return adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, true, true ); 
     1321} 
     1322 
     1323/** 
    13171324 * Display next post link that is adjacent to the current post. 
    13181325 * 
    13191326 * @since 1.5.0 
     
    13241331 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
    13251332 */ 
    13261333function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { 
    1327         adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false); 
     1334        echo get_next_post_link( $format, $link, $in_same_cat, $excluded_categories ); 
    13281335} 
    13291336 
    13301337/** 
     1338 * needs-docs if accepted... 
     1339 */ 
     1340function get_next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { 
     1341        return adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, false, true ); 
     1342} 
     1343 
     1344/** 
    13311345 * Display adjacent post link. 
    13321346 * 
    13331347 * Can be either next post link or previous. 
     
    13391353 * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    13401354 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
    13411355 * @param bool $previous Optional, default is true. Whether to display link to previous or next post. 
     1356 * @param bool $return Optional, default is false. Whether to return the link or echo it. 
    13421357 */ 
    1343 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { 
     1358function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true, $return = false) { 
    13441359        if ( $previous && is_attachment() ) 
    13451360                $post = & get_post($GLOBALS['post']->post_parent); 
    13461361        else 
     
    13661381        $format = str_replace('%link', $link, $format); 
    13671382 
    13681383        $adjacent = $previous ? 'previous' : 'next'; 
    1369         echo apply_filters( "{$adjacent}_post_link", $format, $link ); 
     1384         
     1385        if ( $return ) 
     1386                return apply_filters( "{$adjacent}_post_link", $format, $link ); 
     1387        else 
     1388                echo apply_filters( "{$adjacent}_post_link", $format, $link ); 
    13701389} 
    13711390 
    13721391/**