Ejemplo n.º 1
0
 /**
  * Sends specified email to specified address.
  *
  * @param       $hook string Email to send.
  * @param array $args Arguments to the email.
  * @param       $to   string Receiver address.
  */
 public function send($hook, array $args = array(), $to)
 {
     if ($this->suppress) {
         $this->suppress = false;
         return;
     }
     $templates = $this->getTemplates();
     if (!isset($templates[$hook]) || empty($templates[$hook])) {
         return;
     }
     foreach ($templates[$hook] as $postId) {
         $post = $this->wp->getPost($postId);
         if (!empty($post) && $post->post_status == 'publish') {
             $subject = $this->wp->getPostMeta($postId, 'subject', true);
             $post->post_title = empty($subject) ? $post->post_title : $subject;
             $post = $this->filterPost($post, $args);
             $headers = array('MIME-Version: 1.0', 'Content-Type: text/html; charset=UTF-8', 'From: "' . $this->options->get('general.emails.from') . '" <' . $this->options->get('general.email') . '>');
             $footer = $this->options->get('general.emails.footer');
             $post->post_content = $footer ? $post->post_content . '<br/><br/>' . $footer : $post->post_content;
             $this->wp->wpMail($to, $post->post_title, nl2br($post->post_content), $headers);
         }
     }
 }