- availability:
-
WPML Version: 3.2.7
- description:
-
- Retrieve the data passed by the filter wpml_cross_domain_language_data.You can find more details in our document Passing session data between languages in domains.
- This is specific for displaying the language URL format as A different domain per language.
- type:
- filter
- category:
- Miscellaneous
- parameters:
-
apply_filters( 'wpml_get_cross_domain_language_data', array $array );
- $array
- (array) (Required) This is just an empty array, you should always use this value array().
- hook example usage:
-
We use wpml_cross_domain_language_data to pass the cookie data. In other domains, we use wpml_get_cross_domain_language_data to handle the data and save the cookie.
Example
add_filter( 'wpml_cross_domain_language_data', 'pass_data_to_domain' ); // after plugins loaded // this will be executed on the original domain where we have access to the cookie function pass_data_to_domain( $xdomain_data ) { if ( isset ( $_COOKIE[ 'cookie_name' ] ) ) { $xdomain_data[ 'cookie_name' ] = $_COOKIE[ 'cookie_name' ]; } return $xdomain_data; } add_action( 'init', 'set_xdomain_data_cookie' ); // this handle the xdomain_data and set the cookie function set_xdomain_data_cookie() { $xdomain_data = apply_filters( 'wpml_get_cross_domain_language_data', array() ); if ( isset ( $xdomain_data[ 'cookie_name' ] ) ) { setcookie( 'cookie_name', $xdomain_data[ 'cookie_name' ], time() + 30 * DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); } }