For the complete documentation index, see llms.txt. This page is also available as Markdown.

Helpers Functions

All Weglot functions you can call in WordPress to get informations

Helpers Functions

Weglot plugin is exposing functions that can be called in your code.

To see the source code of all available functions, you can go to the file : weglot-functions.php.

weglot_get_service

weglot_get_service( string $service )

Return a Weglot service.

weglot_get_options

weglot_get_options()

Return all Weglot options.

weglot_get_option

weglot_get_option( string $key )

Return Weglot option by key.

weglot_get_original_language

weglot_get_original_language()

Return the original language code (2-letter internal code, e.g. en).

weglot_get_current_language

Return the current language internal code (2-letter code, e.g. en). This is the code Weglot uses internally, not the one that may appear in your URLs.

weglot_get_current_language_custom

Return the current language external code — the custom language code configured in your Weglot dashboard (falls back to the standard code when none is set). Use this when you need the code as it appears to your visitors.

weglot_get_current_language_code_from_custom_language() is an alias that returns the exact same value.

weglot_get_destination_languages

Return an array of public destination language keys.

weglot_get_request_url_service

Return weglot request URL service.

weglot_get_languages_available

Return an array of all languages objects available.

weglot_get_button_selector_html

Return the language's selector button HTML in string format.

weglot_get_exclude_urls

Return an array of all excluded URLs.

weglot_get_translate_amp_translation

Return true if amp pages translation is activated.

weglot_get_current_full_url

Return a string of current URL.

weglot_create_url_object

Return a Weglot\Util\Url object for the given URL. Call ->getForLanguage( $language ) on it to get the URL translated into a specific language.

weglot_is_eligible_url

Return true if $url is an eligible URL.

weglot_get_api_key

Return a string of private API key.

weglot_has_auto_redirect

Return true if redirect users based on their browser language option is activated.

weglot_get_full_url_no_language

Return a string of current URL without the language key.

weglot_get_postid_from_url

Return the WordPress post ID matching the current URL, or 0 if none is found.

weglot_get_rest_current_url_path

Return a string of rest current URL path.

Last updated