Ticket #13578: post_template-wp_link_pages.diff
File post_template-wp_link_pages.diff, 7.5 KB (added by , 13 years ago) |
---|
-
post-template.php
536 536 * Quicktag one or more times). This tag must be within The Loop. 537 537 * 538 538 * The defaults for overwriting are: 539 * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to 540 * each bookmarks. 541 * 'after' - Default is '</p>' (string). The html or text to append to each 542 * bookmarks. 543 * 'link_before' - Default is '' (string). The html or text to prepend to each 544 * Pages link inside the <a> tag. 545 * 'link_after' - Default is '' (string). The html or text to append to each 546 * Pages link inside the <a> tag. 539 547 * 'next_or_number' - Default is 'number' (string). Indicates whether page 540 548 * numbers should be used. Valid values are number and next. 541 549 * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page. 542 550 * of the bookmark. 551 * 'separator' - Default is ' ' (string). Text used only between numbers. 543 552 * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to 544 553 * previous page, if available. 545 554 * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in 546 555 * the parameter string will be replaced with the page number, so Page % 547 556 * generates "Page 1", "Page 2", etc. Defaults to %, just the page number. 548 * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to 549 * each bookmarks. 550 * 'after' - Default is '</p>' (string). The html or text to append to each 551 * bookmarks. 552 * 'link_before' - Default is '' (string). The html or text to prepend to each 553 * Pages link inside the <a> tag. 554 * 'link_after' - Default is '' (string). The html or text to append to each 555 * Pages link inside the <a> tag. 557 * 'echo' - Default is 1 (integer). When not 0, this triggers the text to be 558 * echoed as well as returned. 556 559 * 557 560 * @since 1.2.0 558 561 * @access private … … 562 565 */ 563 566 function wp_link_pages($args = '') { 564 567 $defaults = array( 565 'before' => '<p>' . __('Pages:'), 'after' => '</p>', 566 'link_before' => '', 'link_after' => '', 567 'next_or_number' => 'number', 'nextpagelink' => __('Next page'), 568 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 568 'before' => '<p>' . __('Pages:'), 569 'after' => '</p>', 570 'link_before' => '', 571 'link_after' => '', 572 'next_or_number' => 'number', 573 'nextpagelink' => __('Next page'), 574 'separator' => ' ', 575 'previouspagelink' => __('Previous page'), 576 'pagelink' => '%', 569 577 'echo' => 1 570 578 ); 571 579 … … 581 589 $output .= $before; 582 590 for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) { 583 591 $j = str_replace('%',$i,$pagelink); 584 $output .= ' '; 592 if ($output != $before) { 593 $output .= $separator; 594 } 585 595 if ( ($i != $page) || ((!$more) && ($page==1)) ) { 586 596 if ( 1 == $i ) { 587 $output .= '<a href="' . get_permalink() . '">';597 $output .= '<a class="pag_nav_num pag_nav_first" href="' . get_permalink() . '">'; 588 598 } else { 589 599 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 590 $output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">';600 $output .= '<a class="pag_nav_num" href="' . add_query_arg('page', $i, get_permalink()) . '">'; 591 601 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 592 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">';602 $output .= '<a class="pag_nav_num" href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">'; 593 603 else 594 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';604 $output .= '<a class="pag_nav_num' . ($i >= $numpages ? ' pag_nav_last':'') . '" href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">'; 595 605 } 596 606 } else { 607 $output .= '<span class="pag_nav_num pag_nav_current' . ($i <= 1 ? ' pag_nav_first':($i >= $numpages ? ' pag_nav_last':'')) . '">'; 597 608 } 598 609 $output .= $link_before; 599 610 $output .= $j; 600 611 $output .= $link_after; 601 if ( ($i != $page) || ((!$more) && ($page==1)) ) 612 if ( ($i != $page) || ((!$more) && ($page==1)) ) { 602 613 $output .= '</a>'; 614 } else { 615 $output .= '</span>'; 616 } 603 617 } 604 618 $output .= $after; 605 619 } else { 606 620 if ( $more ) { 607 621 $output .= $before; 608 622 $i = $page - 1; 609 if ( $i && $more) {623 if ( ($i > 0) && $more && ($previouspagelink != "")) { 610 624 if ( 1 == $i ) { 611 $output .= '<a href="' . get_permalink() . '">';625 $output .= '<a class="pag_nav_prev pag_nav_first" href="' . get_permalink() . '">' . $link_before . $previouspagelink . $link_after . '</a>'; 612 626 } else { 613 627 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 614 $output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">';628 $output .= '<a class="pag_nav_prev" href="' . add_query_arg('page', $i, get_permalink()) . '">' . $link_before . $previouspagelink . $link_after . '</a>'; 615 629 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 616 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">';630 $output .= '<a class="pag_nav_prev" href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">'; 617 631 else 618 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';632 $output .= '<a class="pag_nav_prev" href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $link_before. $previouspagelink . $link_after . '</a>'; 619 633 } 620 $output .= $link_before. $previouspagelink . $link_after . '</a>';621 634 } 622 635 $i = $page + 1; 623 if ( $i <= $numpages && $more) {636 if ( ($i <= $numpages) && $more && ($nextpagelink != "")) { 624 637 if ( 1 == $i ) { 625 $output .= '<a href="' . get_permalink() . '">';638 $output .= '<a class="pag_nav_next first" href="' . get_permalink() . '">' . $link_before . $nextpagelink . $link_after . '</a>'; 626 639 } else { 627 640 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 628 $output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">';641 $output .= '<a class="pag_nav_next" href="' . add_query_arg('page', $i, get_permalink()) . '">' . $link_before . $nextpagelink . $link_after . '</a>'; 629 642 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 630 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">';643 $output .= '<a class="pag_nav_next" href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">'; 631 644 else 632 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';645 $output .= '<a class="pag_nav_next" href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $link_before. $nextpagelink . $link_after . '</a>'; 633 646 } 634 $output .= $link_before. $nextpagelink . $link_after . '</a>';635 647 } 636 648 $output .= $after; 637 649 }