jobs_migration = $jobs_migration; $this->jobs_repository = $jobs_repository; } public function add_hooks() { add_action( 'wpml_troubleshooting_after_fix_element_type_collation', array( $this, 'render_troubleshooting_section', ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'wp_ajax_' . self::AJAX_ACTION, array( $this, 'fix_tp_id_ajax' ) ); } public function fix_tp_id_ajax() { if ( isset( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], self::AJAX_ACTION ) ) { $job_ids = isset( $_POST['job_ids'] ) ? array_map( 'intval', explode( ',', filter_var( $_POST['job_ids'], FILTER_SANITIZE_FULL_SPECIAL_CHARS ) ) ) : array(); $jobs = array(); foreach ( $job_ids as $job_id ) { if ( ! $job_id ) { continue; } $params = new WPML_TM_Jobs_Search_Params(); $params->set_scope( WPML_TM_Jobs_Search_Params::SCOPE_REMOTE ); $params->set_job_types( array( WPML_TM_Job_Entity::POST_TYPE, WPML_TM_Job_Entity::PACKAGE_TYPE ) ); $params->set_local_job_id( $job_id ); $jobs[] = current( $this->jobs_repository->get( $params )->getIterator()->getArrayCopy() ); } if ( $jobs ) { $this->jobs_migration->migrate_jobs( $jobs, true ); } wp_send_json_success(); } else { wp_send_json_error(); } } public function enqueue_scripts( $hook ) { if ( WPML_PLUGIN_FOLDER . '/menu/troubleshooting.php' === $hook ) { wp_enqueue_script( 'wpml-fix-tp-id', WPML_TM_URL . '/res/js/fix-tp-id.js', array( 'jquery' ), WPML_TM_VERSION ); } } public function render_troubleshooting_section() { ?>

"/>