option = new WpdiscuzUCMOption(); } function sendMail($users, $userList, $comment_author, $post_title, $comment_data) { $current_user = wp_get_current_user(); if (!empty($comment_author)&& !empty($userList) && $this->option->adminEmail) { $content_type = apply_filters('wp_mail_content_type', 'text/html'); $from_name = apply_filters('wp_mail_from_name', get_option('blogname')); $comment_link = get_comment_link($comment_data->comment_ID); $comment_url = '' . $comment_link . ''; $headers_author[] = "Content-Type: $content_type; charset=UTF-8"; $headers_author[] = 'From: ' .get_option('blogname') . ' <' . get_option('admin_email') . '>'; $message_author = $this->option->authorMailMessage; $subject_author = $this->option->authorMailSubject; foreach ($userList as $value) { $body_author = strtr($message_author, array( '[mentionedUserName]' => $value["display_name"], '[postTitle]' => $post_title, '[commentURL]' => $comment_url, '[authorUserName]' => $current_user->display_name )); if ($value["email"] && $this->option->adminEmail) { wp_mail($value["email"], $subject_author, $body_author, $headers_author); } } } if ($users && $comment_author) { $comment_link = get_comment_link($comment_data->comment_ID); $headers_users = array(); $headers_author = array(); $content_type = apply_filters('wp_mail_content_type', 'text/html'); $from_name = apply_filters('wp_mail_from_name', get_option('blogname')); $headers_users[] = "Content-Type: $content_type; charset=UTF-8"; $headers_users[] = 'From: ' . get_option('blogname') . ' <' . get_option('admin_email') . '>'; $message_user = $this->option->userMailMessage; $subject_user = $this->option->userMailSubject; $comment_url = '' . $comment_link . ''; foreach ($users as $user) { if ($user['email'] && $this->option->userEmail) { $body_user = strtr($message_user, array( '[mentionedUserName]' => $user['display_name'], '[postTitle]' => $post_title, '[commentURL]' => $comment_url, '[authorUserName]' => $current_user->display_name )); wp_mail($user['email'], $subject_user, $body_user, $headers_users); } } } } }