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'));
 }
Exemple #2
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;
 }
 public static function record_environment()
 {
     $environment = new Prompt_Environment();
     self::record_event(time(), 'environment', $environment->to_array());
 }