<!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>[27341] trunk/src/wp-includes/rewrite.php: Inline documentation for hooks in wp-includes/rewrite.php.</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 { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { 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/27341">27341</a></dd>
<dt>Author</dt> <dd>DrewAPicture</dd>
<dt>Date</dt> <dd>2014-03-01 09:30:55 +0000 (Sat, 01 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Inline documentation for hooks in wp-includes/rewrite.php.

Props mboynes for the initial patch.
Fixes <a href="http://core.trac.wordpress.org/ticket/26095">#26095</a>.</pre>

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesrewritephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/rewrite.php (27340 => 27341)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/rewrite.php        2014-03-01 07:36:42 UTC (rev 27340)
+++ trunk/src/wp-includes/rewrite.php   2014-03-01 09:30:55 UTC (rev 27341)
</span><span class="lines">@@ -289,7 +289,14 @@
</span><span class="cx"> function url_to_postid($url) {
</span><span class="cx">  global $wp_rewrite;
</span><span class="cx"> 
</span><del>-       $url = apply_filters('url_to_postid', $url);
</del><ins>+        /**
+        * Filter the URL to derive the post ID from.
+        *
+        * @since 2.2.0
+        *
+        * @param string $url The URL to derive the post ID from.
+        */
+       $url = apply_filters( 'url_to_postid', $url );
</ins><span class="cx"> 
</span><span class="cx">  // First, check to see if there is a 'p=N' or 'page_id=N' to match against
</span><span class="cx">  if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) )   {
</span><span class="lines">@@ -1559,36 +1566,105 @@
</span><span class="cx">          }
</span><span class="cx">          $registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; // Deprecated
</span><span class="cx"> 
</span><del>-               // Post
</del><ins>+                // Post rewrite rules.
</ins><span class="cx">           $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK );
</span><del>-               $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
</del><span class="cx"> 
</span><del>-               // Date
</del><ins>+                /**
+                * Filter rewrite rules used for "post" archives.
+                *
+                * @since 1.5.0
+                *
+                * @param array $post_rewrite The rewrite rules for posts.
+                */
+               $post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite );
+
+               // Date rewrite rules.
</ins><span class="cx">           $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE);
</span><del>-               $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
</del><span class="cx"> 
</span><del>-               // Root
</del><ins>+                /**
+                * Filter rewrite rules used for date archives.
+                *
+                * Likely date archives would include /yyyy/, /yyyy/mm/, and /yyyy/mm/dd/.
+                *
+                * @since 1.5.0
+                *
+                * @param array $date_rewrite The rewrite rules for date archives.
+                */
+               $date_rewrite = apply_filters( 'date_rewrite_rules', $date_rewrite );
+
+               // Root-level rewrite rules.
</ins><span class="cx">           $root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT);
</span><del>-               $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
</del><span class="cx"> 
</span><del>-               // Comments
</del><ins>+                /**
+                * Filter rewrite rules used for root-level archives.
+                *
+                * Likely root-level archives would include pagination rules for the homepage
+                * as well as site-wide post feeds (e.g. /feed/, and /feed/atom/).
+                *
+                * @since 1.5.0
+                *
+                * @param array $root_rewrite The root-level rewrite rules.
+                */
+               $root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite );
+
+               // Comments rewrite rules.
</ins><span class="cx">           $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, false, true, true, false);
</span><del>-               $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
</del><span class="cx"> 
</span><del>-               // Search
</del><ins>+                /**
+                * Filter rewrite rules used for comment feed archives.
+                *
+                * Likely comments feed archives include /comments/feed/, and /comments/feed/atom/.
+                *
+                * @since 1.5.0
+                *
+                * @param array $comments_rewrite The rewrite rules for the site-wide comments feeds.
+                */
+               $comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite );
+
+               // Search rewrite rules.
</ins><span class="cx">           $search_structure = $this->get_search_permastruct();
</span><span class="cx">          $search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH);
</span><del>-               $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
</del><span class="cx"> 
</span><del>-               // Authors
</del><ins>+                /**
+                * Filter rewrite rules used for search archives.
+                *
+                * Likely search-related archives include /search/search+query/ as well as
+                * pagination and feed paths for a search.
+                *
+                * @since 1.5.0
+                *
+                * @param array $search_rewrite The rewrite rules for search queries.
+                */
+               $search_rewrite = apply_filters( 'search_rewrite_rules', $search_rewrite );
+
+               // Author rewrite rules.
</ins><span class="cx">           $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
</span><del>-               $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
</del><span class="cx"> 
</span><del>-               // Pages
</del><ins>+                /**
+                * Filter rewrite rules used for author archives.
+                *
+                * Likely author archives would inlcude /author/author-name/, as well as
+                * pagination and feed paths for author archives.
+                *
+                * @since 1.5.0
+                *
+                * @param array $author_rewrite The rewrite rules for author archives.
+                */
+               $author_rewrite = apply_filters( 'author_rewrite_rules', $author_rewrite );
+
+               // Pages rewrite rules.
</ins><span class="cx">           $page_rewrite = $this->page_rewrite_rules();
</span><del>-               $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
</del><span class="cx"> 
</span><del>-               // Extra permastructs
</del><ins>+                /**
+                * Filter rewrite rules used for "page" post type archives.
+                *
+                * @since 1.5.0
+                *
+                * @param array $page_rewrite The rewrite rules for the "page" post type.
+                */
+               $page_rewrite = apply_filters( 'page_rewrite_rules', $page_rewrite );
+
+               // Extra permastructs.
</ins><span class="cx">           foreach ( $this->extra_permastructs as $permastructname => $struct ) {
</span><span class="cx">                  if ( is_array( $struct ) ) {
</span><span class="cx">                          if ( count( $struct ) == 2 )
</span><span class="lines">@@ -1599,10 +1675,31 @@
</span><span class="cx">                          $rules = $this->generate_rewrite_rules( $struct );
</span><span class="cx">                  }
</span><span class="cx"> 
</span><del>-                       $rules = apply_filters($permastructname . '_rewrite_rules', $rules);
-                       if ( 'post_tag' == $permastructname )
-                               $rules = apply_filters('tag_rewrite_rules', $rules);
</del><ins>+                        /**
+                        * Filter rewrite rules used for individual permastructs.
+                        *
+                        * The dynamic portion of the hook name, $permastructname, refers
+                        * to the name of the registered permastruct, e.g. 'post_tag' (tags),
+                        * 'category' (categories), etc.
+                        *
+                        * @since 3.1.0
+                        *
+                        * @param array $rules The rewrite rules generated for the current permastruct.
+                        */
+                       $rules = apply_filters( $permastructname . '_rewrite_rules', $rules );
+                       if ( 'post_tag' == $permastructname ) {
</ins><span class="cx"> 
</span><ins>+                               /**
+                                * Filter rewrite rules used specifically for Tags.
+                                *
+                                * @since 2.3.0
+                                * @deprecated 3.1.0 Use 'post_tag_rewrite_rules' instead
+                                *
+                                * @param array $rules The rewrite rules generated for tags.
+                                */
+                               $rules = apply_filters( 'tag_rewrite_rules', $rules );
+                       }
+
</ins><span class="cx">                   $this->extra_rules_top = array_merge($this->extra_rules_top, $rules);
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="lines">@@ -1612,9 +1709,24 @@
</span><span class="cx">          else
</span><span class="cx">                  $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
</span><span class="cx"> 
</span><del>-               do_action_ref_array('generate_rewrite_rules', array(&$this));
-               $this->rules = apply_filters('rewrite_rules_array', $this->rules);
</del><ins>+                /**
+                * Fires after the rewrite rules are generated.
+                *
+                * @since 1.5.0
+                *
+                * @param WP_Rewrite $this Current WP_Rewrite instance, passed by reference.
+                */
+               do_action_ref_array( 'generate_rewrite_rules', array( &$this ) );
</ins><span class="cx"> 
</span><ins>+               /**
+                * Filter the full set of generated rewrite rules.
+                *
+                * @since 1.5.0
+                *
+                * @param array $this->rules The compiled array of rewrite rules.
+                */
+               $this->rules = apply_filters( 'rewrite_rules_array', $this->rules );
+
</ins><span class="cx">           return $this->rules;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -1721,9 +1833,26 @@
</span><span class="cx"> 
</span><span class="cx">          $rules .= "</IfModule>\n";
</span><span class="cx"> 
</span><del>-               $rules = apply_filters('mod_rewrite_rules', $rules);
-               $rules = apply_filters('rewrite_rules', $rules);  // Deprecated
</del><ins>+                /**
+                *
+                * Filter the list of rewrite rules formatted for output to an .htaccess file.
+                *
+                * @since 1.5.0
+                *
+                * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
+                */
+               $rules = apply_filters( 'mod_rewrite_rules', $rules );
</ins><span class="cx"> 
</span><ins>+               /**
+                * Filter the list of rewrite rules formatted for output to an .htaccess file.
+                *
+                * @since 1.5.0
+                * @deprecated 1.5.0 Use the mod_rewrite_rules filter instead.
+                *
+                * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
+                */
+               $rules = apply_filters( 'rewrite_rules', $rules );  // Deprecated
+
</ins><span class="cx">           return $rules;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -1768,7 +1897,14 @@
</span><span class="cx"> </configuration>';
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               $rules = apply_filters('iis7_url_rewrite_rules', $rules);
</del><ins>+                /**
+                * Filter the list of rewrite rules formatted for output to a web.config.
+                *
+                * @since 2.8.0
+                *
+                * @param string $rules Rewrite rules formatted for IIS web.config.
+                */
+               $rules = apply_filters( 'iis7_url_rewrite_rules', $rules );
</ins><span class="cx"> 
</span><span class="cx">          return $rules;
</span><span class="cx">  }
</span><span class="lines">@@ -1916,10 +2052,12 @@
</span><span class="cx">           * A "hard" flush updates .htaccess (Apache) or web.config (IIS).
</span><span class="cx">           *
</span><span class="cx">           * @since 3.7.0
</span><del>-                * @param bool $hard Defaults to true.
</del><ins>+                 *
+                * @param bool $hard Whether to flush rewrite rules "hard". Default true.
</ins><span class="cx">            */
</span><del>-               if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) )
</del><ins>+                if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) {
</ins><span class="cx">                   return;
</span><ins>+               }
</ins><span class="cx">           if ( function_exists( 'save_mod_rewrite_rules' ) )
</span><span class="cx">                  save_mod_rewrite_rules();
</span><span class="cx">          if ( function_exists( 'iis7_save_url_rewrite_rules' ) )
</span><span class="lines">@@ -1978,7 +2116,16 @@
</span><span class="cx">                  $old_permalink_structure = $this->permalink_structure;
</span><span class="cx">                  update_option('permalink_structure', $permalink_structure);
</span><span class="cx">                  $this->init();
</span><del>-                       do_action('permalink_structure_changed', $old_permalink_structure, $permalink_structure);
</del><ins>+
+                       /**
+                        * Fires after the permalink structure is updated.
+                        *
+                        * @since 2.8.0
+                        *
+                        * @param string $old_permalink_structure The previous permalink structure.
+                        * @param string $permalink_structure     The new permalink structure.
+                        */
+                       do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure );
</ins><span class="cx">           }
</span><span class="cx">  }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>