Ticket #4209: 4209-nextgen.diff
File 4209-nextgen.diff, 3.8 KB (added by , 16 years ago) |
---|
-
wp-includes/default-filters.php
160 160 add_action('wp_head', 'locale_stylesheet'); 161 161 add_action('publish_future_post', 'wp_publish_post', 10, 1); 162 162 add_action('wp_head', 'noindex', 1); 163 add_action( 'wp_head', 'link_rel_prev_next' ); 163 164 add_action('wp_head', 'wp_print_scripts'); 164 165 if(!defined('DOING_CRON')) 165 166 add_action('init', 'wp_cron'); -
wp-includes/link-template.php
352 352 353 353 // Navigation links 354 354 355 function get_previous_post($in_same_cat = false, $excluded_categories = '') { 356 global $post, $wpdb; 355 function get_previous_post($in_same_cat = false, $excluded_categories = '', $id = 0) { 356 global $wpdb; 357 358 $post = &get_post( $id ); 357 359 358 360 if( !is_single() || is_attachment() ) 359 361 return null; … … 389 391 return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join $where $sort"); 390 392 } 391 393 392 function get_next_post($in_same_cat = false, $excluded_categories = '') { 393 global $post, $wpdb; 394 function get_next_post($in_same_cat = false, $excluded_categories = '', $id = 0) { 395 global $wpdb; 396 397 $post = &get_post( $id ); 394 398 395 399 if( !is_single() || is_attachment() ) 396 400 return null; … … 438 442 return; 439 443 440 444 $title = apply_filters('the_title', $post->post_title, $post); 441 $string = '<a href="'.get_permalink($post->ID).'" >';445 $string = '<a href="'.get_permalink($post->ID).'" rel="prev">'; 442 446 $link = str_replace('%title', $title, $link); 443 447 $link = $pre . $string . $link . '</a>'; 444 448 … … 454 458 return; 455 459 456 460 $title = apply_filters('the_title', $post->post_title, $post); 457 $string = '<a href="'.get_permalink($post->ID).'" >';461 $string = '<a href="'.get_permalink($post->ID).'" rel="next">'; 458 462 $link = str_replace('%title', $title, $link); 459 463 $link = $string . $link . '</a>'; 460 464 $format = str_replace('%link', $link, $format); … … 607 611 } 608 612 } 609 613 610 ?> 614 function link_rel_prev_next( $id = 0 ) { 615 if ( !is_single() ) { 616 return; 617 } 618 619 $prev_url = ''; 620 $next_url = ''; 621 622 $post = get_post( $id ); 623 setup_postdata( $post ); 624 625 global $multipage, $numpages, $pagenow, $page, $wp_rewrite; 626 627 if ( $multipage ) { 628 global $numpages, $pagenow, $page; 629 630 if ( $page == 1 ) { 631 if ( $prev_post = get_previous_post( false, '', $post->ID ) ) { 632 $prev_url = get_permalink( $prev_post->ID ); 633 } 634 } else { 635 if ( !$wp_rewrite->using_permalinks() || $post->post_status == 'draft' ) { 636 $prev_url = add_query_arg( 'page', $page - 1, get_permalink() ); 637 } else { 638 $prev_url = trailingslashit( get_permalink() ) . user_trailingslashit( $page - 1, 'single_paged' ); 639 } 640 } 641 642 if ( $page == $numpages ) { 643 if ( $next_post = get_next_post( false, '', $post->ID ) ) { 644 $next_url = get_permalink( $next_post->ID ); 645 } 646 } else { 647 if ( !$wp_rewrite->using_permalinks() || $post->post_status == 'draft' ) { 648 $next_url = add_query_arg( 'page', $page + 1, get_permalink( $post->ID ) ); 649 } else { 650 $next_url = trailingslashit( get_permalink() ) . user_trailingslashit( $page + 1, 'single_paged' ); 651 } 652 } 653 } else { 654 if ( $prev_post = get_previous_post( false, '', $post->ID ) ) { 655 $prev_url = get_permalink( $prev_post->ID ); 656 } 657 658 if ( $next_post = get_next_post( false, '', $post->ID ) ) { 659 $next_url = get_permalink( $next_post->ID ); 660 } 661 } 662 663 if ( !empty( $prev_url ) ) { 664 printf( '<link rel="prev" href="%s" />' . "\n", $prev_url ); 665 } 666 667 if ( !empty( $next_url ) ) { 668 printf( '<link rel="next" href="%s" />' . "\n", $next_url ); 669 } 670 } 671 672 ?> 673 No newline at end of file