Yoast\WP\SEO\Bulk_Editor\Infrastructure\Posts
Indexable_Posts_Collector::apply_search
Adds the catch-all search clause to the query.
The post title lives in the posts table, so it is matched through a subquery while the remaining fields are matched directly on the indexable. All clauses are OR-ed inside a single group so they do not interfere with the other filters.
Метод класса: Indexable_Posts_Collector{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->apply_search( $builder, $search ): void;
- $builder(ORM) (обязательный)
- The query to add the search clause to.
- $search(строка) (обязательный)
- The search term.
Код Indexable_Posts_Collector::apply_search() Indexable Posts Collector::apply search Yoast 28.9
private function apply_search( ORM $builder, string $search ): void {
global $wpdb;
$like = '%' . $wpdb->esc_like( $search ) . '%';
// The post title lives in the posts table, so match it through a subquery; the rest are indexable columns.
$clauses = [ 'object_id IN ( SELECT ID FROM ' . $wpdb->posts . ' WHERE post_title LIKE %s )' ];
foreach ( \array_keys( $this->searchable_fields() ) as $column ) {
$clauses[] = $column . ' LIKE %s';
}
// The ORM binds each %s through $wpdb->prepare; one bound value per clause.
$builder->where_raw(
'( ' . \implode( ' OR ', $clauses ) . ' )',
\array_fill( 0, \count( $clauses ), $like ),
);
}