- สถานะ
- แก้ไขแล้วโดยผู้พัฒนา
- แก้ไขใน
- BetterDocs 4.2.3
- ปลั๊กอิน/ธีมที่เกี่ยวข้อง
- BetterDocs
- แท็กหัวข้อ
- Compatibility
ภาพรวมของปัญหา
เมื่อใช้ BetterDocs กับ WPML คุณอาจพบปัญหาต่อไปนี้: การจัดลำดับ Docs ใหม่ ผ่าน UI แบบลากแล้ววางของ BetterDocs ทำให้การกำหนดหมวดหมู่ ไม่ซิงก์กันในภาษารอง ส่งผลให้ Docs อาจถูกกำหนดไปยังหมวดหมู่จากภาษาอื่นอย่างไม่ถูกต้อง และลำดับใหม่อาจไม่แสดงผลในการแปล
วิธีแก้ปัญหาชั่วคราว
โปรดตรวจสอบให้แน่ใจว่าได้ทำการสำรองข้อมูลไซต์ทั้งหมดของคุณก่อนดำเนินการต่อ
- เปิดไฟล์ …wp-content/plugins/betterdocs/includes/Core/PostType.php
- ค้นหาบรรทัดที่ 599
- แทนที่:
if ( update_term_meta( $term_id, '_docs_order', $docs_ordering_data ) ) { wp_send_json_success( __( 'Successfully updated.', 'betterdocs' ) ); } - ด้วย:
if ( update_term_meta( $term_id, '_docs_order', $docs_ordering_data ) ) { // WPML Integration: Sync taxonomies after order change if ( class_exists( 'SitePress' ) && class_exists( 'WPML_Term_Translation_Utils' ) ) { $docs_array = isset( $_POST['docs_ordering_data'] ) && is_array( $_POST['docs_ordering_data'] ) ? array_map( 'intval', $_POST['docs_ordering_data'] ) : explode( ',', $docs_ordering_data ); $this->wpml_sync_posts_taxonomies( $docs_array ); } wp_send_json_success( __( 'Successfully updated.', 'betterdocs' ) ); } - ที่ส่วนท้ายของไฟล์เดียวกัน ก่อน
}สุดท้าย (ประมาณบรรทัดที่ 1130) - เพิ่มฟังก์ชันตัวช่วยนี้:
/** * WPML Integration: Sync post taxonomies across translations * @param array $post_ids Array of post IDs to sync */ private function wpml_sync_posts_taxonomies( $post_ids ) { global $sitepress; if ( ! $sitepress || empty( $post_ids ) ) return; $sync = new WPML_Term_Translation_Utils( $sitepress ); foreach ( $post_ids as $post_id ) { $trid = $sitepress->get_element_trid( $post_id, 'post_docs' ); if ( ! $trid ) continue; $translations = $sitepress->get_element_translations( $trid, 'post_docs' ); $original_id = $post_id; foreach ( $translations as $translation ) { if ( isset( $translation->original ) && $translation->original == 1 ) { $original_id = $translation->element_id; break; } } foreach ( $sitepress->get_active_languages() as $lang => $details ) { $sync->sync_terms( $original_id, $lang ); } } }