<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[15582] trunk/wp-includes: Don't hardcode the pagination base.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15582">15582</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-09-07 01:18:42 +0000 (Tue, 07 Sep 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Don't hardcode the pagination base. Fixes <a href="http://trac.wordpress.org/ticket/12507">#12507</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescanonicalphp">trunk/wp-includes/canonical.php</a></li>
<li><a href="#trunkwpincludeslinktemplatephp">trunk/wp-includes/link-template.php</a></li>
<li><a href="#trunkwpincludesposttemplatephp">trunk/wp-includes/post-template.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
<li><a href="#trunkwpincludesrewritephp">trunk/wp-includes/rewrite.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescanonicalphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/canonical.php (15581 => 15582)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/canonical.php        2010-09-06 11:28:59 UTC (rev 15581)
+++ trunk/wp-includes/canonical.php        2010-09-07 01:18:42 UTC (rev 15582)
</span><span class="lines">@@ -191,9 +191,9 @@
</span><span class="cx">                         if ( !$redirect_url )
</span><span class="cx">                                 $redirect_url = $requested_url;
</span><span class="cx">                         $paged_redirect = @parse_url($redirect_url);
</span><del>-                        while ( preg_match( '#/page/?[0-9]+?(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $paged_redirect['path'] ) ) {
</del><ins>+                        while ( preg_match( &quot;#/$wp_rewrite-&gt;pagination_base/?[0-9]+?(/+)?$#&quot;, $paged_redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $paged_redirect['path'] ) ) {
</ins><span class="cx">                                 // Strip off paging and feed
</span><del>-                                $paged_redirect['path'] = preg_replace('#/page/?[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing paging
</del><ins>+                                $paged_redirect['path'] = preg_replace(&quot;#/$wp_rewrite-&gt;pagination_base/?[0-9]+?(/+)?$#&quot;, '/', $paged_redirect['path']); // strip off any existing paging
</ins><span class="cx">                                 $paged_redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $paged_redirect['path']); // strip off feed endings
</span><span class="cx">                                 $paged_redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing comment paging
</span><span class="cx">                         }
</span><span class="lines">@@ -212,7 +212,7 @@
</span><span class="cx">                                 $redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
</span><span class="cx">                                 if ( !is_feed() ) {
</span><span class="cx">                                         if ( $paged &gt; 1 &amp;&amp; !is_single() ) {
</span><del>-                                                $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit(&quot;page/$paged&quot;, 'paged');
</del><ins>+                                                $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit(&quot;$wp_rewrite-&gt;pagination_base/$paged&quot;, 'paged');
</ins><span class="cx">                                         } elseif ( !is_single() ) {
</span><span class="cx">                                                 $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
</span><span class="cx">                                         }
</span></span></pre></div>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (15581 => 15582)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2010-09-06 11:28:59 UTC (rev 15581)
+++ trunk/wp-includes/link-template.php        2010-09-07 01:18:42 UTC (rev 15582)
</span><span class="lines">@@ -1411,7 +1411,7 @@
</span><span class="cx">                         $query_string = '';
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                $request = preg_replace( '|page/\d+/?$|', '', $request);
</del><ins>+                $request = preg_replace( &quot;|$wp_rewrite-&gt;pagination_base/\d+/?$|&quot;, '', $request);
</ins><span class="cx">                 $request = preg_replace( '|^index\.php|', '', $request);
</span><span class="cx">                 $request = ltrim($request, '/');
</span><span class="cx"> 
</span><span class="lines">@@ -1421,7 +1421,7 @@
</span><span class="cx">                         $base .= 'index.php/';
</span><span class="cx"> 
</span><span class="cx">                 if ( $pagenum &gt; 1 ) {
</span><del>-                        $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
</del><ins>+                        $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite-&gt;pagination_base . &quot;/&quot; . $pagenum, 'paged' );
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $result = $base . $request . $query_string;
</span></span></pre></div>
<a id="trunkwpincludesposttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-template.php (15581 => 15582)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-template.php        2010-09-06 11:28:59 UTC (rev 15581)
+++ trunk/wp-includes/post-template.php        2010-09-07 01:18:42 UTC (rev 15582)
</span><span class="lines">@@ -575,7 +575,7 @@
</span><span class="cx">         $r = apply_filters( 'wp_link_pages_args', $r );
</span><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx"> 
</span><del>-        global $post, $page, $numpages, $multipage, $more, $pagenow;
</del><ins>+        global $page, $numpages, $multipage, $more, $pagenow;
</ins><span class="cx"> 
</span><span class="cx">         $output = '';
</span><span class="cx">         if ( $multipage ) {
</span><span class="lines">@@ -585,21 +585,9 @@
</span><span class="cx">                                 $j = str_replace('%',$i,$pagelink);
</span><span class="cx">                                 $output .= ' ';
</span><span class="cx">                                 if ( ($i != $page) || ((!$more) &amp;&amp; ($page==1)) ) {
</span><del>-                                        if ( 1 == $i ) {
-                                                $output .= '&lt;a href=&quot;' . get_permalink() . '&quot;&gt;';
-                                        } else {
-                                                if ( '' == get_option('permalink_structure') || in_array($post-&gt;post_status, array('draft', 'pending')) )
-                                                        $output .= '&lt;a href=&quot;' . add_query_arg('page', $i, get_permalink()) . '&quot;&gt;';
-                                                elseif ( 'page' == get_option('show_on_front') &amp;&amp; get_option('page_on_front') == $post-&gt;ID )
-                                                        $output .= '&lt;a href=&quot;' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '&quot;&gt;';
-                                                else
-                                                        $output .= '&lt;a href=&quot;' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '&quot;&gt;';
-                                        }
-
</del><ins>+                                        $output .= _wp_link_page($i);
</ins><span class="cx">                                 }
</span><del>-                                $output .= $link_before;
-                                $output .= $j;
-                                $output .= $link_after;
</del><ins>+                                $output .= $link_before . $j . $link_after;
</ins><span class="cx">                                 if ( ($i != $page) || ((!$more) &amp;&amp; ($page==1)) )
</span><span class="cx">                                         $output .= '&lt;/a&gt;';
</span><span class="cx">                         }
</span><span class="lines">@@ -609,30 +597,12 @@
</span><span class="cx">                                 $output .= $before;
</span><span class="cx">                                 $i = $page - 1;
</span><span class="cx">                                 if ( $i &amp;&amp; $more ) {
</span><del>-                                        if ( 1 == $i ) {
-                                                $output .= '&lt;a href=&quot;' . get_permalink() . '&quot;&gt;';
-                                        } else {
-                                                if ( '' == get_option('permalink_structure') || in_array($post-&gt;post_status, array('draft', 'pending')) )
-                                                        $output .= '&lt;a href=&quot;' . add_query_arg('page', $i, get_permalink()) . '&quot;&gt;';
-                                                elseif ( 'page' == get_option('show_on_front') &amp;&amp; get_option('page_on_front') == $post-&gt;ID )
-                                                        $output .= '&lt;a href=&quot;' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '&quot;&gt;';
-                                                else
-                                                        $output .= '&lt;a href=&quot;' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '&quot;&gt;';
-                                        }
</del><ins>+                                        $output .= _wp_link_page($i);
</ins><span class="cx">                                         $output .= $link_before. $previouspagelink . $link_after . '&lt;/a&gt;';
</span><span class="cx">                                 }
</span><span class="cx">                                 $i = $page + 1;
</span><span class="cx">                                 if ( $i &lt;= $numpages &amp;&amp; $more ) {
</span><del>-                                        if ( 1 == $i ) {
-                                                $output .= '&lt;a href=&quot;' . get_permalink() . '&quot;&gt;';
-                                        } else {
-                                                if ( '' == get_option('permalink_structure') || in_array($post-&gt;post_status, array('draft', 'pending')) )
-                                                        $output .= '&lt;a href=&quot;' . add_query_arg('page', $i, get_permalink()) . '&quot;&gt;';
-                                                elseif ( 'page' == get_option('show_on_front') &amp;&amp; get_option('page_on_front') == $post-&gt;ID )
-                                                        $output .= '&lt;a href=&quot;' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '&quot;&gt;';
-                                                else
-                                                        $output .= '&lt;a href=&quot;' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '&quot;&gt;';
-                                        }
</del><ins>+                                        $output .= _wp_link_page($i);
</ins><span class="cx">                                         $output .= $link_before. $nextpagelink . $link_after . '&lt;/a&gt;';
</span><span class="cx">                                 }
</span><span class="cx">                                 $output .= $after;
</span><span class="lines">@@ -646,7 +616,23 @@
</span><span class="cx">         return $output;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function _wp_link_page( $i ) {
+        global $post, $wp_rewrite;
</ins><span class="cx"> 
</span><ins>+        if ( 1 == $i ) {
+                $url .= get_permalink();
+        } else {
+                if ( '' == get_option('permalink_structure') || in_array($post-&gt;post_status, array('draft', 'pending')) )
+                        $url = add_query_arg( 'page', $i, get_permalink() );
+                elseif ( 'page' == get_option('show_on_front') &amp;&amp; get_option('page_on_front') == $post-&gt;ID )
+                        $url = trailingslashit(get_permalink()) . user_trailingslashit(&quot;$wp_rewrite-&gt;pagination_base/&quot; . $i, 'single_paged');
+                else
+                        $url .= trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
+        }
+
+        return '&lt;a href=&quot;' . $url  . '&quot;&gt;';
+}
+
</ins><span class="cx"> //
</span><span class="cx"> // Post-meta: Custom per-post fields.
</span><span class="cx"> //
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (15581 => 15582)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-09-06 11:28:59 UTC (rev 15581)
+++ trunk/wp-includes/post.php        2010-09-07 01:18:42 UTC (rev 15582)
</span><span class="lines">@@ -2550,7 +2550,7 @@
</span><span class="cx">                 $check_sql = &quot;SELECT post_name FROM $wpdb-&gt;posts WHERE post_name = %s AND post_type IN ( '&quot; . implode( &quot;', '&quot;, esc_sql( $hierarchical_post_types ) ) . &quot;' ) AND ID != %d AND post_parent = %d LIMIT 1&quot;;
</span><span class="cx">                 $post_name_check = $wpdb-&gt;get_var( $wpdb-&gt;prepare( $check_sql, $slug, $post_ID, $post_parent ) );
</span><span class="cx"> 
</span><del>-                if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( '@^(page)?\d+$@', $slug ) ) {
</del><ins>+                if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( &quot;@^($wp_rewrite-&gt;pagination_base)?\d+$@&quot;, $slug ) ) {
</ins><span class="cx">                         $suffix = 2;
</span><span class="cx">                         do {
</span><span class="cx">                                 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . &quot;-$suffix&quot;;
</span></span></pre></div>
<a id="trunkwpincludesrewritephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/rewrite.php (15581 => 15582)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/rewrite.php        2010-09-06 11:28:59 UTC (rev 15581)
+++ trunk/wp-includes/rewrite.php        2010-09-07 01:18:42 UTC (rev 15582)
</span><span class="lines">@@ -480,6 +480,15 @@
</span><span class="cx">         var $comments_base = 'comments';
</span><span class="cx"> 
</span><span class="cx">         /**
</span><ins>+         * Pagination permalink base.
+         *
+         * @since 3.1.0
+         * @access private
+         * @var string
+         */
+        var $pagination_base = 'page';
+
+        /**
</ins><span class="cx">          * Feed permalink base.
</span><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="lines">@@ -1279,7 +1288,7 @@
</span><span class="cx"> 
</span><span class="cx">                 //build a regex to match the trackback and page/xx parts of URLs
</span><span class="cx">                 $trackbackregex = 'trackback/?$';
</span><del>-                $pageregex = 'page/?([0-9]{1,})/?$';
</del><ins>+                $pageregex = $this-&gt;pagination_base . '/?([0-9]{1,})/?$';
</ins><span class="cx">                 $commentregex = 'comment-page-([0-9]{1,})/?$';
</span><span class="cx"> 
</span><span class="cx">                 //build up an array of endpoint regexes to append =&gt; queries to append
</span></span></pre>
</div>
</div>

</body>
</html>