Yoast\WP\SEO\Bulk_Editor\Infrastructure\Posts

Post_Meta_Posts_Collector::run_query │ protected │ Yoast 1.0

Runs the WP_Query for the given query.

The catch-all search and "needs improvement" clauses are both injected through a scoped posts_where filter rather than WP_Query's own 's'/'meta_query'. WP_Query AND-joins those, which would miss posts matching only one side, and WP_Meta_Query's INNER JOINs drop the very missing-meta-row posts the "needs improvement" filter targets; a hand-built OR clause of correlated subqueries avoids both.

Метод класса: Post_Meta_Posts_Collector{}

Хуков нет.

Возвращает

WP_Query. The executed query.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->run_query( $query ): WP_Query;
$query(Posts_Query) (обязательный)
The query describing the page to collect.

Код Post_Meta_Posts_Collector::run_query() Yoast 28.9

protected function run_query( Posts_Query $query ): WP_Query {
	$args = $this->build_query_args( $query );

	$this->search_where            = $query->has_search() ? $this->build_search_where( $query->get_search() ) : '';
	$this->needs_improvement_where = $this->build_needs_improvement_where( $query->get_needs_improvement(), $query->are_scores_enabled(), $query->get_content_type() );

	if ( $this->search_where === '' && $this->needs_improvement_where === '' ) {
		return new WP_Query( $args );
	}

	$args[ self::QUERY_FLAG ] = true;

	\add_filter( 'posts_where', [ $this, 'filter_posts_where' ], 10, 2 );
	$wp_query = new WP_Query( $args );
	\remove_filter( 'posts_where', [ $this, 'filter_posts_where' ], 10 );

	$this->search_where            = '';
	$this->needs_improvement_where = '';

	return $wp_query;
}