wpml-language-api

Installation
SKILL.md

WPML: the runtime language API

For plugin/theme code that must behave per language — know the current language, show the correct translation of a post/term, query in a specific language, or build language-aware URLs. WPML exposes this as a set of wpml_* hooks (not global functions), all registered in SitePress::api_hooks() (sitepress.class.php:316-407). The legacy icl_* global functions still exist but are deprecated since 3.2 in favour of these hooks.

Why hooks, not function calls

WPML deliberately exposes its API as filters/actions so your code works whether or not WPML is active: apply_filters('wpml_current_language','') returns your passed default ('') when WPML is absent, instead of a fatal undefined function. Always call through the hook, and treat the WPML-absent return as the graceful fallback.

Current / active / default language

// Current language code (2-letter). Pass '' — it's the ignored default.
$current = apply_filters( 'wpml_current_language', '' );          // e.g. 'hu'

// Or the constant (defined once per request at sitepress.class.php:485-487):
$current = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : '';

// Default (site) language:
$default = apply_filters( 'wpml_default_language', null );        // e.g. 'en'
Installs
1
GitHub Stars
22
First Seen
1 day ago
wpml-language-api — lonsdale201/wp-agent-skills