WPML

ภาพรวมของปัญหา

เมื่อใช้ WP Job Manager ร่วมกับ WPML การลบโพสต์งานหรือโพสต์เรซูเม่จากส่วนหน้า (Job Dashboard) จะไม่ลบคำแปลโดยอัตโนมัติ แม้ว่าจะเปิดใช้งานตัวเลือก “เมื่อลบโพสต์ ให้ลบคำแปลด้วย” ใน “WPML > การตั้งค่า > การซิงโครไนซ์โพสต์และหน้า” ก็ตาม

วิธีแก้ปัญหาชั่วคราว

โปรดตรวจสอบให้แน่ใจว่าคุณได้สำรองข้อมูลไซต์ทั้งหมดของคุณก่อนดำเนินการต่อ

สำหรับโพสต์งาน

  • เปิด /wp-content/plugins/wp-job-manager/includes/class-job-dashboard-shortcode.php
  • ค้นหาบรรทัดที่ 466
  • แทนที่:
    case 'delete':
    	// Trash it.
    	wp_trash_post( $job_id );
  • ด้วย:
    case 'delete':
    	// Trash it.
    	// WPML workaround for compsupp-7729
    	if ( class_exists('Sitepress') ) {
    		$trid = apply_filters( 'wpml_element_trid', NULL, $job_id , 'post_job_listing' );
    		$translations = apply_filters( 'wpml_get_element_translations', NULL, $trid, 'job_listing' );
    		if ( !empty( $translations ) ) {
    			foreach ( $translations as $lang => $translation ) {
    				$translation_id = absint( $translation->element_id );
    				wp_trash_post( $translation_id );
    			}
    		}
    	} else {
    		wp_trash_post( $job_id );
    	}

สำหรับโพสต์เรซูเม่

  • เปิด /wp-content/plugins/wp-job-manager-resumes/includes/class-wp-resume-manager-shortcodes.php
  • ค้นหาบรรทัดที่ 125
  • แทนที่:
    case 'delete':
    	// Trash it.
    	wp_trash_post( $resume_id );
  • ด้วย:
    case 'delete':
    	// Trash it.
    	// WPML workaround for compsupp-7757
    	if ( class_exists('Sitepress') ) {
    		$trid = apply_filters( 'wpml_element_trid', NULL, $resume_id , 'post_resume' );
    		$translations = apply_filters( 'wpml_get_element_translations', NULL, $trid, 'resume' );
    		if ( !empty( $translations ) ) {
    			foreach ( $translations as $lang => $translation ) {
    				$translation_id = absint( $translation->element_id );
    				wp_trash_post( $translation_id );
    			}
    		}
    	} else {
    		wp_trash_post( $resume_id );
    	}

ปัญหาที่ทราบแล้วทั้งหมด