Esempio n. 1
0
 /**
  * Send a comment a notification when their comment is rejected.
  *
  * This could be due to a deleted post, change in post status, or comments being closed.
  *
  * @param $user_id
  * @param $post_id
  */
 public static function send_rejected_notification($user_id, $post_id)
 {
     $comment_author = get_userdata($user_id);
     $post = get_post($post_id);
     $post_title = $post ? $post->post_title : __('a deleted post', 'Postmatic');
     $template_data = compact('comment_author', 'post', 'post_title');
     /**
      * Filter comment rejected email template data.
      *
      * @param array $template_data {
      *      @type WP_User $comment_author
      *      @type WP_Post $post
      *      @type string $post_title Post title or placeholder if post no longer exists
      * }
      */
     $template_data = apply_filters('prompt/comment_rejected_email/template_data', $template_data);
     $subject = sprintf(__('Unable to publish your reply to "%s"', 'Postmatic'), $post_title);
     $template = new Prompt_Template('comment-rejected-email.php');
     $batch = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => $comment_author->user_email, 'subject' => $subject, 'html_content' => $template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::ADMIN));
     /**
      * Filter comment rejected email.
      *
      * @param Prompt_Email_Batch $batch
      * @param array $template_data see prompt/comment_reject_email/template_data
      */
     $batch = apply_filters('prompt/comment_rejected_batch', $batch, $template_data);
     Prompt_Factory::make_mailer($batch)->send();
 }
Esempio n. 2
0
 /**
  * Send an email to a user who has had an account created for them.
  *
  * @param int|object $user
  * @param string $password
  * @param Prompt_Template $template
  */
 public static function send_new_user_notification($user, $password, $template)
 {
     $user = is_integer($user) ? get_userdata($user) : $user;
     $template_data = compact('user', 'password');
     /**
      * Filter new user email template data.
      *
      * @param array $template_data {
      * @type WP_User $user
      * @type string $password
      * }
      */
     $template_data = apply_filters('prompt/new_user_email/template_data', $template_data);
     $subject = sprintf(__('Welcome to %s', 'Postmatic'), get_option('blogname'));
     $batch = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => $user->user_email, 'from_address' => get_option('admin_email'), 'subject' => $subject, 'html_content' => $template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::ADMIN));
     /**
      * Filter new user email.
      *
      * @param Prompt_Email_Batch $batch
      * @param array $template_data {
      * @type WP_User $user
      * @type string $password
      * }
      */
     $batch = apply_filters('prompt/new_user_batch', $batch, $template_data);
     Prompt_Factory::make_mailer($batch)->send();
 }
 public function form_handler()
 {
     $environment = new Prompt_Environment();
     $user = wp_get_current_user();
     $email = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => Prompt_Core::SUPPORT_EMAIL, 'from_address' => $user->user_email, 'from_name' => $user->display_name, 'subject' => sprintf(__('Diagnostics from %s', 'Postmatic'), html_entity_decode(get_option('blogname'))), 'html_content' => json_encode($environment->to_array()), 'message_type' => Prompt_Enum_Message_Types::ADMIN));
     $sent = Prompt_Factory::make_mailer($email)->send();
     if (is_wp_error($sent)) {
         Prompt_Logging::add_error('diagnostic_submission_error', __('Diagnostics could not be sent, please try a bug report.', 'Postmatic'), $sent);
         return;
     }
     $this->add_notice(__('Diagnostics <strong>sent</strong>.', 'Postmatic'));
 }
Esempio n. 4
0
 /**
  * Report new errors.
  *
  * @since 2.0.0
  */
 public static function submit()
 {
     $user = wp_get_current_user();
     $last_submit_time = self::get_last_submission_time();
     update_option(self::$last_submit_option_name, time(), $autoload = false);
     $message = array('error_log' => self::get_log($last_submit_time, ARRAY_A));
     $environment = new Prompt_Environment();
     $message = array_merge($message, $environment->to_array());
     $email = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => Prompt_Core::SUPPORT_EMAIL, 'from_address' => $user->exists() ? $user->user_email : get_option('admin_email'), 'from_name' => $user->exists() ? $user->display_name : '', 'subject' => sprintf('Error submission from %s', html_entity_decode(get_option('blogname'))), 'text_content' => json_encode($message), 'message_type' => Prompt_Enum_Message_Types::ADMIN));
     $sent = Prompt_Factory::make_mailer($email, Prompt_Enum_Email_Transports::LOCAL)->send();
     if (is_wp_error($sent) and Prompt_Core::$options->get('prompt_key')) {
         $sent = Prompt_Factory::make_mailer($email, Prompt_Enum_Email_Transports::API)->send();
     }
     return $sent;
 }
Esempio n. 5
0
 /**
  * @since 2.0.0
  */
 protected function forward()
 {
     $text = $this->get_message_text();
     $from_user = get_user_by('id', $this->from_user_id);
     $to_user = get_user_by('id', $this->to_user_id);
     $command = new Prompt_Forward_Command();
     $command->set_keys(array('', '', $this->to_user_id, $this->from_user_id));
     $template_data = array('sender' => $from_user, 'message' => $text);
     $html_template = new Prompt_Template('forward-email.php');
     $batch = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => $to_user->user_email, 'from_name' => $from_user->display_name, 'subject' => $this->message->subject, 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::ADMIN, 'reply_to' => array('trackable-address' => Prompt_Command_Handling::get_command_metadata($command))));
     Prompt_Factory::make_mailer($batch)->send();
 }