Filter
wpml_object_id
On this page
Calls WPML's filter to get the translated ID of a page.
RestroPress applies this WPML filter to map its configured pages (menu, checkout and success pages) to their translation in the current language. This is used when building translated page URLs, deciding whether the current request is a RestroPress page, the checkout or the success page, and when disabling canonical redirects on the checkout and success pages. WPML returns the translated ID.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$element_id | int | The ID of the page to translate. |
$element_type | string | The element type; always 'page' in RestroPress. |
$return_original_if_missing | bool | Whether to return the original ID when there is no translation. |
$language_code | string | The target language code. |
Return value#
int|null. The translated page ID; null when no translation exists and the original is not requested.
Example#
add_filter( 'wpml_object_id', 'my_map_page_translation', 10, 4 );
function my_map_page_translation( $element_id, $element_type, $return_original_if_missing, $language_code ) {
if ( 'page' === $element_type && 'fr' === $language_code && 123 === (int) $element_id ) {
return 456;
}
return $element_id;
}
Notes#
The third argument is true when building translated page URLs and when checking the success page, and false for the page-matching, checkout and redirect checks. A null result is then ignored.
Source#
Applied in:
includes/plugin-compatibility.php(line 266), inrpress_wpml_translate_page_url()includes/plugin-compatibility.php(line 326), inrpress_wpml_filter_is_a_restropress_page()includes/plugin-compatibility.php(line 370), inrpress_wpml_filter_is_checkout()includes/plugin-compatibility.php(line 406), inrpress_wpml_disable_canonical_redirect()includes/plugin-compatibility.php(line 407), inrpress_wpml_disable_canonical_redirect()includes/plugin-compatibility.php(line 439), inrpress_wpml_filter_is_success_page()
