/** * Sends email to post author with reject reason. */ public function run() { $sender = wp_get_current_user()->get('user_email'); $headers = 'From: ' . $sender . '<' . $sender . '>' . "\r\n"; $subject = sprintf(esc_html__('Your post on %s was rejected.', 'reject-notify'), esc_html(get_bloginfo('name'))); add_filter('wp_mail_content_type', function () { return 'text/html'; }, PHP_INT_MAX); $success = wp_mail($this->data['recipient'], $subject, $this->data['reason'], $headers); $format = $success ? esc_html__('Email sent to %s!', 'reject-notify') : esc_html__('Error on sending email to %s', 'reject-notify'); $message = sprintf($format, $this->data['recipient']); $class = $success ? 'updated' : 'error'; $json = array_merge($this->data, compact('message', 'class', 'sender', 'subject')); $success and $this->meta->add($this->data['postid'], $this->authorID); wp_send_json($json); }