<!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>[27210] trunk/src/wp-includes/query.php: Inline documentation hooks in wp-includes/query.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/27210">27210</a></dd>
<dt>Author</dt> <dd>DrewAPicture</dd>
<dt>Date</dt> <dd>2014-02-20 17:53:33 +0000 (Thu, 20 Feb 2014)</dd>
</dl>

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

Covers documentation for the various remaining query hooks, notably including but not limited to:
* `parse_query`
* `parse_tax_query`
* `pre_get_posts`
* `posts_results`
* `the_posts`
* `found_posts`
* `the_post`

Props dougwollison, DrewAPicture.
See <a href="http://core.trac.wordpress.org/ticket/25514">#25514</a>.</pre>

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesqueryphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/query.php (27209 => 27210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/query.php  2014-02-20 17:49:30 UTC (rev 27209)
+++ trunk/src/wp-includes/query.php     2014-02-20 17:53:33 UTC (rev 27210)
</span><span class="lines">@@ -1713,7 +1713,14 @@
</span><span class="cx">          $this->query_vars_hash = md5( serialize( $this->query_vars ) );
</span><span class="cx">          $this->query_vars_changed = false;
</span><span class="cx"> 
</span><del>-               do_action_ref_array('parse_query', array(&$this));
</del><ins>+                /**
+                * Fires after the main query vars have been parsed.
+                *
+                * @since 1.5.0
+                *
+                * @param WP_Query &$this The WP_Query instance (passed by reference).
+                */
+               do_action_ref_array( 'parse_query', array( &$this ) );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="lines">@@ -1920,6 +1927,13 @@
</span><span class="cx"> 
</span><span class="cx">          $this->tax_query = new WP_Tax_Query( $tax_query );
</span><span class="cx"> 
</span><ins>+               /**
+                * Fires after taxonomy-related query vars have been parsed.
+                *
+                * @since 3.7.0
+                *
+                * @param WP_Query $this The WP_Query instance.
+                */
</ins><span class="cx">           do_action( 'parse_tax_query', $this );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -2155,7 +2169,18 @@
</span><span class="cx"> 
</span><span class="cx">          $this->parse_query();
</span><span class="cx"> 
</span><del>-               do_action_ref_array('pre_get_posts', array(&$this));
</del><ins>+                /**
+                * Fires after the query variable object is created, but before the actual query is run.
+                *
+                * Note: If using conditional tags, use the method versions within the passed instance
+                * (e.g. $this->is_main_query() instead of is_main_query()). This is because the functions
+                * like is_main_query() test against the global $wp_query instance, not the passed one.
+                *
+                * @since 2.0.0
+                *
+                * @param WP_Query &$this The WP_Query instance (passed by reference).
+                */
+               do_action_ref_array( 'pre_get_posts', array( &$this ) );
</ins><span class="cx"> 
</span><span class="cx">          // Shorthand.
</span><span class="cx">          $q = &$this->query_vars;
</span><span class="lines">@@ -3146,6 +3171,14 @@
</span><span class="cx">          $this->request = $old_request = "SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
</span><span class="cx"> 
</span><span class="cx">          if ( !$q['suppress_filters'] ) {
</span><ins>+                       /**
+                        * Filter the completed SQL query before sending.
+                        *
+                        * @since 2.0.0
+                        *
+                        * @param array    $request The complete SQL query.
+                        * @param WP_Query &$this   The WP_Query instance (passed by reference).
+                        */
</ins><span class="cx">                   $this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) );
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="lines">@@ -3170,6 +3203,19 @@
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="cx">          $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );
</span><ins>+
+               /**
+                * Filter whether to split the query.
+                *
+                * Splitting the query will cause it to fetch just the IDs of the found posts
+                * (and then individually fetch each post by ID), rather than fetching every
+                * complete row at once. One massive result vs. many small results.
+                *
+                * @since 3.4.0
+                *
+                * @param bool     $split_the_query Whether or not to split the query.
+                * @param WP_Query $this            The WP_Query instance.
+                */
</ins><span class="cx">           $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this );
</span><span class="cx"> 
</span><span class="cx">          if ( $split_the_query ) {
</span><span class="lines">@@ -3177,6 +3223,14 @@
</span><span class="cx"> 
</span><span class="cx">                  $this->request = "SELECT $found_rows $distinct $wpdb->posts.ID FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
</span><span class="cx"> 
</span><ins>+                       /**
+                        * Filter the Post IDs SQL request before sending.
+                        *
+                        * @since 3.4.0
+                        *
+                        * @param string   $request The post ID request.
+                        * @param WP_Query $this    The WP_Query instance.
+                        */
</ins><span class="cx">                   $this->request = apply_filters( 'posts_request_ids', $this->request, $this );
</span><span class="cx"> 
</span><span class="cx">                  $ids = $wpdb->get_col( $this->request );
</span><span class="lines">@@ -3197,9 +3251,17 @@
</span><span class="cx">          if ( $this->posts )
</span><span class="cx">                  $this->posts = array_map( 'get_post', $this->posts );
</span><span class="cx"> 
</span><del>-               // Raw results filter. Prior to status checks.
-               if ( !$q['suppress_filters'] )
-                       $this->posts = apply_filters_ref_array('posts_results', array( $this->posts, &$this ) );
</del><ins>+                if ( ! $q['suppress_filters'] ) {
+                       /**
+                        * Filter the raw post results array, prior to status checks.
+                        *
+                        * @since 2.3.0
+                        *
+                        * @param array    $posts The post results array.
+                        * @param WP_Query &$this The WP_Query instance (passed by reference).
+                        */
+                       $this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) );
+               }
</ins><span class="cx"> 
</span><span class="cx">          if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
</span><span class="cx">                  /** This filter is documented in wp-includes/query.php */
</span><span class="lines">@@ -3252,8 +3314,17 @@
</span><span class="cx">                          }
</span><span class="cx">                  }
</span><span class="cx"> 
</span><del>-                       if ( $this->is_preview && $this->posts && current_user_can( $edit_cap, $this->posts[0]->ID ) )
</del><ins>+                        if ( $this->is_preview && $this->posts && current_user_can( $edit_cap, $this->posts[0]->ID ) ) {
+                               /**
+                                * Filter the single post for preview mode.
+                                *
+                                * @since 2.7.0
+                                *
+                                * @param WP_Post  $post_preview  The Post object.
+                                * @param WP_Query &$this         The WP_Query instance (passed by reference).
+                                */
</ins><span class="cx">                           $this->posts[0] = get_post( apply_filters_ref_array( 'the_preview', array( $this->posts[0], &$this ) ) );
</span><ins>+                       }
</ins><span class="cx">           }
</span><span class="cx"> 
</span><span class="cx">          // Put sticky posts at the top of the posts array
</span><span class="lines">@@ -3297,8 +3368,18 @@
</span><span class="cx">                  }
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               if ( !$q['suppress_filters'] )
-                       $this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) );
</del><ins>+                if ( ! $q['suppress_filters'] ) {
+                       /**
+                        * Filter the array of retrieved posts after they've been fetched and
+                        * internally processed.
+                        *
+                        * @since 1.5.0
+                        *
+                        * @param array    $posts The array of retrieved posts.
+                        * @param WP_Query &$this The WP_Query instance (passed by reference).
+                        */
+                       $this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) );
+               }
</ins><span class="cx"> 
</span><span class="cx">          // Ensure that any posts added/modified via one of the filters above are
</span><span class="cx">          // of the type WP_Post and are filtered.
</span><span class="lines">@@ -3334,11 +3415,28 @@
</span><span class="cx">          if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) )
</span><span class="cx">                  return;
</span><span class="cx"> 
</span><del>-               if ( ! empty( $limits ) )
</del><ins>+                if ( ! empty( $limits ) ) {
+                       /**
+                        * Filter the query to run for retrieving the found posts.
+                        *
+                        * @since 2.1.0
+                        *
+                        * @param string   $found_posts The query to run to find the found posts.
+                        * @param WP_Query &$this       The WP_Query instance (passed by reference).
+                        */
</ins><span class="cx">                   $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) );
</span><del>-               else
</del><ins>+                } else {
</ins><span class="cx">                   $this->found_posts = count( $this->posts );
</span><ins>+               }
</ins><span class="cx"> 
</span><ins>+               /**
+                * Filter the number of found posts for the query.
+                *
+                * @since 2.1.0
+                *
+                * @param int      $found_posts The number of posts found.
+                * @param WP_Query &$this       The WP_Query instance (passed by reference).
+                */
</ins><span class="cx">           $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );
</span><span class="cx"> 
</span><span class="cx">          if ( ! empty( $limits ) )
</span><span class="lines">@@ -3377,7 +3475,14 @@
</span><span class="cx">          $this->in_the_loop = true;
</span><span class="cx"> 
</span><span class="cx">          if ( $this->current_post == -1 ) // loop has just started
</span><del>-                       do_action_ref_array('loop_start', array(&$this));
</del><ins>+                        /**
+                        * Fires once the loop is started.
+                        *
+                        * @since 2.0.0
+                        *
+                        * @param WP_Query &$this The WP_Query instance (passed by reference).
+                        */
+                       do_action_ref_array( 'loop_start', array( &$this ) );
</ins><span class="cx"> 
</span><span class="cx">          $post = $this->next_post();
</span><span class="cx">          setup_postdata($post);
</span><span class="lines">@@ -3398,7 +3503,14 @@
</span><span class="cx">          if ( $this->current_post + 1 < $this->post_count ) {
</span><span class="cx">                  return true;
</span><span class="cx">          } elseif ( $this->current_post + 1 == $this->post_count && $this->post_count > 0 ) {
</span><del>-                       do_action_ref_array('loop_end', array(&$this));
</del><ins>+                        /**
+                        * Fires once the loop has ended.
+                        *
+                        * @since 2.0.0
+                        *
+                        * @param WP_Query &$this The WP_Query instance (passed by reference).
+                        */
+                       do_action_ref_array( 'loop_end', array( &$this ) );
</ins><span class="cx">                   // Do some cleaning up after the loop
</span><span class="cx">                  $this->rewind_posts();
</span><span class="cx">          }
</span><span class="lines">@@ -3449,7 +3561,12 @@
</span><span class="cx">          $comment = $this->next_comment();
</span><span class="cx"> 
</span><span class="cx">          if ( $this->current_comment == 0 ) {
</span><del>-                       do_action('comment_loop_start');
</del><ins>+                        /**
+                        * Fires once the comment loop is started.
+                        *
+                        * @since 2.2.0
+                        */
+                       do_action( 'comment_loop_start' );
</ins><span class="cx">           }
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -4242,7 +4359,14 @@
</span><span class="cx">          $pages = array( $post->post_content );
</span><span class="cx">  }
</span><span class="cx"> 
</span><del>-       do_action_ref_array('the_post', array(&$post));
</del><ins>+        /**
+        * Fires once the post data has been setup.
+        *
+        * @since 2.8.0
+        *
+        * @param WP_Post &$post The Post object (passed by reference).
+        */
+       do_action_ref_array( 'the_post', array( &$post ) );
</ins><span class="cx"> 
</span><span class="cx">  return true;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>