JPKCOM_SIMPLELANG_BASENAME
public
mixed
JPKCOM_SIMPLELANG_BASENAME
= \plugin_basename(__FILE__)
public
mixed
JPKCOM_SIMPLELANG_BASENAME
= \plugin_basename(__FILE__)
public
mixed
JPKCOM_SIMPLELANG_PLUGIN_PATH
= \plugin_dir_path(__FILE__)
public
mixed
JPKCOM_SIMPLELANG_PLUGIN_URL
= \plugin_dir_url(__FILE__)
public
mixed
JPKCOM_SIMPLELANG_VERSION
= '1.1.1'
Sanitize post types array
jpkcom_simplelang_sanitize_post_types(array<int, string>|null $value) : array<int, string>
Ensures only valid post types are saved in the settings.
The post types array to sanitize.
Sanitized array of valid post types.
Render enabled post types field
jpkcom_simplelang_enabled_post_types_field() : void
Displays checkboxes for all public post types.
Render settings page
jpkcom_simplelang_settings_page() : void
Displays the admin settings page for Simple Lang plugin.
Convert locale to language code
jpkcom_simplelang_get_language_code(string $locale) : string
Converts a locale string (e.g., de_DE) to a language code (e.g., de).
The locale string.
The language code.
Get current frontend language
jpkcom_simplelang_get_current_language() : string|null
Returns the currently active language for the frontend.
The current language locale or null if using site default.
Get site default locale
jpkcom_simplelang_get_site_default_locale() : string
Returns the site's default locale, ignoring any temporary locale switches. This is the locale set in Settings > General.
The site default locale (e.g., 'de_DE', 'en_US').
Get language name from locale
jpkcom_simplelang_get_language_name(string $locale) : string
Converts a locale code to a human-readable language name.
The locale code (e.g., 'de_DE', 'fr_FR').
The language name in native language.
Group posts by language
jpkcom_simplelang_group_posts_by_language(array<string, mixed> $query_args) : array<string, array<int, WP_Post>>
Queries posts and groups them by their assigned language for display in the translation links meta box.
WP_Query arguments.
Posts grouped by locale.
Validate translation links
jpkcom_simplelang_validate_translations(int $post_id, array<string|int, int> $translation_ids) : array<string|int, int>
Ensures that translation links are valid and prevents duplicate languages.
The current post ID.
Array of translation post IDs.
Validated array of translation post IDs.
Get translation posts efficiently
jpkcom_simplelang_get_translation_posts(array<string|int, int> $post_ids) : array<string|int, WP_Post>
Fetches multiple posts in a single query to avoid N+1 query problems.
Array of post IDs to fetch.
Array of post objects.
Sync translation links bidirectionally
jpkcom_simplelang_sync_translations(int $post_id, array<string|int, int> $new_translations) : void
Updates translation links for the current post and ensures all posts in the translation set are linked to each other. Creates a complete translation set where every post links to all others in the set.
The post ID to sync.
Array of translation post IDs.
Render translation links meta box
jpkcom_simplelang_render_translations_meta_box(WP_Post $post) : void
Displays a multi-select dropdown with posts grouped by language.
Current post object.
Generate and output hreflang tags
jpkcom_simplelang_output_hreflang_tags(int $post_id, array<string|int, int> $translation_ids) : void
Creates hreflang link tags for all translations including the current post.
The current post ID.
Array of translation post IDs.
Render language selection meta box
jpkcom_simplelang_render_meta_box(WP_Post $post) : void
Displays a dropdown with all available WordPress languages.
Current post object.
Get post language
jpkcom_simplelang_get_post_language([int|null $post_id = null ]) : string|null
Retrieves the language set for a specific post.
Optional. Post ID. Defaults to current post.
The language locale or null if not set.
Get language options for Oxygen Builder
jpkcom_simplelang_get_oxygen_language_options() : array<string, string>
Returns an array of available languages formatted for Oxygen Builder conditions.
Array of language codes and names.
Oxygen condition callback: Post language is specific value
jpkcom_simplelang_oxygen_post_language_is(string $value, string $operator) : bool
Checks if the post has a specific language set.
The language code to check.
The comparison operator (== or !=).
True if the condition matches.
Oxygen condition callback: Post has custom language
jpkcom_simplelang_oxygen_has_custom_language(string $value, string $operator) : bool
Checks if the post has any custom language set (not using site default).
The value to check ('true' or 'false').
The comparison operator (always ==).
True if the condition matches.
Oxygen condition callback: Post uses default language
jpkcom_simplelang_oxygen_uses_default_language(string $value, string $operator) : bool
Checks if the post is using the site default language (no custom language set).
The value to check ('true' or 'false').
The comparison operator (always ==).
True if the condition matches.
Load plugin text domain for translations
jpkcom_simplelang_textdomain() : void
Loads translation files from the /languages directory.
Locate file with override support
jpkcom_simplelang_locate_file(string $filename) : string|null
Searches for a file in multiple locations with priority:
The filename to locate (without path).
Full path to the file if found, null otherwise.