<!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" />
<title>[19752] trunk/wp-includes/rewrite.php: Improve documentation of WP_Rewrite.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/19752">19752</a></dd>
<dt>Author</dt> <dd>duck_</dd>
<dt>Date</dt> <dd>2012-01-25 21:44:02 +0000 (Wed, 25 Jan 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Improve documentation of WP_Rewrite. Fixes <a href="http://core.trac.wordpress.org/ticket/19897">#19897</a>.

In particular WP_Rewrite::$front, WP_Rewrite::$root, WP_Rewrite::$use_verbose_page_rules and WP_Rewrite::generate_rewrite_rules(). As well as some code indentation prettification.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesrewritephp">trunk/wp-includes/rewrite.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesrewritephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/rewrite.php (19751 => 19752)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/rewrite.php        2012-01-25 10:41:52 UTC (rev 19751)
+++ trunk/wp-includes/rewrite.php        2012-01-25 21:44:02 UTC (rev 19752)
</span><span class="lines">@@ -372,7 +372,7 @@
</span><span class="cx">  */
</span><span class="cx"> class WP_Rewrite {
</span><span class="cx">         /**
</span><del>-         * Default permalink structure for WordPress.
</del><ins>+         * Permalink structure for posts.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -390,7 +390,7 @@
</span><span class="cx">         var $use_trailing_slashes;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Permalink author request base ( example.com/author/authorname ).
</del><ins>+         * Base for the author permalink structure (example.com/$author_base/authorname).
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -399,7 +399,7 @@
</span><span class="cx">         var $author_base = 'author';
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Permalink request structure for author pages.
</del><ins>+         * Permalink structure for author archives.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -408,7 +408,7 @@
</span><span class="cx">         var $author_structure;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Permalink request structure for dates.
</del><ins>+         * Permalink structure for date archives.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -417,7 +417,7 @@
</span><span class="cx">         var $date_structure;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Permalink request structure for pages.
</del><ins>+         * Permalink structure for pages.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -426,7 +426,7 @@
</span><span class="cx">         var $page_structure;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Search permalink base ( example.com/search/query ).
</del><ins>+         * Base of the search permalink structure (example.com/$search_base/query).
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -435,7 +435,7 @@
</span><span class="cx">         var $search_base = 'search';
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Permalink request structure for searches.
</del><ins>+         * Permalink structure for searches.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -471,7 +471,7 @@
</span><span class="cx">         var $feed_base = 'feed';
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Comments feed request structure permalink.
</del><ins>+         * Comments feed permalink structure.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -480,7 +480,7 @@
</span><span class="cx">         var $comments_feed_structure;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Feed request structure permalink.
</del><ins>+         * Feed request permalink structure.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -489,13 +489,13 @@
</span><span class="cx">         var $feed_structure;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Front URL path.
</del><ins>+         * The static portion of the post permalink structure.
</ins><span class="cx">          *
</span><del>-         * The difference between the root property is that WordPress might be
-         * located at example/WordPress/index.php, if permalinks are turned off. The
-         * WordPress/index.php will be the front portion. If permalinks are turned
-         * on, this will most likely be empty or not set.
</del><ins>+         * If the permalink structure is &quot;/archive/%post_id%&quot; then the front
+         * is &quot;/archive/&quot;. If the permalink structure is &quot;/%year%/%postname%/&quot;
+         * then the front is &quot;/&quot;.
</ins><span class="cx">          *
</span><ins>+         * @see WP_Rewrite::init()
</ins><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="cx">          * @var string
</span><span class="lines">@@ -503,11 +503,14 @@
</span><span class="cx">         var $front;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Root URL path to WordPress (without domain).
</del><ins>+         * The prefix for all permalink structures.
</ins><span class="cx">          *
</span><del>-         * The difference between front property is that WordPress might be located
-         * at example.com/WordPress/. The root is the 'WordPress/' portion.
</del><ins>+         * If PATHINFO/index permalinks are in use then the root is the value of
+         * {@link WP_Rewrite::$index} with a trailing slash appended. Otherwise
+         * the root will be empty.
</ins><span class="cx">          *
</span><ins>+         * @see WP_Rewrite::init()
+         * @see WP_Rewrite::using_index_permalinks()
</ins><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="cx">          * @var string
</span><span class="lines">@@ -515,7 +518,7 @@
</span><span class="cx">         var $root = '';
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Permalink to the home page.
</del><ins>+         * The name of the index file which is the entry point to all requests.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access public
</span><span class="lines">@@ -524,7 +527,7 @@
</span><span class="cx">         var $index = 'index.php';
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Request match string.
</del><ins>+         * Variable name to use for regex matches in the rewritten query.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -550,7 +553,7 @@
</span><span class="cx">          * @access private
</span><span class="cx">          * @var array
</span><span class="cx">          */
</span><del>-        var $extra_rules = array(); //
</del><ins>+        var $extra_rules = array();
</ins><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Additional rules that belong at the beginning to match first.
</span><span class="lines">@@ -561,21 +564,22 @@
</span><span class="cx">          * @access private
</span><span class="cx">          * @var array
</span><span class="cx">          */
</span><del>-        var $extra_rules_top = array(); //
</del><ins>+        var $extra_rules_top = array();
</ins><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Rules that don't redirect to WP's index.php.
</del><ins>+         * Rules that don't redirect to WordPress' index.php.
</ins><span class="cx">          *
</span><del>-         * These rules are written to the mod_rewrite portion of the .htaccess.
</del><ins>+         * These rules are written to the mod_rewrite portion of the .htaccess,
+         * and are added by {@link add_external_rule()}.
</ins><span class="cx">          *
</span><span class="cx">          * @since 2.1.0
</span><span class="cx">          * @access private
</span><span class="cx">          * @var array
</span><span class="cx">          */
</span><del>-        var $non_wp_rules = array(); //
</del><ins>+        var $non_wp_rules = array();
</ins><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Extra permalink structures.
</del><ins>+         * Extra permalink structures, e.g. categories, added by {@link add_permastruct()}.
</ins><span class="cx">          *
</span><span class="cx">          * @since 2.1.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -584,7 +588,7 @@
</span><span class="cx">         var $extra_permastructs = array();
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Endpoints permalinks
</del><ins>+         * Endpoints (like /trackback/) added by {@link add_rewrite_endpoint()}.
</ins><span class="cx">          *
</span><span class="cx">          * @since 2.1.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -593,11 +597,12 @@
</span><span class="cx">         var $endpoints;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Whether to write every mod_rewrite rule for WordPress.
</del><ins>+         * Whether to write every mod_rewrite rule for WordPress into the .htaccess file.
</ins><span class="cx">          *
</span><span class="cx">          * This is off by default, turning it on might print a lot of rewrite rules
</span><span class="cx">          * to the .htaccess file.
</span><span class="cx">          *
</span><ins>+         * @see WP_Rewrite::mod_rewrite_rules()
</ins><span class="cx">          * @since 2.0.0
</span><span class="cx">          * @access public
</span><span class="cx">          * @var bool
</span><span class="lines">@@ -605,8 +610,17 @@
</span><span class="cx">         var $use_verbose_rules = false;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Whether to write every mod_rewrite rule for WordPress pages.
</del><ins>+         * Could post permalinks be confused with those of pages?
</ins><span class="cx">          *
</span><ins>+         * If the first rewrite tag in the post permalink structure is one that could
+         * also match a page name (e.g. %postname% or %author%) then this flag is
+         * set to true. Prior to WordPress 3.3 this flag indicated that every page
+         * would have a set of rules added to the top of the rewrite rules array.
+         * Now it tells {@link WP::parse_request()} to check if a URL matching the
+         * page permastruct is actually a page before accepting it.
+         * 
+         * @link http://core.trac.wordpress.org/ticket/16687
+         * @see WP_Rewrite::init()
</ins><span class="cx">          * @since 2.5.0
</span><span class="cx">          * @access public
</span><span class="cx">          * @var bool
</span><span class="lines">@@ -614,70 +628,74 @@
</span><span class="cx">         var $use_verbose_page_rules = true;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Permalink structure search for preg_replace.
</del><ins>+         * Rewrite tags that can be used in permalink structures.
</ins><span class="cx">          *
</span><ins>+         * These are translated into the regular expressions stored in
+         * {@link WP_Rewrite::$rewritereplace} and are rewritten to the
+         * query variables listed in {@link WP_Rewrite::$queryreplace}.
+         *
+         * Additional tags can be added with {@link add_rewrite_tag()}.
+         *
</ins><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="cx">          * @var array
</span><span class="cx">          */
</span><del>-        var $rewritecode =
-                array(
-                                        '%year%',
-                                        '%monthnum%',
-                                        '%day%',
-                                        '%hour%',
-                                        '%minute%',
-                                        '%second%',
-                                        '%postname%',
-                                        '%post_id%',
-                                        '%author%',
-                                        '%pagename%',
-                                        '%search%'
-                                        );
</del><ins>+        var $rewritecode = array(
+                '%year%',
+                '%monthnum%',
+                '%day%',
+                '%hour%',
+                '%minute%',
+                '%second%',
+                '%postname%',
+                '%post_id%',
+                '%author%',
+                '%pagename%',
+                '%search%'
+        );
</ins><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Preg_replace values for the search, see {@link WP_Rewrite::$rewritecode}.
</del><ins>+         * Regular expressions to be substituted into rewrite rules in place
+         * of rewrite tags, see {@link WP_Rewrite::$rewritecode}.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="cx">          * @var array
</span><span class="cx">          */
</span><del>-        var $rewritereplace =
-                array(
-                                        '([0-9]{4})',
-                                        '([0-9]{1,2})',
-                                        '([0-9]{1,2})',
-                                        '([0-9]{1,2})',
-                                        '([0-9]{1,2})',
-                                        '([0-9]{1,2})',
-                                        '([^/]+)',
-                                        '([0-9]+)',
-                                        '([^/]+)',
-                                        '([^/]+?)',
-                                        '(.+)'
-                                        );
</del><ins>+        var $rewritereplace = array(
+                '([0-9]{4})',
+                '([0-9]{1,2})',
+                '([0-9]{1,2})',
+                '([0-9]{1,2})',
+                '([0-9]{1,2})',
+                '([0-9]{1,2})',
+                '([^/]+)',
+                '([0-9]+)',
+                '([^/]+)',
+                '([^/]+?)',
+                '(.+)'
+        );
</ins><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Search for the query to look for replacing.
</del><ins>+         * Query variables that rewrite tags map to, see {@link WP_Rewrite::$rewritecode}.
</ins><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access private
</span><span class="cx">          * @var array
</span><span class="cx">          */
</span><del>-        var $queryreplace =
-                array (
-                                        'year=',
-                                        'monthnum=',
-                                        'day=',
-                                        'hour=',
-                                        'minute=',
-                                        'second=',
-                                        'name=',
-                                        'p=',
-                                        'author_name=',
-                                        'pagename=',
-                                        's='
-                                        );
</del><ins>+        var $queryreplace = array(
+                'year=',
+                'monthnum=',
+                'day=',
+                'hour=',
+                'minute=',
+                'second=',
+                'name=',
+                'p=',
+                'author_name=',
+                'pagename=',
+                's='
+        );
</ins><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Supported default feeds.
</span><span class="lines">@@ -686,7 +704,7 @@
</span><span class="cx">          * @access private
</span><span class="cx">          * @var array
</span><span class="cx">          */
</span><del>-        var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
</del><ins>+        var $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
</ins><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Whether permalinks are being used.
</span><span class="lines">@@ -902,7 +920,7 @@
</span><span class="cx">          * @return bool|string False on failure. Year structure on success.
</span><span class="cx">          */
</span><span class="cx">         function get_year_permastruct() {
</span><del>-                $structure = $this-&gt;get_date_permastruct($this-&gt;permalink_structure);
</del><ins>+                $structure = $this-&gt;get_date_permastruct();
</ins><span class="cx"> 
</span><span class="cx">                 if ( empty($structure) )
</span><span class="cx">                         return false;
</span><span class="lines">@@ -927,7 +945,7 @@
</span><span class="cx">          * @return bool|string False on failure. Year/Month structure on success.
</span><span class="cx">          */
</span><span class="cx">         function get_month_permastruct() {
</span><del>-                $structure = $this-&gt;get_date_permastruct($this-&gt;permalink_structure);
</del><ins>+                $structure = $this-&gt;get_date_permastruct();
</ins><span class="cx"> 
</span><span class="cx">                 if ( empty($structure) )
</span><span class="cx">                         return false;
</span><span class="lines">@@ -950,7 +968,7 @@
</span><span class="cx">          * @return bool|string False on failure. Year/Month/Day structure on success.
</span><span class="cx">          */
</span><span class="cx">         function get_day_permastruct() {
</span><del>-                return $this-&gt;get_date_permastruct($this-&gt;permalink_structure);
</del><ins>+                return $this-&gt;get_date_permastruct();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -1166,7 +1184,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Generate the rules from permalink structure.
</del><ins>+         * Generate rewrite rules from a permalink structure.
</ins><span class="cx">          *
</span><span class="cx">          * The main WP_Rewrite function for building the rewrite rule list. The
</span><span class="cx">          * contents of the function is a mix of black magic and regular expressions,
</span><span class="lines">@@ -1176,12 +1194,13 @@
</span><span class="cx">          * @access public
</span><span class="cx">          *
</span><span class="cx">          * @param string $permalink_structure The permalink structure.
</span><del>-         * @param int $ep_mask Optional, default is EP_NONE. Endpoint constant, see EP_* constants.
-         * @param bool $paged Optional, default is true. Whether permalink request is paged.
-         * @param bool $feed Optional, default is true. Whether for feed.
-         * @param bool $forcomments Optional, default is false. Whether for comments.
-         * @param bool $walk_dirs Optional, default is true. Whether to create list of directories to walk over.
-         * @param bool $endpoints Optional, default is true. Whether endpoints are enabled.
</del><ins>+         * @param int $ep_mask Endpoint mask defining what endpoints are added to the structure. Default is EP_NONE.
+         * @param bool $paged Should archive pagination rules be added for the structure? Default is true.
+         * @param bool $feed Should feed rewrite rules be added for the structure? Default is true.
+         * @param bool $forcomments Should the feed rules be a query for a comments feed? Default is false.
+         * @param bool $walk_dirs Should the 'directories' making up the structure be walked over and rewrite rules
+         *                        built for each in turn? Default is true.
+         * @param bool $endpoints Should endpoints be applied to the generated rewrite rules? Default is true.
</ins><span class="cx">          * @return array Rewrite rule list.
</span><span class="cx">          */
</span><span class="cx">         function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
</span><span class="lines">@@ -1240,8 +1259,8 @@
</span><span class="cx">                         $structure = str_replace($front, '', $structure);
</span><span class="cx"> 
</span><span class="cx">                 //create a list of dirs to walk over, making rewrite rules for each level
</span><del>-                //so for example, a $structure of /%year%/%month%/%postname% would create
-                //rewrite rules for /%year%/, /%year%/%month%/ and /%year%/%month%/%postname%
</del><ins>+                //so for example, a $structure of /%year%/%monthnum%/%postname% would create
+                //rewrite rules for /%year%/, /%year%/%monthnum%/ and /%year%/%monthnum%/%postname%
</ins><span class="cx">                 $structure = trim($structure, '/');
</span><span class="cx">                 $dirs = $walk_dirs ? explode('/', $structure) : array( $structure );
</span><span class="cx">                 $num_dirs = count($dirs);
</span><span class="lines">@@ -1377,8 +1396,6 @@
</span><span class="cx">                                         $sub1feed = $sub1 . $feedregex; //and &lt;permalink&gt;/feed/(atom|...)
</span><span class="cx">                                         $sub1feed2 = $sub1 . $feedregex2; //and &lt;permalink&gt;/(feed|atom...)
</span><span class="cx">                                         $sub1comment = $sub1 . $commentregex; //and &lt;permalink&gt;/comment-page-xx
</span><del>-                                        //add an ? as we don't have to match that last slash, and finally a $ so we
-                                        //match to the end of the URL
</del><span class="cx"> 
</span><span class="cx">                                         //add another rule to match attachments in the explicit form:
</span><span class="cx">                                         //&lt;permalink&gt;/attachment/some-text
</span><span class="lines">@@ -1405,10 +1422,12 @@
</span><span class="cx">                                         }
</span><span class="cx"> 
</span><span class="cx">                                         //now we've finished with endpoints, finish off the $sub1 and $sub2 matches
</span><ins>+                                        //add a ? as we don't have to match that last slash, and finally a $ so we
+                                        //match to the end of the URL
</ins><span class="cx">                                         $sub1 .= '?$';
</span><span class="cx">                                         $sub2 .= '?$';
</span><span class="cx"> 
</span><del>-                                        //allow URLs like &lt;permalink&gt;/2 for &lt;permalink&gt;/page/2
</del><ins>+                                        //post pagination, e.g. &lt;permalink&gt;/2/
</ins><span class="cx">                                         $match = $match . '(/[0-9]+)?/?$';
</span><span class="cx">                                         $query = $index . '?' . $query . '&amp;page=' . $this-&gt;preg_index($num_toks + 1);
</span><span class="cx">                                 } else { //not matching a permalink so this is a lot simpler
</span><span class="lines">@@ -1586,7 +1605,7 @@
</span><span class="cx">          * Does not actually write to the .htaccess file, but creates the rules for
</span><span class="cx">          * the process that will.
</span><span class="cx">          *
</span><del>-         * Will add  the non_wp_rules property rules to the .htaccess file before
</del><ins>+         * Will add the non_wp_rules property rules to the .htaccess file before
</ins><span class="cx">          * the WordPress rewrite rules one.
</span><span class="cx">          *
</span><span class="cx">          * @since 1.5.0
</span></span></pre>
</div>
</div>

</body>
</html>