: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$this->is_trackback = true;
if ( '' != $qv['paged'] && ( (int) $qv['paged'] > 1 ) ) {
// If we're previewing inside the write screen.
if ( '' != $qv['preview'] ) {
$this->is_preview = true;
if ( str_contains( $qv['feed'], 'comments-' ) ) {
$qv['feed'] = str_replace( 'comments-', '', $qv['feed'] );
$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
if ( $this->is_feed && ( ! empty( $qv['withcomments'] ) || ( empty( $qv['withoutcomments'] ) && $this->is_singular ) ) ) {
$this->is_comment_feed = true;
if ( ! ( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed
|| ( wp_is_serving_rest_request() && $this->is_main_query() )
|| $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots || $this->is_favicon ) ) {
// Correct `is_*` for 'page_on_front' and 'page_for_posts'.
if ( $this->is_home && 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) {
$_query = wp_parse_args( $this->query );
// 'pagename' can be set and empty depending on matched rewrite rules. Ignore an empty 'pagename'.
if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) {
unset( $_query['pagename'] );
unset( $_query['embed'] );
if ( empty( $_query ) || ! array_diff( array_keys( $_query ), array( 'preview', 'page', 'paged', 'cpage' ) ) ) {
$qv['page_id'] = get_option( 'page_on_front' );
// Correct <!--nextpage--> for 'page_on_front'.
if ( ! empty( $qv['paged'] ) ) {
$qv['page'] = $qv['paged'];
if ( '' !== $qv['pagename'] ) {
$this->queried_object = get_page_by_path( $qv['pagename'] );
if ( $this->queried_object && 'attachment' === $this->queried_object->post_type ) {
if ( preg_match( '/^[^%]*%(?:postname)%/', get_option( 'permalink_structure' ) ) ) {
// See if we also have a post with the same slug.
$post = get_page_by_path( $qv['pagename'], OBJECT, 'post' );
$this->queried_object = $post;
if ( ! empty( $this->queried_object ) ) {
$this->queried_object_id = (int) $this->queried_object->ID;
unset( $this->queried_object );
if ( 'page' === get_option( 'show_on_front' ) && isset( $this->queried_object_id ) && get_option( 'page_for_posts' ) == $this->queried_object_id ) {
$this->is_posts_page = true;
if ( isset( $this->queried_object_id ) && get_option( 'wp_page_for_privacy_policy' ) == $this->queried_object_id ) {
$this->is_privacy_policy = true;
if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == $qv['page_id'] ) {
$this->is_posts_page = true;
if ( get_option( 'wp_page_for_privacy_policy' ) == $qv['page_id'] ) {
$this->is_privacy_policy = true;
if ( ! empty( $qv['post_type'] ) ) {
if ( is_array( $qv['post_type'] ) ) {
$qv['post_type'] = array_map( 'sanitize_key', $qv['post_type'] );
$qv['post_type'] = sanitize_key( $qv['post_type'] );
if ( ! empty( $qv['post_status'] ) ) {
if ( is_array( $qv['post_status'] ) ) {
$qv['post_status'] = array_map( 'sanitize_key', $qv['post_status'] );
$qv['post_status'] = preg_replace( '|[^a-z0-9_,-]|', '', $qv['post_status'] );
if ( $this->is_posts_page && ( ! isset( $qv['withcomments'] ) || ! $qv['withcomments'] ) ) {
$this->is_comment_feed = false;
$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
// Done correcting `is_*` for 'page_on_front' and 'page_for_posts'.
if ( '404' == $qv['error'] ) {
$this->is_embed = $this->is_embed && ( $this->is_singular || $this->is_404 );
$this->query_vars_hash = md5( serialize( $this->query_vars ) );
$this->query_vars_changed = false;
* Fires after the main query vars have been parsed.
* @param WP_Query $query The WP_Query instance (passed by reference).
do_action_ref_array( 'parse_query', array( &$this ) );
* Parses various taxonomy related query vars.
* For BC, this method is not marked as protected. See [28987].
* @param array $q The query variables. Passed by reference.
public function parse_tax_query( &$q ) {
if ( ! empty( $q['tax_query'] ) && is_array( $q['tax_query'] ) ) {
$tax_query = $q['tax_query'];
if ( ! empty( $q['taxonomy'] ) && ! empty( $q['term'] ) ) {
'taxonomy' => $q['taxonomy'],
'terms' => array( $q['term'] ),
foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy => $t ) {
if ( 'post_tag' === $taxonomy ) {
continue; // Handled further down in the $q['tag'] block.
if ( $t->query_var && ! empty( $q[ $t->query_var ] ) ) {
$tax_query_defaults = array(
if ( ! empty( $t->rewrite['hierarchical'] ) ) {
$q[ $t->query_var ] = wp_basename( $q[ $t->query_var ] );
$term = $q[ $t->query_var ];
if ( is_array( $term ) ) {
$term = implode( ',', $term );
if ( str_contains( $term, '+' ) ) {
$terms = preg_split( '/[+]+/', $term );
foreach ( $terms as $term ) {
$tax_query[] = array_merge(
'terms' => array( $term ),
$tax_query[] = array_merge(
'terms' => preg_split( '/[,]+/', $term ),
// If query string 'cat' is an array, implode it.
if ( is_array( $q['cat'] ) ) {
$q['cat'] = implode( ',', $q['cat'] );
if ( ! empty( $q['cat'] ) && ! $this->is_singular ) {
$cat_array = preg_split( '/[,\s]+/', urldecode( $q['cat'] ) );
$cat_array = array_map( 'intval', $cat_array );
$q['cat'] = implode( ',', $cat_array );
foreach ( $cat_array as $cat ) {
$cat_not_in[] = abs( $cat );
if ( ! empty( $cat_in ) ) {
'taxonomy' => 'category',
'include_children' => true,
if ( ! empty( $cat_not_in ) ) {
'taxonomy' => 'category',
'include_children' => true,
unset( $cat_array, $cat_in, $cat_not_in );
if ( ! empty( $q['category__and'] ) && 1 === count( (array) $q['category__and'] ) ) {
$q['category__and'] = (array) $q['category__and'];
if ( ! isset( $q['category__in'] ) ) {
$q['category__in'] = array();
$q['category__in'][] = absint( reset( $q['category__and'] ) );
unset( $q['category__and'] );
if ( ! empty( $q['category__in'] ) ) {
$q['category__in'] = array_map( 'absint', array_unique( (array) $q['category__in'] ) );
'taxonomy' => 'category',
'terms' => $q['category__in'],
'include_children' => false,
if ( ! empty( $q['category__not_in'] ) ) {
$q['category__not_in'] = array_map( 'absint', array_unique( (array) $q['category__not_in'] ) );
'taxonomy' => 'category',
'terms' => $q['category__not_in'],
'include_children' => false,
if ( ! empty( $q['category__and'] ) ) {
$q['category__and'] = array_map( 'absint', array_unique( (array) $q['category__and'] ) );
'taxonomy' => 'category',
'terms' => $q['category__and'],
'include_children' => false,
// If query string 'tag' is array, implode it.
if ( is_array( $q['tag'] ) ) {
$q['tag'] = implode( ',', $q['tag'] );
if ( '' !== $q['tag'] && ! $this->is_singular && $this->query_vars_changed ) {
if ( str_contains( $q['tag'], ',' ) ) {
$tags = preg_split( '/[,\r\n\t ]+/', $q['tag'] );
foreach ( (array) $tags as $tag ) {
$tag = sanitize_term_field( 'slug', $tag, 0, 'post_tag', 'db' );
$q['tag_slug__in'][] = $tag;
} elseif ( preg_match( '/[+\r\n\t ]+/', $q['tag'] ) || ! empty( $q['cat'] ) ) {
$tags = preg_split( '/[+\r\n\t ]+/', $q['tag'] );
foreach ( (array) $tags as $tag ) {
$tag = sanitize_term_field( 'slug', $tag, 0, 'post_tag', 'db' );
$q['tag_slug__and'][] = $tag;
$q['tag'] = sanitize_term_field( 'slug', $q['tag'], 0, 'post_tag', 'db' );
$q['tag_slug__in'][] = $q['tag'];
if ( ! empty( $q['tag_id'] ) ) {
$q['tag_id'] = absint( $q['tag_id'] );
'taxonomy' => 'post_tag',
if ( ! empty( $q['tag__in'] ) ) {
$q['tag__in'] = array_map( 'absint', array_unique( (array) $q['tag__in'] ) );
'taxonomy' => 'post_tag',
'terms' => $q['tag__in'],
if ( ! empty( $q['tag__not_in'] ) ) {
$q['tag__not_in'] = array_map( 'absint', array_unique( (array) $q['tag__not_in'] ) );
'taxonomy' => 'post_tag',
'terms' => $q['tag__not_in'],
if ( ! empty( $q['tag__and'] ) ) {
$q['tag__and'] = array_map( 'absint', array_unique( (array) $q['tag__and'] ) );
'taxonomy' => 'post_tag',
'terms' => $q['tag__and'],
if ( ! empty( $q['tag_slug__in'] ) ) {
$q['tag_slug__in'] = array_map( 'sanitize_title_for_query', array_unique( (array) $q['tag_slug__in'] ) );
'taxonomy' => 'post_tag',
'terms' => $q['tag_slug__in'],
if ( ! empty( $q['tag_slug__and'] ) ) {
$q['tag_slug__and'] = array_map( 'sanitize_title_for_query', array_unique( (array) $q['tag_slug__and'] ) );
'taxonomy' => 'post_tag',
'terms' => $q['tag_slug__and'],
$this->tax_query = new WP_Tax_Query( $tax_query );
* Fires after taxonomy-related query vars have been parsed.
* @param WP_Query $query The WP_Query instance.
do_action( 'parse_tax_query', $this );
* Generates SQL for the WHERE clause based on passed search terms.
* @global wpdb $wpdb WordPress database abstraction object.
* @param array $q Query variables.
* @return string WHERE clause.
protected function parse_search( &$q ) {
// Added slashes screw with quote grouping when done early, so done later.
$q['s'] = stripslashes( $q['s'] );
if ( empty( $_GET['s'] ) && $this->is_main_query() ) {
$q['s'] = urldecode( $q['s'] );
// There are no line breaks in <input /> fields.
$q['s'] = str_replace( array( "\r", "\n" ), '', $q['s'] );
$q['search_terms_count'] = 1;
if ( ! empty( $q['sentence'] ) ) {
$q['search_terms'] = array( $q['s'] );
if ( preg_match_all( '/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $q['s'], $matches ) ) {
$q['search_terms_count'] = count( $matches[0] );
$q['search_terms'] = $this->parse_search_terms( $matches[0] );
// If the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence.
if ( empty( $q['search_terms'] ) || count( $q['search_terms'] ) > 9 ) {
$q['search_terms'] = array( $q['s'] );
$q['search_terms'] = array( $q['s'] );
$n = ! empty( $q['exact'] ) ? '' : '%';
$q['search_orderby_title'] = array();
$default_search_columns = array( 'post_title', 'post_excerpt', 'post_content' );
$search_columns = ! empty( $q['search_columns'] ) ? $q['search_columns'] : $default_search_columns;
if ( ! is_array( $search_columns ) ) {
$search_columns = array( $search_columns );
* Filters the columns to search in a WP_Query search.
* The supported columns are `post_title`, `post_excerpt` and `post_content`.
* They are all included by default.
* @param string[] $search_columns Array of column names to be searched.
* @param string $search Text being searched.
* @param WP_Query $query The current WP_Query instance.
$search_columns = (array) apply_filters( 'post_search_columns', $search_columns, $q['s'], $this );
// Use only supported search columns.
$search_columns = array_intersect( $search_columns, $default_search_columns );
if ( empty( $search_columns ) ) {
$search_columns = $default_search_columns;
* Filters the prefix that indicates that a search term should be excluded from results.
* @param string $exclusion_prefix The prefix. Default '-'. Returning
* an empty value disables exclusions.
$exclusion_prefix = apply_filters( 'wp_query_search_exclusion_prefix', '-' );
foreach ( $q['search_terms'] as $term ) {
// If there is an $exclusion_prefix, terms prefixed with it should be excluded.
$exclude = $exclusion_prefix && str_starts_with( $term, $exclusion_prefix );
$term = substr( $term, 1 );
if ( $n && ! $exclude ) {
$like = '%' . $wpdb->esc_like( $term ) . '%';
$q['search_orderby_title'][] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $like );
$like = $n . $wpdb->esc_like( $term ) . $n;
$search_columns_parts = array();
foreach ( $search_columns as $search_column ) {
$search_columns_parts[ $search_column ] = $wpdb->prepare( "({$wpdb->posts}.$search_column $like_op %s)", $like );
if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
$search_columns_parts['attachment'] = $wpdb->prepare( "(sq1.meta_value $like_op %s)", $like );
$search .= "$searchand(" . implode( " $andor_op ", $search_columns_parts ) . ')';
if ( ! empty( $search ) ) {
$search = " AND ({$search}) ";
if ( ! is_user_logged_in() ) {
$search .= " AND ({$wpdb->posts}.post_password = '') ";