/**
  */
 public function outputDiagnosticsContent()
 {
     // test features
     print '<div class="wrap">';
     PostmanViewController::outputChildPageHeader(__('Diagnostic Test', Postman::TEXT_DOMAIN));
     printf('<h4>%s</h4>', __('Are you having issues with Postman?', Postman::TEXT_DOMAIN));
     /* translators: where %1$s and %2$s are the URLs to the Troubleshooting and Support Forums on WordPress.org */
     printf('<p style="margin:0 10px">%s</p>', sprintf(__('Please check the <a href="%1$s">troubleshooting and error messages</a> page and the <a href="%2$s">support forum</a>.', Postman::TEXT_DOMAIN), 'https://wordpress.org/plugins/postman-smtp/other_notes/', 'https://wordpress.org/support/plugin/postman-smtp'));
     printf('<h4>%s</h4>', __('Diagnostic Test', Postman::TEXT_DOMAIN));
     printf('<p style="margin:0 10px">%s</p><br/>', sprintf(__('If you write for help, please include the following:', Postman::TEXT_DOMAIN), 'https://wordpress.org/plugins/postman-smtp/other_notes/', 'https://wordpress.org/support/plugin/postman-smtp'));
     printf('<textarea readonly="readonly" id="diagnostic-text" cols="80" rows="15">%s</textarea>', _x('Checking..', 'The "please wait" message', Postman::TEXT_DOMAIN));
     print '</div>';
 }
 /**
  */
 public function outputPortTestContent()
 {
     print '<div class="wrap">';
     PostmanViewController::outputChildPageHeader(__('Connectivity Test', Postman::TEXT_DOMAIN));
     print '<p>';
     print __('This test determines which well-known ports are available for Postman to use.', Postman::TEXT_DOMAIN);
     print '<form id="port_test_form_id" method="post">';
     printf('<label for="hostname">%s</label>', __('Outgoing Mail Server Hostname', Postman::TEXT_DOMAIN));
     $this->port_test_hostname_callback();
     submit_button(_x('Begin Test', 'Button Label', Postman::TEXT_DOMAIN), 'primary', 'begin-port-test', true);
     print '</form>';
     print '<table id="connectivity_test_table">';
     print sprintf('<tr><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th colspan="5">%s</th></tr>', __('Transport', Postman::TEXT_DOMAIN), _x('Socket', 'A socket is the network term for host and port together', Postman::TEXT_DOMAIN), __('Status', Postman::TEXT_DOMAIN) . '<sup>*</sup>', __('Service Available', Postman::TEXT_DOMAIN), __('Server ID', Postman::TEXT_DOMAIN), __('Authentication', Postman::TEXT_DOMAIN));
     print sprintf('<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>', 'None', 'Login', 'Plain', 'CRAM-MD5', 'OAuth 2.0');
     $sockets = PostmanTransportRegistry::getInstance()->getSocketsForSetupWizardToProbe();
     foreach ($sockets as $socket) {
         if ($socket['smtp']) {
             print sprintf('<tr id="%s"><th class="name">%s</th><td class="socket">%s:%s</td><td class="firewall resettable">-</td><td class="service resettable">-</td><td class="reported_id resettable">-</td><td class="auth_none resettable">-</td><td class="auth_login resettable">-</td><td class="auth_plain resettable">-</td><td class="auth_crammd5 resettable">-</td><td class="auth_xoauth2 resettable">-</td></tr>', $socket['id'], $socket['transport_name'], $socket['host'], $socket['port']);
         } else {
             print sprintf('<tr id="%s"><th class="name">%s</th><td class="socket">%s:%s</td><td class="firewall resettable">-</td><td class="service resettable">-</td><td class="reported_id resettable">-</td><td colspan="5">%s</td></tr>', $socket['id'], $socket['transport_name'], $socket['host'], $socket['port'], __('n/a', Postman::TEXT_DOMAIN));
         }
     }
     print '</table>';
     /* Translators: Where %s is the name of the service providing Internet connectivity test */
     printf('<p class="portquiz" style="display:none; font-size:0.8em">* %s</p>', sprintf(__('According to %s', Postman::TEXT_DOMAIN), '<a target="_new" href="http://ww.downor.me/portquiz.net">portquiz.net</a>'));
     printf('<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url('postman-smtp/style/ajax-loader.gif'));
     print '<section id="conclusion" style="display:none">';
     print sprintf('<h3>%s:</h3>', __('Summary', Postman::TEXT_DOMAIN));
     print '<ol class="conclusion">';
     print '</ol>';
     print '</section>';
     print '<section id="blocked-port-help" style="display:none">';
     print sprintf('<p><b>%s</b></p>', __('A test with <span style="color:red">"No"</span> Service Available indicates one or more of these issues:', Postman::TEXT_DOMAIN));
     print '<ol>';
     printf('<li>%s</li>', __('Your web host has placed a firewall between this site and the Internet', Postman::TEXT_DOMAIN));
     printf('<li>%s</li>', __('The SMTP hostname is wrong or the mail server does not provide service on this port', Postman::TEXT_DOMAIN));
     /* translators: where (1) is the URL and (2) is the system */
     $systemBlockMessage = __('Your <a href="%1$s">%2$s configuration</a> is preventing outbound connections', Postman::TEXT_DOMAIN);
     printf('<li>%s</li>', sprintf($systemBlockMessage, 'http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen', 'PHP'));
     printf('<li>%s</li>', sprintf($systemBlockMessage, 'http://wp-mix.com/disable-external-url-requests/', 'WordPress'));
     print '</ol></p>';
     print sprintf('<p><b>%s</b></p>', __('If the issues above can not be resolved, your last option is to configure Postman to use an email account managed by your web host with an SMTP server managed by your web host.', Postman::TEXT_DOMAIN));
     print '</section>';
     print '</div>';
 }
 /**
  */
 public function outputPurgeDataContent()
 {
     $importTitle = __('Import', Postman::TEXT_DOMAIN);
     $exportTile = __('Export', Postman::TEXT_DOMAIN);
     $resetTitle = __('Reset Plugin', Postman::TEXT_DOMAIN);
     $options = $this->options;
     print '<div class="wrap">';
     PostmanViewController::outputChildPageHeader(sprintf('%s/%s/%s', $importTitle, $exportTile, $resetTitle));
     print '<section id="export_settings">';
     printf('<h3><span>%s<span></h3>', $exportTile);
     printf('<p><span>%s</span></p>', __('Copy this data into another instance of Postman to duplicate the configuration.', Postman::TEXT_DOMAIN));
     $data = '';
     if (!PostmanPreRequisitesCheck::checkZlibEncode()) {
         $extraDeleteButtonAttributes = sprintf('disabled="true"');
         $data = '';
     } else {
         $extraDeleteButtonAttributes = '';
         if (!$options->isNew()) {
             $data = $options->export();
         }
     }
     printf('<textarea cols="80" rows="5" readonly="true" name="settings" %s>%s</textarea>', $extraDeleteButtonAttributes, $data);
     print '</section>';
     print '<section id="import_settings">';
     printf('<h3><span>%s<span></h3>', $importTitle);
     print '<form method="POST" action="' . get_admin_url() . 'admin-post.php">';
     wp_nonce_field(PostmanAdminController::IMPORT_SETTINGS_SLUG);
     printf('<input type="hidden" name="action" value="%s" />', PostmanAdminController::IMPORT_SETTINGS_SLUG);
     print '<p>';
     printf('<span>%s</span>', __('Paste data from another instance of Postman here to duplicate the configuration.', Postman::TEXT_DOMAIN));
     if (PostmanTransportRegistry::getInstance()->getSelectedTransport()->isOAuthUsed(PostmanOptions::getInstance()->getAuthenticationType())) {
         $warning = __('Warning', Postman::TEXT_DOMAIN);
         $errorMessage = __('Using the same OAuth 2.0 Client ID and Client Secret from this site at the same time as another site will cause failures.', Postman::TEXT_DOMAIN);
         printf(' <span><b>%s</b>: %s</span>', $warning, $errorMessage);
     }
     print '</p>';
     printf('<textarea cols="80" rows="5" name="settings" %s></textarea>', $extraDeleteButtonAttributes);
     submit_button(__('Import', Postman::TEXT_DOMAIN), 'primary', 'import', true, $extraDeleteButtonAttributes);
     print '</form>';
     print '</section>';
     print '<section id="delete_settings">';
     printf('<h3><span>%s<span></h3>', $resetTitle);
     print '<form method="POST" action="' . get_admin_url() . 'admin-post.php">';
     wp_nonce_field(PostmanAdminController::PURGE_DATA_SLUG);
     printf('<input type="hidden" name="action" value="%s" />', PostmanAdminController::PURGE_DATA_SLUG);
     printf('<p><span>%s</span></p><p><span>%s</span></p>', __('This will purge all of Postman\'s settings, including account credentials and the email log.', Postman::TEXT_DOMAIN), __('Are you sure?', Postman::TEXT_DOMAIN));
     $extraDeleteButtonAttributes = 'style="background-color:red;color:white"';
     if ($this->options->isNew()) {
         $extraDeleteButtonAttributes .= ' disabled="true"';
     }
     submit_button($resetTitle, 'delete', 'submit', true, $extraDeleteButtonAttributes);
     print '</form>';
     print '</section>';
     print '</div>';
 }
 /**
  */
 public function outputWizardContent()
 {
     // Set default values for input fields
     $this->options->setMessageSenderEmailIfEmpty(wp_get_current_user()->user_email);
     $this->options->setMessageSenderNameIfEmpty(wp_get_current_user()->display_name);
     // construct Wizard
     print '<div class="wrap">';
     PostmanViewController::outputChildPageHeader(__('Setup Wizard', Postman::TEXT_DOMAIN));
     print '<form id="postman_wizard" method="post" action="options.php">';
     // account tab
     // message tab
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, $this->options->isPluginSenderEmailEnforced());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, $this->options->isPluginSenderNameEnforced());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::REPLY_TO, $this->options->getReplyTo());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_TO_RECIPIENTS, $this->options->getForcedToRecipients());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_CC_RECIPIENTS, $this->options->getForcedCcRecipients());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::FORCED_BCC_RECIPIENTS, $this->options->getForcedBccRecipients());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::ADDITIONAL_HEADERS, $this->options->getAdditionalHeaders());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::DISABLE_EMAIL_VALIDAITON, $this->options->isEmailValidationDisabled());
     // logging tab
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::MAIL_LOG_ENABLED_OPTION, $this->options->getMailLoggingEnabled());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::MAIL_LOG_MAX_ENTRIES, $this->options->getMailLoggingMaxEntries());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TRANSCRIPT_SIZE, $this->options->getTranscriptSize());
     // advanced tab
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::CONNECTION_TIMEOUT, $this->options->getConnectionTimeout());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::READ_TIMEOUT, $this->options->getReadTimeout());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::LOG_LEVEL, $this->options->getLogLevel());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::RUN_MODE, $this->options->getRunMode());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled());
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory());
     // display the setting text
     settings_fields(PostmanAdminController::SETTINGS_GROUP_NAME);
     // Wizard Step 0
     printf('<h5>%s</h5>', _x('Import Configuration', 'Wizard Step Title', Postman::TEXT_DOMAIN));
     print '<fieldset>';
     printf('<legend>%s</legend>', _x('Import configuration from another plugin?', 'Wizard Step Title', Postman::TEXT_DOMAIN));
     printf('<p>%s</p>', __('If you had a working configuration with another Plugin, the Setup Wizard can begin with those settings.', Postman::TEXT_DOMAIN));
     print '<table class="input_auth_type">';
     printf('<tr><td><input type="radio" id="import_none" name="input_plugin" value="%s" checked="checked"></input></td><td><label> %s</label></td></tr>', 'none', __('None', Postman::TEXT_DOMAIN));
     if ($this->importableConfiguration->isImportAvailable()) {
         foreach ($this->importableConfiguration->getAvailableOptions() as $options) {
             printf('<tr><td><input type="radio" name="input_plugin" value="%s"/></td><td><label> %s</label></td></tr>', $options->getPluginSlug(), $options->getPluginName());
         }
     }
     print '</table>';
     print '</fieldset>';
     // Wizard Step 1
     printf('<h5>%s</h5>', _x('Sender Details', 'Wizard Step Title', Postman::TEXT_DOMAIN));
     print '<fieldset>';
     printf('<legend>%s</legend>', _x('Who is the mail coming from?', 'Wizard Step Title', Postman::TEXT_DOMAIN));
     printf('<p>%s</p>', __('Enter the email address and name you\'d like to send mail as.', Postman::TEXT_DOMAIN));
     printf('<p>%s</p>', __('Please note that to prevent abuse, many email services will <em>not</em> let you send from an email address other than the one you authenticate with.', Postman::TEXT_DOMAIN));
     printf('<label for="postman_options[sender_email]">%s</label>', __('Email Address', Postman::TEXT_DOMAIN));
     print $this->settingsRegistry->from_email_callback();
     print '<br/>';
     printf('<label for="postman_options[sender_name]">%s</label>', __('Name', Postman::TEXT_DOMAIN));
     print $this->settingsRegistry->sender_name_callback();
     print '</fieldset>';
     // Wizard Step 2
     printf('<h5>%s</h5>', __('Outgoing Mail Server Hostname', Postman::TEXT_DOMAIN));
     print '<fieldset>';
     foreach (PostmanTransportRegistry::getInstance()->getTransports() as $transport) {
         $transport->printWizardMailServerHostnameStep();
     }
     print '</fieldset>';
     // Wizard Step 3
     printf('<h5>%s</h5>', __('Connectivity Test', Postman::TEXT_DOMAIN));
     print '<fieldset>';
     printf('<legend>%s</legend>', __('How will the connection to the mail server be established?', Postman::TEXT_DOMAIN));
     printf('<p>%s</p>', __('Your connection settings depend on what your email service provider offers, and what your WordPress host allows.', Postman::TEXT_DOMAIN));
     printf('<p id="connectivity_test_status">%s: <span id="port_test_status">%s</span></p>', __('Connectivity Test', Postman::TEXT_DOMAIN), _x('Ready', 'TCP Port Test Status', Postman::TEXT_DOMAIN));
     printf('<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url('postman-smtp/style/ajax-loader.gif'));
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TRANSPORT_TYPE);
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PORT);
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::SECURITY_TYPE);
     printf('<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::AUTHENTICATION_TYPE);
     print '<p id="wizard_recommendation"></p>';
     /* Translators: Where %1$s is the socket identifier and %2$s is the authentication type */
     printf('<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_socket_override" class="user_override"></table></p>', _x('Socket', 'A socket is the network term for host and port together', Postman::TEXT_DOMAIN));
     printf('<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_auth_override" class="user_override"></table></p>', __('Authentication', Postman::TEXT_DOMAIN));
     print '<p><span id="smtp_mitm" style="display:none; background-color:yellow"></span></p>';
     $warning = __('Warning', Postman::TEXT_DOMAIN);
     $clearCredentialsWarning = __('This configuration option will send your authorization credentials in the clear.', Postman::TEXT_DOMAIN);
     printf('<p id="smtp_not_secure" style="display:none"><span style="background-color:yellow">%s: %s</span></p>', $warning, $clearCredentialsWarning);
     print '</fieldset>';
     // Wizard Step 4
     printf('<h5>%s</h5>', __('Authentication', Postman::TEXT_DOMAIN));
     print '<fieldset>';
     printf('<legend>%s</legend>', __('How will you prove your identity to the mail server?', Postman::TEXT_DOMAIN));
     foreach (PostmanTransportRegistry::getInstance()->getTransports() as $transport) {
         $transport->printWizardAuthenticationStep();
     }
     print '</fieldset>';
     // Wizard Step 5
     printf('<h5>%s</h5>', _x('Finish', 'The final step of the Wizard', Postman::TEXT_DOMAIN));
     print '<fieldset>';
     printf('<legend>%s</legend>', _x('You\'re Done!', 'Wizard Step Title', Postman::TEXT_DOMAIN));
     print '<section>';
     printf('<p>%s</p>', __('Click Finish to save these settings, then:', Postman::TEXT_DOMAIN));
     print '<ul style="margin-left: 20px">';
     printf('<li class="wizard-auth-oauth2">%s</li>', __('Grant permission with the Email Provider for Postman to send email and', Postman::TEXT_DOMAIN));
     printf('<li>%s</li>', __('Send yourself a Test Email to make sure everything is working!', Postman::TEXT_DOMAIN));
     print '</ul>';
     print '</section>';
     print '</fieldset>';
     print '</form>';
     print '</div>';
 }
 /**
  */
 public function outputTestEmailContent()
 {
     print '<div class="wrap">';
     PostmanViewController::outputChildPageHeader(__('Send a Test Email', Postman::TEXT_DOMAIN));
     printf('<form id="postman_test_email_wizard" method="post" action="%s">', PostmanUtils::getSettingsPageUrl());
     // Step 1
     printf('<h5>%s</h5>', __('Specify the Recipient', Postman::TEXT_DOMAIN));
     print '<fieldset>';
     printf('<legend>%s</legend>', __('Who is this message going to?', Postman::TEXT_DOMAIN));
     printf('<p>%s', __('This utility allows you to send an email message for testing.', Postman::TEXT_DOMAIN));
     print ' ';
     /* translators: where %d is an amount of time, in seconds */
     printf('%s</p>', sprintf(_n('If there is a problem, Postman will give up after %d second.', 'If there is a problem, Postman will give up after %d seconds.', $this->options->getReadTimeout(), Postman::TEXT_DOMAIN), $this->options->getReadTimeout()));
     printf('<label for="postman_test_options[test_email]">%s</label>', _x('Recipient Email Address', 'Configuration Input Field', Postman::TEXT_DOMAIN));
     print $this->test_email_callback();
     print '</fieldset>';
     // Step 2
     printf('<h5>%s</h5>', __('Send The Message', Postman::TEXT_DOMAIN));
     print '<fieldset>';
     print '<legend>';
     print __('Sending the message:', Postman::TEXT_DOMAIN);
     printf(' <span id="postman_test_message_status">%s</span>', _x('In Outbox', 'Email Test Status', Postman::TEXT_DOMAIN));
     print '</legend>';
     print '<section>';
     printf('<p><label>%s</label></p>', __('Status', Postman::TEXT_DOMAIN));
     print '<textarea id="postman_test_message_error_message" readonly="readonly" cols="65" rows="4"></textarea>';
     print '</section>';
     print '</fieldset>';
     // Step 3
     printf('<h5>%s</h5>', __('Session Transcript', Postman::TEXT_DOMAIN));
     print '<fieldset>';
     printf('<legend>%s</legend>', __('Examine the Session Transcript if you need to.', Postman::TEXT_DOMAIN));
     printf('<p>%s</p>', __('This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.', Postman::TEXT_DOMAIN));
     print '<section>';
     printf('<p><label for="postman_test_message_transcript">%s</label></p>', __('Session Transcript', Postman::TEXT_DOMAIN));
     print '<textarea readonly="readonly" id="postman_test_message_transcript" cols="65" rows="8"></textarea>';
     print '</section>';
     print '</fieldset>';
     print '</form>';
     print '</div>';
 }