Make WordPress Core

Ticket #40108: 40108.2.patch

File 40108.2.patch, 4.2 KB (added by mshumacher, 5 years ago)
  • post-template.php

     
    862862 * Quicktag one or more times). This tag must be within The Loop.
    863863 *
    864864 * @since 1.2.0
    865  * @since 5.0.0 Added the `aria_current` argument.
     865 * @since 5.0.0 Added the `aria_current` argument and `mixed` as possible value for `next_or_number` argument
    866866 *
    867867 * @global int $page
    868868 * @global int $numpages
     
    880880 *                                          Also appended to the current item, which is not linked. Default empty.
    881881 *     @type string       $aria_current     The value for the aria-current attribute. Possible values are 'page',
    882882 *                                          'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
    883  *     @type string       $next_or_number   Indicates whether page numbers should be used. Valid values are number
    884  *                                          and next. Default is 'number'.
     883 *     @type string       $next_or_number   Controls the formatting of navigation links. Valid values are 'next', 'number'
     884 *                                          and 'mixed'. Default is 'number'.
    885885 *     @type string       $separator        Text between pagination links. Default is ' '.
    886886 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
    887887 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
     
    902902                'link_after'       => '',
    903903                'aria_current'     => 'page',
    904904                'next_or_number'   => 'number',
     905                'navwidth'         => '3',
    905906                'separator'        => ' ',
    906907                'nextpagelink'     => __( 'Next page' ),
    907908                'previouspagelink' => __( 'Previous page' ),
     
    954955
    955956                                /** This filter is documented in wp-includes/post-template.php */
    956957                                $output .= apply_filters( 'wp_link_pages_link', $link, $prev );
    957                         }
     958                               
     959                                        // Output number of links equal to $navwidth before current page
     960                    if ( 'mixed' == $r['next_or_number'] ) {
     961                                    For ( $i = $page - $navwidth; $i < $page; $i++) {
     962                                                    if ( $i > 0) {
     963                                                    $link = _wp_link_page( $i ) . $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after'] . '</a>';
     964                                                    $link = apply_filters( 'wp_link_pages_link', $link, $i );
     965                                                   
     966                                                    // Use the custom links separator beginning with the second link.
     967                                                    $output .= ( 1 === $i ) ? ' ' : $r['separator'];
     968                                                    $output .= $link
     969                                                    }
     970                                    }
     971                                    // Output current page within <span> tags for enhanced styling capability
     972                                    if ( $prev ) {
     973                                                    $output .= $r['separator'];
     974                                    }
     975                                    $output .= $r['link_before'] . ('<span class="post-page-numbers current" aria-current="' . esc_attr( $r['aria_current'] ) . '">') . str_replace( '%', $i, $r['pagelink'] ) . ('</span>') . $r['link_after'];
     976                                   
     977                                    // Output number of links equal to $navwidth after current page
     978                                    For ($i = $page + 1; $i <= $numpages; $i++) {
     979                                                    $link = _wp_link_page( $i ) . $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after'] . '</a>';
     980                                                    $link = apply_filters( 'wp_link_pages_link', $link, $i );
     981                                                    $output .= $r['separator'] . $link;
     982                                    }                           
     983                                        }
    958984                        $next = $page + 1;
    959985                        if ( $next <= $numpages ) {
    960986                                if ( $prev ) {