Changeset 21802
- Timestamp:
- 09/10/2012 09:36:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r21735 r21802 1365 1365 * @param bool $previous Optional, default is true. Whether to display link to previous or next post. 1366 1366 */ 1367 function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {1367 function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) { 1368 1368 if ( $previous && is_attachment() ) 1369 1369 $post = get_post( get_post()->post_parent ); 1370 1370 else 1371 $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous); 1372 1373 if ( !$post ) 1374 return; 1375 1376 $title = $post->post_title; 1377 1378 if ( empty($post->post_title) ) 1379 $title = $previous ? __('Previous Post') : __('Next Post'); 1380 1381 $title = apply_filters('the_title', $title, $post->ID); 1382 $date = mysql2date(get_option('date_format'), $post->post_date); 1383 $rel = $previous ? 'prev' : 'next'; 1384 1385 $string = '<a href="'.get_permalink($post).'" rel="'.$rel.'">'; 1386 $link = str_replace('%title', $title, $link); 1387 $link = str_replace('%date', $date, $link); 1388 $link = $string . $link . '</a>'; 1389 1390 $format = str_replace('%link', $link, $format); 1371 $post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous ); 1372 1373 if ( ! $post ) { 1374 $output = ''; 1375 } else { 1376 $title = $post->post_title; 1377 1378 if ( empty( $post->post_title ) ) 1379 $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); 1380 1381 $title = apply_filters( 'the_title', $title, $post->ID ); 1382 $date = mysql2date( get_option( 'date_format' ), $post->post_date ); 1383 $rel = $previous ? 'prev' : 'next'; 1384 1385 $string = '<a href="' . get_permalink( $post ) . '" rel="'.$rel.'">'; 1386 $inlink = str_replace( '%title', $title, $link ); 1387 $inlink = str_replace( '%date', $date, $inlink ); 1388 $inlink = $string . $inlink . '</a>'; 1389 1390 $output = str_replace( '%link', $inlink, $format ); 1391 } 1391 1392 1392 1393 $adjacent = $previous ? 'previous' : 'next'; 1393 echo apply_filters( "{$adjacent}_post_link", $format, $link ); 1394 1395 echo apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post ); 1394 1396 } 1395 1397
Note: See TracChangeset
for help on using the changeset viewer.