batch_report = $batch_report; $this->email_builder = $email_builder; } public function process_emails() { $batch_jobs = $this->batch_report->get_jobs(); $this->email_builder->prepare_assigned_jobs_emails( $batch_jobs ); $this->email_builder->prepare_unassigned_jobs_emails( $batch_jobs ); $this->send_emails(); } private function send_emails() { $headers = array(); $headers[] = 'Content-type: text/html; charset=UTF-8'; foreach ( $this->email_builder->get_emails() as $email ) { $email['attachment'] = isset( $email['attachment'] ) ? $email['attachment'] : array(); $email_sent = wp_mail( $email['email'], $email['subject'], $email['body'], $headers, $email['attachment'] ); if ( $email_sent ) { $this->batch_report->reset_batch_report( $email['translator_id'] ); } } $this->batch_report->reset_batch_report( 0 ); } }