Recent

Language_Handlerclass

Language_Handler

Language handler class.

Namespace: WebberZone\Better_Search\Frontend
Since: 3.3.0
Source: includes/frontend/class-language-handler.php line 22

Methods

__construct()

Constructor.

Since: 3.3.0
Line: 29

public function __construct(  );

load_plugin_textdomain() static

Initialises text domain for l10n.

Since: 3.3.0
Line: 41

static public function load_plugin_textdomain(  ): void;

Returns: void

translate_ids() static

Get the ID of a post in the current language. Works with WPML and PolyLang.

Since: 3.3.0
Line: 53

static public function translate_ids( $results ): \WP_Post[];
Type Name Description
int[] $results Arry of Posts.

Returns: \WP_Post[] — Updated array of WP_Post objects.

object_id_cur_lang() static

Returns the object identifier for the current language (WPML).

Since: 3.3.0
Line: 87

static public function object_id_cur_lang( $post ): \WP_Post|array|null;
Type Name Description
int|string|\WP_Post $post Post object or Post ID.

Returns: \WP_Post|array|null — Post opbject, updated if needed.

is_translatepress_active() static

Whether TranslatePress is active and exposes the API this integration needs.

Since: 4.5.0
Line: 137

static public function is_translatepress_active(  ): bool;

Returns: bool — True if TranslatePress can be used.

get_trp_settings() static

Get the TranslatePress settings array.

Since: 4.5.0
Line: 148

static public function get_trp_settings(  ): array;

Returns: array — TranslatePress settings.

get_trp_current_language() static

Get the TranslatePress language the current front-end request is rendering in.

Since: 4.5.0
Line: 162

static public function get_trp_current_language(  ): string;

Returns: string — Language code, or an empty string when TranslatePress is inactive

get_trp_component() static

Fetch a TranslatePress component instance.

Since: 4.5.0
Line: 184

static public function get_trp_component( string $component ): object|null;
Type Name Description
string $component Component name, e.g. url_converter.

Returns: object|null — Component instance or null when unavailable.

get_trp_ajax_language() static

Resolve the TranslatePress language for an admin-ajax request.

Since: 4.5.0
Line: 230

static public function get_trp_ajax_language(  ): string;

Returns: string — Language code, or an empty string when no translation is needed.

trp_translate_content() static

Translate a string with TranslatePress.

Since: 4.5.0
Line: 282

static public function trp_translate_content( string $content, string $language ): string;
Type Name Description
string $content Content in the default language.
string $language Target language code.

Returns: string — Translated content.

trp_translate_url() static

Convert a URL to its TranslatePress equivalent in the given language.

Since: 4.5.0
Line: 299

static public function trp_translate_url( string $url, string $language ): string;
Type Name Description
string $url URL in the default language.
string $language Target language code.

Returns: string — Converted URL.

get_cache_language() static

Get a language identifier for cache keys.

Rendered output is language-specific — TranslatePress filters home_url(), and WPML/Polylang resolve different post IDs — so cached HTML and post lists must not be shared between languages.

Since: 4.5.0
Line: 325

static public function get_cache_language(  ): string;

Returns: string — Current language code, or an empty string when the site is monolingual.