<!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>[38279] trunk/src/wp-includes/query.php: Query: use composition for `$db` in `WP_Query`, removes need to import `global $wpdb` in multiple methods.</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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/38279">38279</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/38279","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>wonderboymusic</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-08-18 19:38:18 +0000 (Thu, 18 Aug 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Query: use composition for `$db` in `WP_Query`, removes need to import `global $wpdb` in multiple methods.
See <a href="https://core.trac.wordpress.org/ticket/37699">#37699</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 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/query.php 2016-08-18 19:37:23 UTC (rev 38278)
+++ trunk/src/wp-includes/query.php 2016-08-18 19:38:18 UTC (rev 38279)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1321,6 +1321,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> private $compat_methods = array( 'init_query_flags', 'parse_tax_query' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Resets query flags to false.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The query flags are what page info WordPress was able to figure out.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2114,14 +2121,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.7.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param array $q Query variables.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string WHERE clause.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function parse_search( &$q ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $search = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // added slashes screw with quote grouping when done early, so done later
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2161,19 +2164,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $n && $include ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $like = '%' . $wpdb->esc_like( $term ) . '%';
- $q['search_orderby_title'][] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $like );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $like = '%' . $this->db->esc_like( $term ) . '%';
+ $q['search_orderby_title'][] = $this->db->prepare( "{$this->db->posts}.post_title LIKE %s", $like );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $like = $n . $wpdb->esc_like( $term ) . $n;
- $search .= $wpdb->prepare( "{$searchand}(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_excerpt $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s))", $like, $like, $like );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $like = $n . $this->db->esc_like( $term ) . $n;
+ $search .= $this->db->prepare( "{$searchand}(({$this->db->posts}.post_title $like_op %s) $andor_op ({$this->db->posts}.post_excerpt $like_op %s) $andor_op ({$this->db->posts}.post_content $like_op %s))", $like, $like, $like );
</ins><span class="cx" style="display: block; padding: 0 10px"> $searchand = ' AND ';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $search ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $search = " AND ({$search}) ";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_user_logged_in() )
- $search .= " AND ($wpdb->posts.post_password = '') ";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_user_logged_in() ) {
+ $search .= " AND ({$this->db->posts}.post_password = '') ";
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $search;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2256,28 +2260,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Generate SQL for the ORDER BY condition based on passed search terms.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param array $q Query variables.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string ORDER BY clause.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function parse_search_order( &$q ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $q['search_terms_count'] > 1 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $num_terms = count( $q['search_orderby_title'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If the search terms contain negative queries, don't bother ordering by sentence matches.
</span><span class="cx" style="display: block; padding: 0 10px"> $like = '';
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! preg_match( '/(?:\s|^)\-/', $q['s'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $like = '%' . $wpdb->esc_like( $q['s'] ) . '%';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $like = '%' . $this->db->esc_like( $q['s'] ) . '%';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $search_orderby = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // sentence match in 'post_title'
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $like ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_title LIKE %s THEN 1 ", $like );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $search_orderby .= $this->db->prepare( "WHEN {$this->db->posts}.post_title LIKE %s THEN 1 ", $like );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // sanity limit, sort as sentence when more than 6 terms
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2292,8 +2292,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Sentence match in 'post_content' and 'post_excerpt'.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $like ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_excerpt LIKE %s THEN 4 ", $like );
- $search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_content LIKE %s THEN 5 ", $like );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $search_orderby .= $this->db->prepare( "WHEN {$this->db->posts}.post_excerpt LIKE %s THEN 4 ", $like );
+ $search_orderby .= $this->db->prepare( "WHEN {$this->db->posts}.post_content LIKE %s THEN 5 ", $like );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $search_orderby ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2314,14 +2314,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $orderby Alias for the field to order by.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string|false Table-prefixed value to used in the ORDER clause. False otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function parse_orderby( $orderby ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Used to filter values.
</span><span class="cx" style="display: block; padding: 0 10px"> $allowed_keys = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_name', 'post_author', 'post_date', 'post_title', 'post_modified',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2368,7 +2364,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> case 'ID':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'menu_order':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'comment_count':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby_clause = "$wpdb->posts.{$orderby}";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby_clause = "{$this->db->posts}.{$orderby}";
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'rand':
</span><span class="cx" style="display: block; padding: 0 10px"> $orderby_clause = 'RAND()';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2393,7 +2389,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $orderby_clause = $orderby;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> // Default: order by post field.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby_clause = "$wpdb->posts.post_" . sanitize_key( $orderby );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby_clause = "{$this->db->posts}.post_" . sanitize_key( $orderby );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2480,13 +2476,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @return array List of posts.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_posts() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->parse_query();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2622,31 +2614,36 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $q['fields'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'ids':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fields = "$wpdb->posts.ID";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $fields = "{$this->db->posts}.ID";
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'id=>parent':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fields = "$wpdb->posts.ID, $wpdb->posts.post_parent";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $fields = "{$this->db->posts}.ID, {$this->db->posts}.post_parent";
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fields = "$wpdb->posts.*";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $fields = "{$this->db->posts}.*";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( '' !== $q['menu_order'] )
- $where .= " AND $wpdb->posts.menu_order = " . $q['menu_order'];
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( '' !== $q['menu_order'] ) {
+ $where .= " AND {$this->db->posts}.menu_order = " . $q['menu_order'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> // The "m" parameter is meant for months but accepts datetimes of varying specificity
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $q['m'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND YEAR($wpdb->posts.post_date)=" . substr($q['m'], 0, 4);
- if ( strlen($q['m']) > 5 )
- $where .= " AND MONTH($wpdb->posts.post_date)=" . substr($q['m'], 4, 2);
- if ( strlen($q['m']) > 7 )
- $where .= " AND DAYOFMONTH($wpdb->posts.post_date)=" . substr($q['m'], 6, 2);
- if ( strlen($q['m']) > 9 )
- $where .= " AND HOUR($wpdb->posts.post_date)=" . substr($q['m'], 8, 2);
- if ( strlen($q['m']) > 11 )
- $where .= " AND MINUTE($wpdb->posts.post_date)=" . substr($q['m'], 10, 2);
- if ( strlen($q['m']) > 13 )
- $where .= " AND SECOND($wpdb->posts.post_date)=" . substr($q['m'], 12, 2);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND YEAR({$this->db->posts}.post_date)=" . substr($q['m'], 0, 4);
+ if ( strlen($q['m']) > 5 ) {
+ $where .= " AND MONTH({$this->db->posts}.post_date)=" . substr($q['m'], 4, 2);
+ }
+ if ( strlen($q['m']) > 7 ) {
+ $where .= " AND DAYOFMONTH({$this->db->posts}.post_date)=" . substr($q['m'], 6, 2);
+ }
+ if ( strlen($q['m']) > 9 ) {
+ $where .= " AND HOUR({$this->db->posts}.post_date)=" . substr($q['m'], 8, 2);
+ }
+ if ( strlen($q['m']) > 11 ) {
+ $where .= " AND MINUTE({$this->db->posts}.post_date)=" . substr($q['m'], 10, 2);
+ }
+ if ( strlen($q['m']) > 13 ) {
+ $where .= " AND SECOND({$this->db->posts}.post_date)=" . substr($q['m'], 12, 2);
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Handle the other individual date parameters
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2709,13 +2706,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '' !== $q['title'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= $wpdb->prepare( " AND $wpdb->posts.post_title = %s", stripslashes( $q['title'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= $this->db->prepare( " AND {$this->db->posts}.post_title = %s", stripslashes( $q['title'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parameters related to 'post_name'.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '' != $q['name'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $q['name'] = sanitize_title_for_query( $q['name'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND $wpdb->posts.post_name = '" . $q['name'] . "'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_name = '" . $q['name'] . "'";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( '' != $q['pagename'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset($this->queried_object_id) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $reqpage = $this->queried_object_id;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2744,7 +2741,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ('page' != get_option('show_on_front') ) || empty($page_for_posts) || ( $reqpage != $page_for_posts ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $q['name'] = $q['pagename'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND ($wpdb->posts.ID = '$reqpage')";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND ({$this->db->posts}.ID = '$reqpage')";
</ins><span class="cx" style="display: block; padding: 0 10px"> $reqpage_obj = get_post( $reqpage );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->is_attachment = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2756,11 +2753,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( '' != $q['attachment'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $q['name'] = $q['attachment'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_name = '" . $q['attachment'] . "'";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( is_array( $q['post_name__in'] ) && ! empty( $q['post_name__in'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $q['post_name__in'] = array_map( 'sanitize_title_for_query', $q['post_name__in'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $post_name__in = "'" . implode( "','", $q['post_name__in'] ) . "'";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND $wpdb->posts.post_name IN ($post_name__in)";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_name IN ($post_name__in)";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If an attachment is requested by number, let it supersede any post number.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2769,29 +2766,29 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If a post number is specified, load that post
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $q['p'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND {$wpdb->posts}.ID = " . $q['p'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.ID = " . $q['p'];
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $q['post__in'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post__in = implode(',', array_map( 'absint', $q['post__in'] ));
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND {$wpdb->posts}.ID IN ($post__in)";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.ID IN ($post__in)";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $q['post__not_in'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post__not_in = implode(',', array_map( 'absint', $q['post__not_in'] ));
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.ID NOT IN ($post__not_in)";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_numeric( $q['post_parent'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= $wpdb->prepare( " AND $wpdb->posts.post_parent = %d ", $q['post_parent'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= $this->db->prepare( " AND {$this->db->posts}.post_parent = %d ", $q['post_parent'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $q['post_parent__in'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_parent__in = implode( ',', array_map( 'absint', $q['post_parent__in'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND {$wpdb->posts}.post_parent IN ($post_parent__in)";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_parent IN ($post_parent__in)";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $q['post_parent__not_in'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_parent__not_in = implode( ',', array_map( 'absint', $q['post_parent__not_in'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND {$wpdb->posts}.post_parent NOT IN ($post_parent__not_in)";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_parent NOT IN ($post_parent__not_in)";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $q['page_id'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $q['p'] = $q['page_id'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where = " AND {$wpdb->posts}.ID = " . $q['page_id'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where = " AND {$this->db->posts}.ID = " . $q['page_id'];
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2816,7 +2813,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !$this->is_singular ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->parse_tax_query( $q );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $clauses = $this->tax_query->get_sql( $this->db->posts, 'ID' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $join .= $clauses['join'];
</span><span class="cx" style="display: block; padding: 0 10px"> $where .= $clauses['where'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2900,7 +2897,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !empty( $this->tax_query->queries ) || !empty( $this->meta_query->queries ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $groupby = "{$wpdb->posts}.ID";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $groupby = "{$this->db->posts}.ID";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Author/user stuff
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2917,10 +2914,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $q['author__not_in'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $author__not_in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__not_in'] ) ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_author NOT IN ($author__not_in) ";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! empty( $q['author__in'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND {$wpdb->posts}.post_author IN ($author__in) ";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_author IN ($author__in) ";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Author stuff for nice URLs
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2938,18 +2935,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $q['author'] = get_user_by('slug', $q['author_name']);
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $q['author'] )
</span><span class="cx" style="display: block; padding: 0 10px"> $q['author'] = $q['author']->ID;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $whichauthor .= " AND ($wpdb->posts.post_author = " . absint($q['author']) . ')';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $whichauthor .= " AND ({$this->db->posts}.post_author = " . absint($q['author']) . ')';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // MIME-Type stuff for attachment browsing
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] )
- $whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $wpdb->posts );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] ) {
+ $whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $this->db->posts );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $where .= $search . $whichauthor . $whichmimetype;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->meta_query->queries ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $clauses = $this->meta_query->get_sql( 'post', $wpdb->posts, 'ID', $this );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $clauses = $this->meta_query->get_sql( 'post', $this->db->posts, 'ID', $this );
</ins><span class="cx" style="display: block; padding: 0 10px"> $join .= $clauses['join'];
</span><span class="cx" style="display: block; padding: 0 10px"> $where .= $clauses['where'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2970,16 +2967,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $q['orderby'] ) && ( is_array( $q['orderby'] ) || false === $q['orderby'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $orderby = '';
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby = "$wpdb->posts.post_date " . $q['order'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby = "{$this->db->posts}.post_date " . $q['order'];
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'none' == $q['orderby'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $orderby = '';
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $q['orderby'] == 'post__in' && ! empty( $post__in ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby = "FIELD( {$wpdb->posts}.ID, $post__in )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby = "FIELD( {$this->db->posts}.ID, $post__in )";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $q['orderby'] == 'post_parent__in' && ! empty( $post_parent__in ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby = "FIELD( {$wpdb->posts}.post_parent, $post_parent__in )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby = "FIELD( {$this->db->posts}.post_parent, $post_parent__in )";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $q['orderby'] == 'post_name__in' && ! empty( $post_name__in ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby = "FIELD( {$wpdb->posts}.post_name, $post_name__in )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby = "FIELD( {$this->db->posts}.post_name, $post_name__in )";
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $orderby_array = array();
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $q['orderby'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3011,7 +3008,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $orderby = implode( ' ' . $q['order'] . ', ', $orderby_array );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $orderby ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby = "$wpdb->posts.post_date " . $q['order'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby = "{$this->db->posts}.post_date " . $q['order'];
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! empty( $q['order'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $orderby .= " {$q['order']}";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3051,41 +3048,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $q['post_password'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= $wpdb->prepare( " AND $wpdb->posts.post_password = %s", $q['post_password'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= $this->db->prepare( " AND {$this->db->posts}.post_password = %s", $q['post_password'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $q['perm'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $q['perm'] = 'readable';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( isset( $q['has_password'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= sprintf( " AND $wpdb->posts.post_password %s ''", $q['has_password'] ? '!=' : '=' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= sprintf( " AND {$this->db->posts}.post_password %s ''", $q['has_password'] ? '!=' : '=' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $q['comment_status'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= $wpdb->prepare( " AND $wpdb->posts.comment_status = %s ", $q['comment_status'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= $this->db->prepare( " AND {$this->db->posts}.comment_status = %s ", $q['comment_status'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $q['ping_status'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= $wpdb->prepare( " AND $wpdb->posts.ping_status = %s ", $q['ping_status'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= $this->db->prepare( " AND {$this->db->posts}.ping_status = %s ", $q['ping_status'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'any' == $post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $in_search_post_types = get_post_types( array('exclude_from_search' => false) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $in_search_post_types ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $in_search_post_types ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $where .= ' AND 1=0 ';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- else
- $where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $in_search_post_types ) . "')";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } else {
+ $where .= " AND {$this->db->posts}.post_type IN ('" . join("', '", $in_search_post_types ) . "')";
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( !empty( $post_type ) && is_array( $post_type ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $post_type) . "')";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_type IN ('" . join("', '", $post_type) . "')";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! empty( $post_type ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND $wpdb->posts.post_type = '$post_type'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_type = '$post_type'";
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_type_object = get_post_type_object ( $post_type );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $this->is_attachment ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND $wpdb->posts.post_type = 'attachment'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_type = 'attachment'";
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_type_object = get_post_type_object ( 'attachment' );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $this->is_page ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND $wpdb->posts.post_type = 'page'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_type = 'page'";
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_type_object = get_post_type_object ( 'page' );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND $wpdb->posts.post_type = 'post'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND {$this->db->posts}.post_type = 'post'";
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_type_object = get_post_type_object ( 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3114,16 +3112,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( in_array( 'any', $q_status ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( get_post_stati( array( 'exclude_from_search' => true ) ) as $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! in_array( $status, $q_status ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $e_status[] = "$wpdb->posts.post_status <> '$status'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $e_status[] = "{$this->db->posts}.post_status <> '$status'";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( get_post_stati() as $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( in_array( $status, $q_status ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'private' == $status )
- $p_status[] = "$wpdb->posts.post_status = '$status'";
- else
- $r_status[] = "$wpdb->posts.post_status = '$status'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'private' == $status ) {
+ $p_status[] = "{$this->db->posts}.post_status = '$status'";
+ } else {
+ $r_status[] = "{$this->db->posts}.post_status = '$status'";
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3137,49 +3136,54 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $statuswheres[] = "(" . join( ' AND ', $e_status ) . ")";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !empty($r_status) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap) )
- $statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $r_status ) . "))";
- else
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap) ) {
+ $statuswheres[] = "({$this->db->posts}.post_author = $user_id " . "AND (" . join( ' OR ', $r_status ) . "))";
+ } else {
</ins><span class="cx" style="display: block; padding: 0 10px"> $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !empty($p_status) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) )
- $statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $p_status ) . "))";
- else
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) ) {
+ $statuswheres[] = "({$this->db->posts}.post_author = $user_id " . "AND (" . join( ' OR ', $p_status ) . "))";
+ } else {
</ins><span class="cx" style="display: block; padding: 0 10px"> $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $post_status_join ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $join .= " LEFT JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) ";
- foreach ( $statuswheres as $index => $statuswhere )
- $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $join .= " LEFT JOIN {$this->db->posts} AS p2 ON ({$this->db->posts}.post_parent = p2.ID) ";
+ foreach ( $statuswheres as $index => $statuswhere ) {
+ $statuswheres[$index] = "($statuswhere OR ({$this->db->posts}.post_status = 'inherit' AND " . str_replace( $this->db->posts, 'p2', $statuswhere ) . "))";
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $where_status = implode( ' OR ', $statuswheres );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $where_status ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $where .= " AND ($where_status)";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( !$this->is_singular ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " AND ($wpdb->posts.post_status = 'publish'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " AND ({$this->db->posts}.post_status = 'publish'";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add public states.
</span><span class="cx" style="display: block; padding: 0 10px"> $public_states = get_post_stati( array('public' => true) );
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $public_states as $state ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'publish' == $state ) // Publish is hard-coded above.
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where .= " OR $wpdb->posts.post_status = '$state'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where .= " OR {$this->db->posts}.post_status = '$state'";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->is_admin ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Add protected states that should show in the admin all list.
</span><span class="cx" style="display: block; padding: 0 10px"> $admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( (array) $admin_all_states as $state )
- $where .= " OR $wpdb->posts.post_status = '$state'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( (array) $admin_all_states as $state ) {
+ $where .= " OR {$this->db->posts}.post_status = '$state'";
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_user_logged_in() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states.
</span><span class="cx" style="display: block; padding: 0 10px"> $private_states = get_post_stati( array('private' => true) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( (array) $private_states as $state )
- $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status = '$state'";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( (array) $private_states as $state ) {
+ $where .= current_user_can( $read_private_cap ) ? " OR {$this->db->posts}.post_status = '$state'" : " OR {$this->db->posts}.post_author = $user_id AND {$this->db->posts}.post_status = '$state'";
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $where .= ')';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3230,11 +3234,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Comments feeds
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->is_comment_feed && ! $this->is_singular ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->is_archive || $this->is_search ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cjoin = "JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join ";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cjoin = "JOIN {$this->db->posts} ON ({$this->db->comments}.comment_post_ID = {$this->db->posts}.ID) $join ";
</ins><span class="cx" style="display: block; padding: 0 10px"> $cwhere = "WHERE comment_approved = '1' $where";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cgroupby = "$wpdb->comments.comment_id";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cgroupby = "{$this->db->comments}.comment_id";
</ins><span class="cx" style="display: block; padding: 0 10px"> } else { // Other non singular e.g. front
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cjoin = "JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cjoin = "JOIN {$this->db->posts} ON ( {$this->db->comments}.comment_post_ID = {$this->db->posts}.ID )";
</ins><span class="cx" style="display: block; padding: 0 10px"> $cwhere = "WHERE ( post_status = 'publish' OR ( post_status = 'inherit' && post_type = 'attachment' ) ) AND comment_approved = '1'";
</span><span class="cx" style="display: block; padding: 0 10px"> $cgroupby = '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3293,7 +3297,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
</span><span class="cx" style="display: block; padding: 0 10px"> $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits");
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $comments = (array) $this->db->get_results("SELECT $distinct {$this->db->comments}.* FROM {$this->db->comments} $cjoin $cwhere $cgroupby $corderby $climits");
</ins><span class="cx" style="display: block; padding: 0 10px"> // Convert to WP_Comment
</span><span class="cx" style="display: block; padding: 0 10px"> $this->comments = array_map( 'get_comment', $comments );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->comment_count = count($this->comments);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3305,10 +3309,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_ids = join(',', $post_ids);
</span><span class="cx" style="display: block; padding: 0 10px"> $join = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $post_ids )
- $where = "AND $wpdb->posts.ID IN ($post_ids) ";
- else
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $post_ids ) {
+ $where = "AND {$this->db->posts}.ID IN ($post_ids) ";
+ } else {
</ins><span class="cx" style="display: block; padding: 0 10px"> $where = "AND 0";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $pieces = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3547,7 +3552,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !$q['no_found_rows'] && !empty($limits) )
</span><span class="cx" style="display: block; padding: 0 10px"> $found_rows = 'SQL_CALC_FOUND_ROWS';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->request = $old_request = "SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->request = $old_request = "SELECT $found_rows $distinct $fields FROM {$this->db->posts} $join WHERE 1=1 $where $groupby $orderby $limits";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !$q['suppress_filters'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3581,7 +3586,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'ids' == $q['fields'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( null === $this->posts ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->posts = $wpdb->get_col( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->posts = $this->db->get_col( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->posts = array_map( 'intval', $this->posts );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3593,7 +3598,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'id=>parent' == $q['fields'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( null === $this->posts ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->posts = $wpdb->get_results( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->posts = $this->db->get_results( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->post_count = count( $this->posts );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3611,7 +3616,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( null === $this->posts ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $split_the_query = ( $old_request == $this->request && "{$this->db->posts}.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters whether to split the query.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3630,7 +3635,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $split_the_query ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // First get the IDs and then fill in the objects
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->request = "SELECT $found_rows $distinct $wpdb->posts.ID FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->request = "SELECT $found_rows $distinct {$this->db->posts}.ID FROM {$this->db->posts} $join WHERE 1=1 $where $groupby $orderby $limits";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the Post IDs SQL request before sending.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3642,7 +3647,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $this->request = apply_filters( 'posts_request_ids', $this->request, $this );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $ids = $wpdb->get_col( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $ids = $this->db->get_col( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $ids ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->posts = $ids;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3652,7 +3657,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->posts = array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->posts = $wpdb->get_results( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->posts = $this->db->get_results( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->set_found_posts( $q, $limits );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3692,8 +3697,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-includes/query.php */
</span><span class="cx" style="display: block; padding: 0 10px"> $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits";
- $comments = $wpdb->get_results($comments_request);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $comments_request = "SELECT {$this->db->comments}.* FROM {$this->db->comments} $cjoin $cwhere $cgroupby $corderby $climits";
+ $comments = $this->db->get_results($comments_request);
</ins><span class="cx" style="display: block; padding: 0 10px"> // Convert to WP_Comment
</span><span class="cx" style="display: block; padding: 0 10px"> $this->comments = array_map( 'get_comment', $comments );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->comment_count = count($this->comments);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3836,14 +3841,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access private
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param array $q Query variables.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $limits LIMIT clauses of the query.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private function set_found_posts( $q, $limits ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Bail if posts is an empty array. Continue if posts is an empty string,
</span><span class="cx" style="display: block; padding: 0 10px"> // null, or false to accommodate caching plugins that fill posts later.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3858,7 +3859,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $found_posts The query to run to find the found posts.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param WP_Query &$this The WP_Query instance (passed by reference).
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->found_posts = $this->db->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->found_posts = count( $this->posts );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4156,9 +4157,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array $query URL query string or array of vars.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function __construct($query = '') {
- if ( ! empty($query) ) {
- $this->query($query);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function __construct( $query = '' ) {
+ $this->db = $GLOBALS['wpdb'];
+
+ if ( ! empty( $query ) ) {
+ $this->query( $query );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>