add_filter( 'wpml_cross_domain_language_data', callable $function_to_add);
- סוג
- filter
- קטגוריה
- שונות
- גרסת WPML
- 3.2.7
תיאור
- העבר את המידע הדרוש בין הדומיינים של השפות. תוכל למצוא פרטים נוספים במסמך שלנו העברת נתוני סשן בין שפות בדומיינים.
- זה ספציפי להצגת פורמט כתובת URL של שפה בתור דומיין שונה לכל שפה.
- כדי לקבל את הנתונים בחזרה, השתמש בפילטר wpml_get_cross_domain_language_data.
ארגומנטים
- $function_to_add
- (callable) (נדרש) ה־callback שלך שיופעל כאשר הפילטר מוחל.
דוגמה לשימוש
אנו משתמשים ב־wpml_cross_domain_language_data כדי להעביר את נתוני ה־cookie. בדומיינים אחרים, אנו משתמשים ב־wpml_get_cross_domain_language_data כדי לטפל בנתונים ולשמור את ה־cookie.
דוגמה
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 );
}
}
הוקים קשורים
icl_ls_languages, wpml_sync_custom_field_copied_value, wpml_ls_enable_ajax_navigation, wpml_element_type, wpml_setting, wpml_sub_setting, wpml_exclude_post_from_auto_translate, wpml_forms_config_ninja-forms, wpml_forms_config_wpforms, wpml_tf_feedback_open_link