Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/class-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function setup() {
if ( $this->is_active() ) {
add_action( 'ajax_query_attachments_args', [ $this, 'query_attachments' ] );
add_filter( 'pre_get_posts', [ $this, 'main_search' ] );
add_filter( 'wp_link_query_args', [ $this, 'wp_link_query_args' ], 20 );
}
}

Expand Down Expand Up @@ -110,4 +111,20 @@ protected function attachments_post_status( $status ) {

return $status;
}

/**
* Filter the query args used by the tinymce plugin `wplink` to search for
* posts. This will offload the query to Elasticsearch if it is a keyword
* search.
*
* @param array $args WP_Query args.
* @return array
*/
public function wp_link_query_args( $args ) {
if ( ! empty( $args['s'] ) && ! array_key_exists( $args, 'es' ) ) {
$args['es'] = true;
}

return $args;
}
}