HEX
Server: Apache
System: Linux sxb1plmcpnl510113.prod.sxb1.secureserver.net 4.18.0-553.58.1.lve.el8.x86_64 #1 SMP Fri Jul 4 12:07:06 UTC 2025 x86_64
User: acnbijigo78q (10488831)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/acnbijigo78q/www/wp-content/plugins/wpml-elasticpress/src/FeatureSupport/Search.php
<?php

namespace WPML\ElasticPress\FeatureSupport;

use ElasticPress\Features;

use WPML\ElasticPress\Constants;
use WPML\ElasticPress\FeatureSupport;

class Search extends FeatureSupport {

	const FEATURE_SLUG = 'search';

	public function addHooks() {
		if ( ! $this->isFeatureActive() ) {
			return;
		}

		add_filter( 'ep_wp_query_cached_posts', [ $this, 'useIndexByLanguage' ], Constants::LATE_HOOK_PRIORITY );
		add_action( 'ep_wp_query_search', [ $this, 'restoreIndexLanguage' ], Constants::LATE_HOOK_PRIORITY );
	}

	/**
	 * @param array  $newPosts Array of posts
	 *
	 * @return array
	 */
	public function useIndexByLanguage( $newPosts ) {
		$this->indicesManager->setCurrentIndexLanguage( $this->currentLanguage );
		return $newPosts;
	}

	public function restoreIndexLanguage() {
		$this->indicesManager->clearCurrentIndexLanguage();
	}

}