ate_api = $ate_api; } public function add_hooks() { add_filter( 'wpml_tm_ate_job_data_fallback', array( $this, 'get_data_from_api' ), 10, 2 ); } /** * @param array $data * @param int $wpml_job_id * * @return array */ public function get_data_from_api( array $data, $wpml_job_id ) { $response = $this->ate_api->get_jobs_by_wpml_ids( array( $wpml_job_id ) ); if ( ! $response || is_wp_error( $response ) ) { return $data; } if ( ! isset( $response->{$wpml_job_id}->ate_job_id ) ) { return $data; } return array( JobRecords::FIELD_ATE_JOB_ID => $response->{$wpml_job_id}->ate_job_id ); } }