Make WordPress Core

Ticket #40108: 40108.patch

File 40108.patch, 2.6 KB (added by dingo_bastard, 8 years ago)
  • post-template.php

     
    842842 *                                          Also appended to the current item, which is not linked. Default empty.
    843843 *     @type string       $next_or_number   Indicates whether page numbers should be used. Valid values are number
    844844 *                                          and next. Default is 'number'.
     845 *     @type string       $navwidth         Number of links displayed before and after current page.
    845846 *     @type string       $separator        Text between pagination links. Default is ' '.
    846847 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
    847848 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
     
    865866                'nextpagelink'     => __( 'Next page' ),
    866867                'previouspagelink' => __( 'Previous page' ),
    867868                'pagelink'         => '%',
    868                 'echo'             => 1
     869                'echo'             => 1,
    869870        );
    870871
    871872        $params = wp_parse_args( $args, $defaults );
     
    912913                                /** This filter is documented in wp-includes/post-template.php */
    913914                                $output .= apply_filters( 'wp_link_pages_link', $link, $prev );
    914915                        }
     916
     917                        // Output number of links equal to $navwidth before current page.
     918                        if ( 'mixed' == $r['next_or_number'] ) {
     919                                for ( $i = $page - $navwidth; $i < $page; $i++ ) {
     920                                        if ( $i > 0 ) {
     921                                                $link = _wp_link_page( $i ) . $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after'] . '</a>';
     922                                                $link = apply_filters( 'wp_link_pages_link', $link, $i );
     923                                                // Use the custom links separator beginning with the second link.
     924                                                $output .= ( 1 !== $i ) ? $r['separator'] : ' ';
     925                                                $output .= $link;
     926                                        }
     927                                }
     928
     929                                // Output current page within <span> tags for enhanced styling capability.
     930                                if ( $prev ) {
     931                                        $output .= $r['separator'];
     932                                }
     933                                $output .= $r['link_before'] . ('<span>') . str_replace( '%', $i, $r['pagelink'] ) . ('</span>') . $r['link_after'];
     934
     935                                // Output number of links equal to $navwidth after current page.
     936                                for ( $i = $page + 1; $i <= $numpages; $i++ ) {
     937                                        $link = _wp_link_page( $i ) . $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after'] . '</a>';
     938                                        $link = apply_filters( 'wp_link_pages_link', $link, $i );
     939                                        $output .= $r['separator'] . $link;
     940                                }
     941                        }
     942
    915943                        $next = $page + 1;
    916944                        if ( $next <= $numpages ) {
    917945                                if ( $prev ) {