astra_get_i18n_option( string $option, string $translated, mixed $default = '', string $deprecated = '' )

Returns translated string for strings saved in Astra settings.


Description

This function retrieves a theme option value and checks if it needs translation. If the option’s translation is needed, it looks it up based on the provided context. If the translation is not available, it returns the default value.

Usage examples:

  • Retrieve translated theme option with a context description: $value = astra_get_i18n_option( ‘astra-option-key’, esc_html_x( ‘%astra%’, ‘Context Description’, ‘astra-addon’ ) );

  • Retrieve translated theme option with a different context: $value = astra_get_i18n_option( ‘astra-option-key’, _x( ‘%astra%’, ‘Context Description’, ‘astra-addon’ ) );

Parameters

$option

(string) (Required) Option key.

$translated

(string) (Required) Default translation flag.

$default

(mixed) (Optional) Option default value.

Default value: ''

$deprecated

(string) (Optional) Option default value.

Default value: ''


Return

(string) Return option value.


Source

File: classes/astra-common-functions.php

	function astra_get_i18n_option( $option, $translated, $default = '', $deprecated = '' ) {
		// #%astra%# is for TranslatePress compatibility.
		$is_translated = '%astra%' !== $translated && ! strpos( $translated, '#%astra%#' );
		return $is_translated ? $translated : astra_get_option( $option, $default, $deprecated );
	}

Changelog

Changelog
Version Description
4.8.1 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.