Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-inclu...
File: class-wp-query.php
$q['posts_per_page'] = get_option( 'posts_per_rss' );
[2000] Fix | Delete
}
[2001] Fix | Delete
$q['nopaging'] = false;
[2002] Fix | Delete
}
[2003] Fix | Delete
$q['posts_per_page'] = (int) $q['posts_per_page'];
[2004] Fix | Delete
if ( $q['posts_per_page'] < -1 ) {
[2005] Fix | Delete
$q['posts_per_page'] = abs( $q['posts_per_page'] );
[2006] Fix | Delete
} elseif ( 0 == $q['posts_per_page'] ) {
[2007] Fix | Delete
$q['posts_per_page'] = 1;
[2008] Fix | Delete
}
[2009] Fix | Delete
[2010] Fix | Delete
if ( ! isset( $q['comments_per_page'] ) || 0 == $q['comments_per_page'] ) {
[2011] Fix | Delete
$q['comments_per_page'] = get_option( 'comments_per_page' );
[2012] Fix | Delete
}
[2013] Fix | Delete
[2014] Fix | Delete
if ( $this->is_home && ( empty( $this->query ) || 'true' === $q['preview'] ) && ( 'page' === get_option( 'show_on_front' ) ) && get_option( 'page_on_front' ) ) {
[2015] Fix | Delete
$this->is_page = true;
[2016] Fix | Delete
$this->is_home = false;
[2017] Fix | Delete
$q['page_id'] = get_option( 'page_on_front' );
[2018] Fix | Delete
}
[2019] Fix | Delete
[2020] Fix | Delete
if ( isset( $q['page'] ) ) {
[2021] Fix | Delete
$q['page'] = is_scalar( $q['page'] ) ? absint( trim( $q['page'], '/' ) ) : 0;
[2022] Fix | Delete
}
[2023] Fix | Delete
[2024] Fix | Delete
// If true, forcibly turns off SQL_CALC_FOUND_ROWS even when limits are present.
[2025] Fix | Delete
if ( isset( $q['no_found_rows'] ) ) {
[2026] Fix | Delete
$q['no_found_rows'] = (bool) $q['no_found_rows'];
[2027] Fix | Delete
} else {
[2028] Fix | Delete
$q['no_found_rows'] = false;
[2029] Fix | Delete
}
[2030] Fix | Delete
[2031] Fix | Delete
switch ( $q['fields'] ) {
[2032] Fix | Delete
case 'ids':
[2033] Fix | Delete
$fields = "{$wpdb->posts}.ID";
[2034] Fix | Delete
break;
[2035] Fix | Delete
case 'id=>parent':
[2036] Fix | Delete
$fields = "{$wpdb->posts}.ID, {$wpdb->posts}.post_parent";
[2037] Fix | Delete
break;
[2038] Fix | Delete
default:
[2039] Fix | Delete
$fields = "{$wpdb->posts}.*";
[2040] Fix | Delete
}
[2041] Fix | Delete
[2042] Fix | Delete
if ( '' !== $q['menu_order'] ) {
[2043] Fix | Delete
$where .= " AND {$wpdb->posts}.menu_order = " . $q['menu_order'];
[2044] Fix | Delete
}
[2045] Fix | Delete
// The "m" parameter is meant for months but accepts datetimes of varying specificity.
[2046] Fix | Delete
if ( $q['m'] ) {
[2047] Fix | Delete
$where .= " AND YEAR({$wpdb->posts}.post_date)=" . substr( $q['m'], 0, 4 );
[2048] Fix | Delete
if ( strlen( $q['m'] ) > 5 ) {
[2049] Fix | Delete
$where .= " AND MONTH({$wpdb->posts}.post_date)=" . substr( $q['m'], 4, 2 );
[2050] Fix | Delete
}
[2051] Fix | Delete
if ( strlen( $q['m'] ) > 7 ) {
[2052] Fix | Delete
$where .= " AND DAYOFMONTH({$wpdb->posts}.post_date)=" . substr( $q['m'], 6, 2 );
[2053] Fix | Delete
}
[2054] Fix | Delete
if ( strlen( $q['m'] ) > 9 ) {
[2055] Fix | Delete
$where .= " AND HOUR({$wpdb->posts}.post_date)=" . substr( $q['m'], 8, 2 );
[2056] Fix | Delete
}
[2057] Fix | Delete
if ( strlen( $q['m'] ) > 11 ) {
[2058] Fix | Delete
$where .= " AND MINUTE({$wpdb->posts}.post_date)=" . substr( $q['m'], 10, 2 );
[2059] Fix | Delete
}
[2060] Fix | Delete
if ( strlen( $q['m'] ) > 13 ) {
[2061] Fix | Delete
$where .= " AND SECOND({$wpdb->posts}.post_date)=" . substr( $q['m'], 12, 2 );
[2062] Fix | Delete
}
[2063] Fix | Delete
}
[2064] Fix | Delete
[2065] Fix | Delete
// Handle the other individual date parameters.
[2066] Fix | Delete
$date_parameters = array();
[2067] Fix | Delete
[2068] Fix | Delete
if ( '' !== $q['hour'] ) {
[2069] Fix | Delete
$date_parameters['hour'] = $q['hour'];
[2070] Fix | Delete
}
[2071] Fix | Delete
[2072] Fix | Delete
if ( '' !== $q['minute'] ) {
[2073] Fix | Delete
$date_parameters['minute'] = $q['minute'];
[2074] Fix | Delete
}
[2075] Fix | Delete
[2076] Fix | Delete
if ( '' !== $q['second'] ) {
[2077] Fix | Delete
$date_parameters['second'] = $q['second'];
[2078] Fix | Delete
}
[2079] Fix | Delete
[2080] Fix | Delete
if ( $q['year'] ) {
[2081] Fix | Delete
$date_parameters['year'] = $q['year'];
[2082] Fix | Delete
}
[2083] Fix | Delete
[2084] Fix | Delete
if ( $q['monthnum'] ) {
[2085] Fix | Delete
$date_parameters['monthnum'] = $q['monthnum'];
[2086] Fix | Delete
}
[2087] Fix | Delete
[2088] Fix | Delete
if ( $q['w'] ) {
[2089] Fix | Delete
$date_parameters['week'] = $q['w'];
[2090] Fix | Delete
}
[2091] Fix | Delete
[2092] Fix | Delete
if ( $q['day'] ) {
[2093] Fix | Delete
$date_parameters['day'] = $q['day'];
[2094] Fix | Delete
}
[2095] Fix | Delete
[2096] Fix | Delete
if ( $date_parameters ) {
[2097] Fix | Delete
$date_query = new WP_Date_Query( array( $date_parameters ) );
[2098] Fix | Delete
$where .= $date_query->get_sql();
[2099] Fix | Delete
}
[2100] Fix | Delete
unset( $date_parameters, $date_query );
[2101] Fix | Delete
[2102] Fix | Delete
// Handle complex date queries.
[2103] Fix | Delete
if ( ! empty( $q['date_query'] ) ) {
[2104] Fix | Delete
$this->date_query = new WP_Date_Query( $q['date_query'] );
[2105] Fix | Delete
$where .= $this->date_query->get_sql();
[2106] Fix | Delete
}
[2107] Fix | Delete
[2108] Fix | Delete
// If we've got a post_type AND it's not "any" post_type.
[2109] Fix | Delete
if ( ! empty( $q['post_type'] ) && 'any' !== $q['post_type'] ) {
[2110] Fix | Delete
foreach ( (array) $q['post_type'] as $_post_type ) {
[2111] Fix | Delete
$ptype_obj = get_post_type_object( $_post_type );
[2112] Fix | Delete
if ( ! $ptype_obj || ! $ptype_obj->query_var || empty( $q[ $ptype_obj->query_var ] ) ) {
[2113] Fix | Delete
continue;
[2114] Fix | Delete
}
[2115] Fix | Delete
[2116] Fix | Delete
if ( ! $ptype_obj->hierarchical ) {
[2117] Fix | Delete
// Non-hierarchical post types can directly use 'name'.
[2118] Fix | Delete
$q['name'] = $q[ $ptype_obj->query_var ];
[2119] Fix | Delete
} else {
[2120] Fix | Delete
// Hierarchical post types will operate through 'pagename'.
[2121] Fix | Delete
$q['pagename'] = $q[ $ptype_obj->query_var ];
[2122] Fix | Delete
$q['name'] = '';
[2123] Fix | Delete
}
[2124] Fix | Delete
[2125] Fix | Delete
// Only one request for a slug is possible, this is why name & pagename are overwritten above.
[2126] Fix | Delete
break;
[2127] Fix | Delete
} // End foreach.
[2128] Fix | Delete
unset( $ptype_obj );
[2129] Fix | Delete
}
[2130] Fix | Delete
[2131] Fix | Delete
if ( '' !== $q['title'] ) {
[2132] Fix | Delete
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title = %s", stripslashes( $q['title'] ) );
[2133] Fix | Delete
}
[2134] Fix | Delete
[2135] Fix | Delete
// Parameters related to 'post_name'.
[2136] Fix | Delete
if ( '' !== $q['name'] ) {
[2137] Fix | Delete
$q['name'] = sanitize_title_for_query( $q['name'] );
[2138] Fix | Delete
$where .= " AND {$wpdb->posts}.post_name = '" . $q['name'] . "'";
[2139] Fix | Delete
} elseif ( '' !== $q['pagename'] ) {
[2140] Fix | Delete
if ( isset( $this->queried_object_id ) ) {
[2141] Fix | Delete
$reqpage = $this->queried_object_id;
[2142] Fix | Delete
} else {
[2143] Fix | Delete
if ( 'page' !== $q['post_type'] ) {
[2144] Fix | Delete
foreach ( (array) $q['post_type'] as $_post_type ) {
[2145] Fix | Delete
$ptype_obj = get_post_type_object( $_post_type );
[2146] Fix | Delete
if ( ! $ptype_obj || ! $ptype_obj->hierarchical ) {
[2147] Fix | Delete
continue;
[2148] Fix | Delete
}
[2149] Fix | Delete
[2150] Fix | Delete
$reqpage = get_page_by_path( $q['pagename'], OBJECT, $_post_type );
[2151] Fix | Delete
if ( $reqpage ) {
[2152] Fix | Delete
break;
[2153] Fix | Delete
}
[2154] Fix | Delete
}
[2155] Fix | Delete
unset( $ptype_obj );
[2156] Fix | Delete
} else {
[2157] Fix | Delete
$reqpage = get_page_by_path( $q['pagename'] );
[2158] Fix | Delete
}
[2159] Fix | Delete
if ( ! empty( $reqpage ) ) {
[2160] Fix | Delete
$reqpage = $reqpage->ID;
[2161] Fix | Delete
} else {
[2162] Fix | Delete
$reqpage = 0;
[2163] Fix | Delete
}
[2164] Fix | Delete
}
[2165] Fix | Delete
[2166] Fix | Delete
$page_for_posts = get_option( 'page_for_posts' );
[2167] Fix | Delete
if ( ( 'page' !== get_option( 'show_on_front' ) ) || empty( $page_for_posts ) || ( $reqpage != $page_for_posts ) ) {
[2168] Fix | Delete
$q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) );
[2169] Fix | Delete
$q['name'] = $q['pagename'];
[2170] Fix | Delete
$where .= " AND ({$wpdb->posts}.ID = '$reqpage')";
[2171] Fix | Delete
$reqpage_obj = get_post( $reqpage );
[2172] Fix | Delete
if ( is_object( $reqpage_obj ) && 'attachment' === $reqpage_obj->post_type ) {
[2173] Fix | Delete
$this->is_attachment = true;
[2174] Fix | Delete
$post_type = 'attachment';
[2175] Fix | Delete
$q['post_type'] = 'attachment';
[2176] Fix | Delete
$this->is_page = true;
[2177] Fix | Delete
$q['attachment_id'] = $reqpage;
[2178] Fix | Delete
}
[2179] Fix | Delete
}
[2180] Fix | Delete
} elseif ( '' !== $q['attachment'] ) {
[2181] Fix | Delete
$q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) );
[2182] Fix | Delete
$q['name'] = $q['attachment'];
[2183] Fix | Delete
$where .= " AND {$wpdb->posts}.post_name = '" . $q['attachment'] . "'";
[2184] Fix | Delete
} elseif ( is_array( $q['post_name__in'] ) && ! empty( $q['post_name__in'] ) ) {
[2185] Fix | Delete
$q['post_name__in'] = array_map( 'sanitize_title_for_query', $q['post_name__in'] );
[2186] Fix | Delete
$post_name__in = "'" . implode( "','", $q['post_name__in'] ) . "'";
[2187] Fix | Delete
$where .= " AND {$wpdb->posts}.post_name IN ($post_name__in)";
[2188] Fix | Delete
}
[2189] Fix | Delete
[2190] Fix | Delete
// If an attachment is requested by number, let it supersede any post number.
[2191] Fix | Delete
if ( $q['attachment_id'] ) {
[2192] Fix | Delete
$q['p'] = absint( $q['attachment_id'] );
[2193] Fix | Delete
}
[2194] Fix | Delete
[2195] Fix | Delete
// If a post number is specified, load that post.
[2196] Fix | Delete
if ( $q['p'] ) {
[2197] Fix | Delete
$where .= " AND {$wpdb->posts}.ID = " . $q['p'];
[2198] Fix | Delete
} elseif ( $q['post__in'] ) {
[2199] Fix | Delete
$post__in = implode( ',', array_map( 'absint', $q['post__in'] ) );
[2200] Fix | Delete
$where .= " AND {$wpdb->posts}.ID IN ($post__in)";
[2201] Fix | Delete
} elseif ( $q['post__not_in'] ) {
[2202] Fix | Delete
$post__not_in = implode( ',', array_map( 'absint', $q['post__not_in'] ) );
[2203] Fix | Delete
$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
[2204] Fix | Delete
}
[2205] Fix | Delete
[2206] Fix | Delete
if ( is_numeric( $q['post_parent'] ) ) {
[2207] Fix | Delete
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_parent = %d ", $q['post_parent'] );
[2208] Fix | Delete
} elseif ( $q['post_parent__in'] ) {
[2209] Fix | Delete
$post_parent__in = implode( ',', array_map( 'absint', $q['post_parent__in'] ) );
[2210] Fix | Delete
$where .= " AND {$wpdb->posts}.post_parent IN ($post_parent__in)";
[2211] Fix | Delete
} elseif ( $q['post_parent__not_in'] ) {
[2212] Fix | Delete
$post_parent__not_in = implode( ',', array_map( 'absint', $q['post_parent__not_in'] ) );
[2213] Fix | Delete
$where .= " AND {$wpdb->posts}.post_parent NOT IN ($post_parent__not_in)";
[2214] Fix | Delete
}
[2215] Fix | Delete
[2216] Fix | Delete
if ( $q['page_id'] ) {
[2217] Fix | Delete
if ( ( 'page' !== get_option( 'show_on_front' ) ) || ( get_option( 'page_for_posts' ) != $q['page_id'] ) ) {
[2218] Fix | Delete
$q['p'] = $q['page_id'];
[2219] Fix | Delete
$where = " AND {$wpdb->posts}.ID = " . $q['page_id'];
[2220] Fix | Delete
}
[2221] Fix | Delete
}
[2222] Fix | Delete
[2223] Fix | Delete
// If a search pattern is specified, load the posts that match.
[2224] Fix | Delete
if ( strlen( $q['s'] ) ) {
[2225] Fix | Delete
$search = $this->parse_search( $q );
[2226] Fix | Delete
}
[2227] Fix | Delete
[2228] Fix | Delete
if ( ! $q['suppress_filters'] ) {
[2229] Fix | Delete
/**
[2230] Fix | Delete
* Filters the search SQL that is used in the WHERE clause of WP_Query.
[2231] Fix | Delete
*
[2232] Fix | Delete
* @since 3.0.0
[2233] Fix | Delete
*
[2234] Fix | Delete
* @param string $search Search SQL for WHERE clause.
[2235] Fix | Delete
* @param WP_Query $query The current WP_Query object.
[2236] Fix | Delete
*/
[2237] Fix | Delete
$search = apply_filters_ref_array( 'posts_search', array( $search, &$this ) );
[2238] Fix | Delete
}
[2239] Fix | Delete
[2240] Fix | Delete
// Taxonomies.
[2241] Fix | Delete
if ( ! $this->is_singular ) {
[2242] Fix | Delete
$this->parse_tax_query( $q );
[2243] Fix | Delete
[2244] Fix | Delete
$clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' );
[2245] Fix | Delete
[2246] Fix | Delete
$join .= $clauses['join'];
[2247] Fix | Delete
$where .= $clauses['where'];
[2248] Fix | Delete
}
[2249] Fix | Delete
[2250] Fix | Delete
if ( $this->is_tax ) {
[2251] Fix | Delete
if ( empty( $post_type ) ) {
[2252] Fix | Delete
// Do a fully inclusive search for currently registered post types of queried taxonomies.
[2253] Fix | Delete
$post_type = array();
[2254] Fix | Delete
$taxonomies = array_keys( $this->tax_query->queried_terms );
[2255] Fix | Delete
foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) {
[2256] Fix | Delete
$object_taxonomies = 'attachment' === $pt ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
[2257] Fix | Delete
if ( array_intersect( $taxonomies, $object_taxonomies ) ) {
[2258] Fix | Delete
$post_type[] = $pt;
[2259] Fix | Delete
}
[2260] Fix | Delete
}
[2261] Fix | Delete
if ( ! $post_type ) {
[2262] Fix | Delete
$post_type = 'any';
[2263] Fix | Delete
} elseif ( count( $post_type ) === 1 ) {
[2264] Fix | Delete
$post_type = $post_type[0];
[2265] Fix | Delete
} else {
[2266] Fix | Delete
// Sort post types to ensure same cache key generation.
[2267] Fix | Delete
sort( $post_type );
[2268] Fix | Delete
}
[2269] Fix | Delete
[2270] Fix | Delete
$post_status_join = true;
[2271] Fix | Delete
} elseif ( in_array( 'attachment', (array) $post_type, true ) ) {
[2272] Fix | Delete
$post_status_join = true;
[2273] Fix | Delete
}
[2274] Fix | Delete
}
[2275] Fix | Delete
[2276] Fix | Delete
/*
[2277] Fix | Delete
* Ensure that 'taxonomy', 'term', 'term_id', 'cat', and
[2278] Fix | Delete
* 'category_name' vars are set for backward compatibility.
[2279] Fix | Delete
*/
[2280] Fix | Delete
if ( ! empty( $this->tax_query->queried_terms ) ) {
[2281] Fix | Delete
[2282] Fix | Delete
/*
[2283] Fix | Delete
* Set 'taxonomy', 'term', and 'term_id' to the
[2284] Fix | Delete
* first taxonomy other than 'post_tag' or 'category'.
[2285] Fix | Delete
*/
[2286] Fix | Delete
if ( ! isset( $q['taxonomy'] ) ) {
[2287] Fix | Delete
foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) {
[2288] Fix | Delete
if ( empty( $queried_items['terms'][0] ) ) {
[2289] Fix | Delete
continue;
[2290] Fix | Delete
}
[2291] Fix | Delete
[2292] Fix | Delete
if ( ! in_array( $queried_taxonomy, array( 'category', 'post_tag' ), true ) ) {
[2293] Fix | Delete
$q['taxonomy'] = $queried_taxonomy;
[2294] Fix | Delete
[2295] Fix | Delete
if ( 'slug' === $queried_items['field'] ) {
[2296] Fix | Delete
$q['term'] = $queried_items['terms'][0];
[2297] Fix | Delete
} else {
[2298] Fix | Delete
$q['term_id'] = $queried_items['terms'][0];
[2299] Fix | Delete
}
[2300] Fix | Delete
[2301] Fix | Delete
// Take the first one we find.
[2302] Fix | Delete
break;
[2303] Fix | Delete
}
[2304] Fix | Delete
}
[2305] Fix | Delete
}
[2306] Fix | Delete
[2307] Fix | Delete
// 'cat', 'category_name', 'tag_id'.
[2308] Fix | Delete
foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) {
[2309] Fix | Delete
if ( empty( $queried_items['terms'][0] ) ) {
[2310] Fix | Delete
continue;
[2311] Fix | Delete
}
[2312] Fix | Delete
[2313] Fix | Delete
if ( 'category' === $queried_taxonomy ) {
[2314] Fix | Delete
$the_cat = get_term_by( $queried_items['field'], $queried_items['terms'][0], 'category' );
[2315] Fix | Delete
if ( $the_cat ) {
[2316] Fix | Delete
$this->set( 'cat', $the_cat->term_id );
[2317] Fix | Delete
$this->set( 'category_name', $the_cat->slug );
[2318] Fix | Delete
}
[2319] Fix | Delete
unset( $the_cat );
[2320] Fix | Delete
}
[2321] Fix | Delete
[2322] Fix | Delete
if ( 'post_tag' === $queried_taxonomy ) {
[2323] Fix | Delete
$the_tag = get_term_by( $queried_items['field'], $queried_items['terms'][0], 'post_tag' );
[2324] Fix | Delete
if ( $the_tag ) {
[2325] Fix | Delete
$this->set( 'tag_id', $the_tag->term_id );
[2326] Fix | Delete
}
[2327] Fix | Delete
unset( $the_tag );
[2328] Fix | Delete
}
[2329] Fix | Delete
}
[2330] Fix | Delete
}
[2331] Fix | Delete
[2332] Fix | Delete
if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) {
[2333] Fix | Delete
$groupby = "{$wpdb->posts}.ID";
[2334] Fix | Delete
}
[2335] Fix | Delete
[2336] Fix | Delete
// Author/user stuff.
[2337] Fix | Delete
[2338] Fix | Delete
if ( ! empty( $q['author'] ) && '0' != $q['author'] ) {
[2339] Fix | Delete
$q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) );
[2340] Fix | Delete
$authors = array_unique( array_map( 'intval', preg_split( '/[,\s]+/', $q['author'] ) ) );
[2341] Fix | Delete
foreach ( $authors as $author ) {
[2342] Fix | Delete
$key = $author > 0 ? 'author__in' : 'author__not_in';
[2343] Fix | Delete
$q[ $key ][] = abs( $author );
[2344] Fix | Delete
}
[2345] Fix | Delete
$q['author'] = implode( ',', $authors );
[2346] Fix | Delete
}
[2347] Fix | Delete
[2348] Fix | Delete
if ( ! empty( $q['author__not_in'] ) ) {
[2349] Fix | Delete
$author__not_in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__not_in'] ) ) );
[2350] Fix | Delete
$where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
[2351] Fix | Delete
} elseif ( ! empty( $q['author__in'] ) ) {
[2352] Fix | Delete
$author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) );
[2353] Fix | Delete
$where .= " AND {$wpdb->posts}.post_author IN ($author__in) ";
[2354] Fix | Delete
}
[2355] Fix | Delete
[2356] Fix | Delete
// Author stuff for nice URLs.
[2357] Fix | Delete
[2358] Fix | Delete
if ( '' !== $q['author_name'] ) {
[2359] Fix | Delete
if ( str_contains( $q['author_name'], '/' ) ) {
[2360] Fix | Delete
$q['author_name'] = explode( '/', $q['author_name'] );
[2361] Fix | Delete
if ( $q['author_name'][ count( $q['author_name'] ) - 1 ] ) {
[2362] Fix | Delete
$q['author_name'] = $q['author_name'][ count( $q['author_name'] ) - 1 ]; // No trailing slash.
[2363] Fix | Delete
} else {
[2364] Fix | Delete
$q['author_name'] = $q['author_name'][ count( $q['author_name'] ) - 2 ]; // There was a trailing slash.
[2365] Fix | Delete
}
[2366] Fix | Delete
}
[2367] Fix | Delete
$q['author_name'] = sanitize_title_for_query( $q['author_name'] );
[2368] Fix | Delete
$q['author'] = get_user_by( 'slug', $q['author_name'] );
[2369] Fix | Delete
if ( $q['author'] ) {
[2370] Fix | Delete
$q['author'] = $q['author']->ID;
[2371] Fix | Delete
}
[2372] Fix | Delete
$whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint( $q['author'] ) . ')';
[2373] Fix | Delete
}
[2374] Fix | Delete
[2375] Fix | Delete
// Matching by comment count.
[2376] Fix | Delete
if ( isset( $q['comment_count'] ) ) {
[2377] Fix | Delete
// Numeric comment count is converted to array format.
[2378] Fix | Delete
if ( is_numeric( $q['comment_count'] ) ) {
[2379] Fix | Delete
$q['comment_count'] = array(
[2380] Fix | Delete
'value' => (int) $q['comment_count'],
[2381] Fix | Delete
);
[2382] Fix | Delete
}
[2383] Fix | Delete
[2384] Fix | Delete
if ( isset( $q['comment_count']['value'] ) ) {
[2385] Fix | Delete
$q['comment_count'] = array_merge(
[2386] Fix | Delete
array(
[2387] Fix | Delete
'compare' => '=',
[2388] Fix | Delete
),
[2389] Fix | Delete
$q['comment_count']
[2390] Fix | Delete
);
[2391] Fix | Delete
[2392] Fix | Delete
// Fallback for invalid compare operators is '='.
[2393] Fix | Delete
$compare_operators = array( '=', '!=', '>', '>=', '<', '<=' );
[2394] Fix | Delete
if ( ! in_array( $q['comment_count']['compare'], $compare_operators, true ) ) {
[2395] Fix | Delete
$q['comment_count']['compare'] = '=';
[2396] Fix | Delete
}
[2397] Fix | Delete
[2398] Fix | Delete
$where .= $wpdb->prepare( " AND {$wpdb->posts}.comment_count {$q['comment_count']['compare']} %d", $q['comment_count']['value'] );
[2399] Fix | Delete
}
[2400] Fix | Delete
}
[2401] Fix | Delete
[2402] Fix | Delete
// MIME-Type stuff for attachment browsing.
[2403] Fix | Delete
[2404] Fix | Delete
if ( isset( $q['post_mime_type'] ) && '' !== $q['post_mime_type'] ) {
[2405] Fix | Delete
$whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $wpdb->posts );
[2406] Fix | Delete
}
[2407] Fix | Delete
$where .= $search . $whichauthor . $whichmimetype;
[2408] Fix | Delete
[2409] Fix | Delete
if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
[2410] Fix | Delete
$join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
[2411] Fix | Delete
}
[2412] Fix | Delete
[2413] Fix | Delete
if ( ! empty( $this->meta_query->queries ) ) {
[2414] Fix | Delete
$clauses = $this->meta_query->get_sql( 'post', $wpdb->posts, 'ID', $this );
[2415] Fix | Delete
$join .= $clauses['join'];
[2416] Fix | Delete
$where .= $clauses['where'];
[2417] Fix | Delete
}
[2418] Fix | Delete
[2419] Fix | Delete
$rand = ( isset( $q['orderby'] ) && 'rand' === $q['orderby'] );
[2420] Fix | Delete
if ( ! isset( $q['order'] ) ) {
[2421] Fix | Delete
$q['order'] = $rand ? '' : 'DESC';
[2422] Fix | Delete
} else {
[2423] Fix | Delete
$q['order'] = $rand ? '' : $this->parse_order( $q['order'] );
[2424] Fix | Delete
}
[2425] Fix | Delete
[2426] Fix | Delete
// These values of orderby should ignore the 'order' parameter.
[2427] Fix | Delete
$force_asc = array( 'post__in', 'post_name__in', 'post_parent__in' );
[2428] Fix | Delete
if ( isset( $q['orderby'] ) && in_array( $q['orderby'], $force_asc, true ) ) {
[2429] Fix | Delete
$q['order'] = '';
[2430] Fix | Delete
}
[2431] Fix | Delete
[2432] Fix | Delete
// Order by.
[2433] Fix | Delete
if ( empty( $q['orderby'] ) ) {
[2434] Fix | Delete
/*
[2435] Fix | Delete
* Boolean false or empty array blanks out ORDER BY,
[2436] Fix | Delete
* while leaving the value unset or otherwise empty sets the default.
[2437] Fix | Delete
*/
[2438] Fix | Delete
if ( isset( $q['orderby'] ) && ( is_array( $q['orderby'] ) || false === $q['orderby'] ) ) {
[2439] Fix | Delete
$orderby = '';
[2440] Fix | Delete
} else {
[2441] Fix | Delete
$orderby = "{$wpdb->posts}.post_date " . $q['order'];
[2442] Fix | Delete
}
[2443] Fix | Delete
} elseif ( 'none' === $q['orderby'] ) {
[2444] Fix | Delete
$orderby = '';
[2445] Fix | Delete
} else {
[2446] Fix | Delete
$orderby_array = array();
[2447] Fix | Delete
if ( is_array( $q['orderby'] ) ) {
[2448] Fix | Delete
foreach ( $q['orderby'] as $_orderby => $order ) {
[2449] Fix | Delete
$orderby = addslashes_gpc( urldecode( $_orderby ) );
[2450] Fix | Delete
$parsed = $this->parse_orderby( $orderby );
[2451] Fix | Delete
[2452] Fix | Delete
if ( ! $parsed ) {
[2453] Fix | Delete
continue;
[2454] Fix | Delete
}
[2455] Fix | Delete
[2456] Fix | Delete
$orderby_array[] = $parsed . ' ' . $this->parse_order( $order );
[2457] Fix | Delete
}
[2458] Fix | Delete
$orderby = implode( ', ', $orderby_array );
[2459] Fix | Delete
[2460] Fix | Delete
} else {
[2461] Fix | Delete
$q['orderby'] = urldecode( $q['orderby'] );
[2462] Fix | Delete
$q['orderby'] = addslashes_gpc( $q['orderby'] );
[2463] Fix | Delete
[2464] Fix | Delete
foreach ( explode( ' ', $q['orderby'] ) as $i => $orderby ) {
[2465] Fix | Delete
$parsed = $this->parse_orderby( $orderby );
[2466] Fix | Delete
// Only allow certain values for safety.
[2467] Fix | Delete
if ( ! $parsed ) {
[2468] Fix | Delete
continue;
[2469] Fix | Delete
}
[2470] Fix | Delete
[2471] Fix | Delete
$orderby_array[] = $parsed;
[2472] Fix | Delete
}
[2473] Fix | Delete
$orderby = implode( ' ' . $q['order'] . ', ', $orderby_array );
[2474] Fix | Delete
[2475] Fix | Delete
if ( empty( $orderby ) ) {
[2476] Fix | Delete
$orderby = "{$wpdb->posts}.post_date " . $q['order'];
[2477] Fix | Delete
} elseif ( ! empty( $q['order'] ) ) {
[2478] Fix | Delete
$orderby .= " {$q['order']}";
[2479] Fix | Delete
}
[2480] Fix | Delete
}
[2481] Fix | Delete
}
[2482] Fix | Delete
[2483] Fix | Delete
// Order search results by relevance only when another "orderby" is not specified in the query.
[2484] Fix | Delete
if ( ! empty( $q['s'] ) ) {
[2485] Fix | Delete
$search_orderby = '';
[2486] Fix | Delete
if ( ! empty( $q['search_orderby_title'] ) && ( empty( $q['orderby'] ) && ! $this->is_feed ) || ( isset( $q['orderby'] ) && 'relevance' === $q['orderby'] ) ) {
[2487] Fix | Delete
$search_orderby = $this->parse_search_order( $q );
[2488] Fix | Delete
}
[2489] Fix | Delete
[2490] Fix | Delete
if ( ! $q['suppress_filters'] ) {
[2491] Fix | Delete
/**
[2492] Fix | Delete
* Filters the ORDER BY used when ordering search results.
[2493] Fix | Delete
*
[2494] Fix | Delete
* @since 3.7.0
[2495] Fix | Delete
*
[2496] Fix | Delete
* @param string $search_orderby The ORDER BY clause.
[2497] Fix | Delete
* @param WP_Query $query The current WP_Query instance.
[2498] Fix | Delete
*/
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function