- 상태
- 개발자가 해결함
- 해결된 버전
- BetterDocs 4.2.3
- 관련 플러그인/테마
- BetterDocs
- 주제 태그
- Compatibility
문제 개요
WPML과 함께 BetterDocs를 사용할 때 다음과 같은 문제가 발생할 수 있습니다. BetterDocs 드래그 앤 드롭 UI를 통해 문서를 재정렬하면 카테고리 할당이 보조 언어에서 동기화되지 않습니다. 그 결과, 문서가 다른 언어의 카테고리에 잘못 할당될 수 있으며 새 순서가 번역에 반영되지 않을 수 있습니다.
임시 해결 방법
진행하기 전에 반드시 전체 사이트 백업을 수행하세요.
- …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 ); } } }