- สถานะ
- แก้ไขแล้ว
- รายงานสำหรับ
- WPML Multilingual CMS 4.6.4
- ปลั๊กอิน/ธีมที่เกี่ยวข้อง
- The Events Calendar
- แท็กหัวข้อ
- Compatibility
ภาพรวมของปัญหา
ในบางสถานการณ์ เกิดความผิดปกติในการจัดการคำแปลลิงก์ปฏิทินในปลั๊กอิน The Events Calendar (TEC) เมื่อใช้งานร่วมกับ WPML แทนที่จะแสดงคำแปลตามที่คาดไว้ ลิงก์วันที่กลับแสดงผลอย่างไม่ถูกต้องเป็น (/?:month|monat|miesic|….) เป็นต้น
หมายเหตุ: ปัญหานี้ควรจะได้รับการแก้ไขแล้ว อย่างไรก็ตาม เราได้รับรายงานปัญหาที่คล้ายกันเมื่อเร็ว ๆ นี้
วิธีแก้ปัญหาชั่วคราว
โปรดตรวจสอบให้แน่ใจว่าได้ทำการสำรองข้อมูลแบบเต็มสำหรับเว็บไซต์ของคุณก่อนดำเนินการต่อ
- ไปที่ Users > Your profile และตั้งค่าภาษาเริ่มต้นของคุณเป็นภาษาของผู้ใช้
- ไปที่ การตั้งค่า > ลิงก์ถาวร และบันทึกอีกครั้ง บางครั้งการดำเนินการนี้อาจช่วยแก้ปัญหาได้
- หากยังไม่สามารถแก้ปัญหาได้ ให้เพิ่มโค้ดต่อไปนี้ลงในไฟล์ functions.php ของคุณ:
/* * WPML Workaround for compsupp-6815 */ add_filter( 'tribe_rewrite_canonical_url', 'wpml_compsupp6815_resolve_missing_urls', 10, 3 ); function wpml_compsupp6815_resolve_missing_urls( $resolved, $url, $object ) { if ( class_exists('Sitepress') ) { $wpml_default_lang = apply_filters('wpml_default_language', NULL ); $wpml_current_lang = apply_filters( 'wpml_current_language', NULL ); // Let's register the calendar strings so we can translate and use in the workaround if ($wpml_default_lang == $wpml_current_lang ) { $events_slug = $tec_options['eventsSlug']; $single_events_slug = $tec_options['singleEventSlug']; $tec_options = get_option('tribe_events_calendar_options'); do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($events_slug, 0, 20), $events_slug); do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($single_events_slug, 0, 20), $single_events_slug ); foreach ($tec_options['tribeEnableViews'] as $calendar_string) { do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($calendar_string, 0, 20), $calendar_string); } } // Check if the URL is not resolved yet. If not, we will resolve it with the translated strings if ( preg_match( '#/(/?:.+)#', $resolved ) ) { $resolved = preg_replace_callback( '#/(/?:.+?)#', function($matches) use ($url) { $options = explode('|', trim($matches[0], '/(?:)')); $slug = $options[0]; $translated_slug = apply_filters('wpml_translate_single_string', $slug , 'the-events-calendar', 'TEC Calendar Slugs: '.substr($slug, 0, 20) ); // Only apply the translation if the string already exists in the URL. If not, replace with the original. This may avoid possible 404 errors if (in_array(strtolower($translated_slug), $options) && $translated_slug != '') { $slug = $translated_slug; } return '/' . $slug; }, $resolved ); } } return $resolved; } - ไปที่ การตั้งค่า > ลิงก์ถาวร และบันทึกอีกครั้ง
- หลังจากนั้น ให้ตรวจสอบการทำงานของลิงก์ถาวรที่ส่วนหน้าเว็บไซต์สำหรับทุกภาษา
- หากปัญหายังคงอยู่ คุณอาจยังมีสตริงข้อความบางส่วนที่ยังไม่ได้แปล ในกรณีนี้ ไปที่ WPML > การแปลสตริง และแปลสตริงข้อความที่มี textdomain เป็น
the-events-calendarและชื่อTEC Calendar Slugs: ****