779 | | * @type string $before HTML or text to prepend to each link. Default is `<p> Pages:`. |
780 | | * @type string $after HTML or text to append to each link. Default is `</p>`. |
781 | | * @type string $link_before HTML or text to prepend to each link, inside the `<a>` tag. |
782 | | * Also prepended to the current item, which is not linked. Default empty. |
783 | | * @type string $link_after HTML or text to append to each Pages link inside the `<a>` tag. |
784 | | * Also appended to the current item, which is not linked. Default empty. |
785 | | * @type string $next_or_number Indicates whether page numbers should be used. Valid values are number |
786 | | * and next. Default is 'number'. |
787 | | * @type string $separator Text between pagination links. Default is ' '. |
788 | | * @type string $nextpagelink Link text for the next page link, if available. Default is 'Next Page'. |
789 | | * @type string $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'. |
790 | | * @type string $pagelink Format string for page numbers. The % in the parameter string will be |
791 | | * replaced with the page number, so 'Page %' generates "Page 1", "Page 2", etc. |
792 | | * Defaults to '%', just the page number. |
793 | | * @type int|bool $echo Whether to echo or not. Accepts 1|true or 0|false. Default 1|true. |
| 779 | * @type string $before HTML or text to prepend to each link. Default is `<p> Pages:`. |
| 780 | * @type string $after HTML or text to append to each link. Default is `</p>`. |
| 781 | * @type string $link_before HTML or text to prepend to each link, inside the `<a>` tag. |
| 782 | * Also prepended to the current item, which is not linked. Default empty. |
| 783 | * @type string $link_after HTML or text to append to each Pages link inside the `<a>` tag. |
| 784 | * Also appended to the current item, which is not linked. Default empty. |
| 785 | * @type string $next_or_number Indicates whether page numbers should be used. Valid values are number |
| 786 | * and next. Default is 'number'. |
| 787 | * @type string $separator Text between pagination links. Default is ' '. |
| 788 | * @type string $nextpagelink Link text for the next page link, if available. Default is 'Next Page'. |
| 789 | * @type string $nextpageclass Class for link text for the next page link, if available. Default is 'next'. |
| 790 | * @type string $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'. |
| 791 | * @type string $previouspageclass Class for link text for the previous page link, if available. Default is 'previous'. |
| 792 | * @type string $pagelink Format string for page numbers. The % in the parameter string will be |
| 793 | * replaced with the page number, so 'Page %' generates "Page 1", "Page 2", etc. |
| 794 | * Defaults to '%', just the page number. |
| 795 | * @type int|bool $echo Whether to echo or not. Accepts 1|true or 0|false. Default 1|true. |
827 | | $output .= $r['before']; |
828 | | for ( $i = 1; $i <= $numpages; $i++ ) { |
829 | | $link = $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after']; |
830 | | if ( $i != $page || ! $more && 1 == $page ) { |
831 | | $link = _wp_link_page( $i ) . $link . '</a>'; |
| 832 | $output .= _wp_link_pages_numbers( $r ); |
| 833 | } elseif ( 'next_and_number' == $r['next_or_number'] ) { |
| 834 | $prev = $page - 1; |
| 835 | if ( $prev > 0 ) { |
| 836 | $link = _wp_link_page( $prev, 'previous' ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>'; |
| 837 | |
| 838 | /** This filter is documented in wp-includes/post-template.php */ |
| 839 | $output .= apply_filters( 'wp_link_pages_link', $link, $prev ); |
| 840 | } |
| 841 | $output .= _wp_link_pages_numbers( $r ); |
| 842 | $next = $page + 1; |
| 843 | if ( $next <= $numpages ) { |
| 844 | if ( $prev ) { |
| 845 | $output .= $r['separator']; |
| 935 | /** |
| 936 | * Creates and returns number based page links for paginated posts |
| 937 | * (i.e. includes the <!--nextpage-->. Quicktag one or more times). This tag must be within The Loop. |
| 938 | * |
| 939 | * Helper function for wp_link_pages(). |
| 940 | * @since 4.4 |
| 941 | * @access private |
| 942 | * |
| 943 | * @global int $page |
| 944 | * @global int $numpages |
| 945 | * @global int $more |
| 946 | * |
| 947 | * @param $params |
| 948 | * |
| 949 | * @return string |
| 950 | */ |
| 951 | function _wp_link_pages_numbers( $params ) { |
| 952 | global $page, $numpages, $more; |
| 953 | |
| 954 | $output = ''; |
| 955 | for ( $i = 1; $i <= $numpages; $i++ ) { |
| 956 | $link = $params['link_before'] . str_replace( '%', $i, $params['pagelink'] ) . $params['link_after']; |
| 957 | if ( $i != $page || ! $more && 1 == $page ) { |
| 958 | $link = _wp_link_page( $i ) . $link . '</a>'; |
| 959 | } |
| 960 | /** |
| 961 | * Filter the HTML output of individual page number links. |
| 962 | * |
| 963 | * @since 3.6.0 |
| 964 | * |
| 965 | * @param string $link The page number HTML output. |
| 966 | * @param int $i Page number for paginated posts' page links. |
| 967 | */ |
| 968 | $link = apply_filters( 'wp_link_pages_link', $link, $i ); |
| 969 | |
| 970 | // Use the custom links separator beginning with the second link. |
| 971 | $output .= ( 1 === $i ) ? ' ' : $params['separator']; |
| 972 | $output .= $link; |
| 973 | } |
| 974 | return $output; |
| 975 | } |
| 976 | |