wpml_enqueued_browser_redirect_language
- ประเภท
- action
- หมวดหมู่
- ข้อมูลภาษาทั่วทั้งไซต์
- เวอร์ชันของ WPML
- 4.1.0
คำอธิบาย
ฮุกนี้จะทำงานในตอนท้ายของตรรกะ PHP สำหรับการเปลี่ยนเส้นทางเบราว์เซอร์ หลังจากฟิลเตอร์ wpml_browser_redirect_language_params และ wpml_enqueue_browser_redirect_language แม้จะมีชื่อเช่นนี้ แต่การดำเนินการนี้จะทำงานแม้ว่า wpml_enqueue_browser_redirect_language จะส่งค่ากลับเป็น true ก็ตาม
อาร์กิวเมนต์
- $enqueued
- bool หากเป็น true สคริปต์จะถูกจัดคิวแล้ว
- $params
- array ข้อมูลที่มีค่า $pageLanguage, $languageUrls และ $cookie
- $pageLanguage string
- ภาษาของหน้าปัจจุบัน
- $languageUrls array
- อาร์เรย์แบบเชื่อมโยงโดยที่คีย์คือรหัสภาษาและค่าคือ URL ที่แปลแล้วของหน้าปัจจุบัน
- cookie
- จัดเก็บอาร์เรย์แบบเชื่อมโยงที่มีการตั้งค่าคุกกี้ โปรดดูรายละเอียดเพิ่มเติมที่ Document.cookie โดยคีย์ประกอบด้วย:
- name: ชื่อของคุกกี้ (ค่าเริ่มต้นคือ
_icl_visitor_lang_js) - domain: โดเมนที่ต้องใช้คุกกี้ (ค่าเริ่มต้นคือโดเมนปัจจุบันและไม่ควรเปลี่ยนแปลง)
- path: เส้นทางของคุกกี้ (ค่าเริ่มต้นคือ
/) - expiration: วันหมดอายุในหน่วยวินาทีซึ่งอ่านจากค่าที่ตั้งไว้ใน Remember visitors’ language preference ที่สามารถพบได้ใน การเปลี่ยนเส้นทางตามภาษาของเบราว์เซอร์ บน WPML -> ภาษา
- name: ชื่อของคุกกี้ (ค่าเริ่มต้นคือ
ตัวอย่างการใช้งาน
function override_browser_redirect( $enqueued, $params ) {
if ( ! $enqueued ) {
// E.g.: A script which uses IP geolocalization
wp_enqueue_script( 'my-custom-script', 'url/to/custom.script.js' );
// Pass the `$params` array to the script, so it can use it to find the best match
wp_localize_script( 'my-custom-script', 'params', $params );
}
}
add_action( 'wpml_enqueued_browser_redirect_language', 'override_browser_redirect', 10, 2 );
ฮุกที่เกี่ยวข้อง
wpml_decode_custom_field, wpml_footer_language_selector, wpml_add_language_form_field, wpml_ls_exclude_in_menu, wpml_is_rtl, wpml_alternate_hreflang, wpml_head_langs, wpml_must_translate_canonical_url, wpml_browser_redirect_language_params, wpml_active_languages