Ticket #7231: patch_next_and_number.diff

File patch_next_and_number.diff, 3.1 KB (added by jan831, 5 years ago)

patch to add this functionality (applies to /trunk/)

Line 
1Index: wp-includes/post-template.php
2===================================================================
3--- wp-includes/post-template.php       (revision 8266)
4+++ wp-includes/post-template.php       (working copy)
5@@ -176,8 +176,21 @@
6 
7        $output = '';
8        if ( $multipage ) {
9-               if ( 'number' == $next_or_number ) {
10-                       $output .= $before;
11+               $output .= $before;
12+               if( 'next' == $next_or_number || 'next_and_number' == $next_or_number ) {
13+                       $i = $page - 1;
14+                       if ( $i && $more ) {
15+                               if ( 1 == $i ) {
16+                                       $output .= '<a href="' . get_permalink() . '">' . $previouspagelink . '</a>';
17+                               } else {
18+                                       if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
19+                                               $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $previouspagelink . '</a>';
20+                                       else
21+                                               $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $previouspagelink . '</a>';
22+                               }
23+                       }
24+               }
25+               if ( 'number' == $next_or_number || 'next_and_number' == $next_or_number ) {
26                        for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {
27                                $j = str_replace('%',"$i",$pagelink);
28                                $output .= ' ';
29@@ -195,35 +208,22 @@
30                                if ( ($i != $page) || ((!$more) && ($page==1)) )
31                                        $output .= '</a>';
32                        }
33-                       $output .= $after;
34-               } else {
35-                       if ( $more ) {
36-                               $output .= $before;
37-                               $i = $page - 1;
38-                               if ( $i && $more ) {
39-                                       if ( 1 == $i ) {
40-                                               $output .= '<a href="' . get_permalink() . '">' . $previouspagelink . '</a>';
41-                                       } else {
42-                                               if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
43-                                                       $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $previouspagelink . '</a>';
44-                                               else
45-                                                       $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $previouspagelink . '</a>';
46-                                       }
47+
48+               }
49+               if( 'next' == $next_or_number || 'next_and_number' == $next_or_number ) {               
50+                       $i = $page + 1;
51+                       if ( $i <= $numpages && $more ) {
52+                               if ( 1 == $i ) {
53+                                       $output .= '<a href="' . get_permalink() . '">' . $nextpagelink . '</a>';
54+                               } else {
55+                                       if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
56+                                               $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $nextpagelink . '</a>';
57+                                       else
58+                                               $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $nextpagelink . '</a>';
59                                }
60-                               $i = $page + 1;
61-                               if ( $i <= $numpages && $more ) {
62-                                       if ( 1 == $i ) {
63-                                               $output .= '<a href="' . get_permalink() . '">' . $nextpagelink . '</a>';
64-                                       } else {
65-                                               if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
66-                                                       $output .= '<a href="' . get_permalink() . '&amp;page=' . $i . '">' . $nextpagelink . '</a>';
67-                                               else
68-                                                       $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $nextpagelink . '</a>';
69-                                       }
70-                               }
71-                               $output .= $after;
72                        }
73-               }
74+               }                                                               
75+               $output .= $after;
76        }
77 
78        if ( $echo )