From dad9828e8c866e50d6e44aebd103f1ab97409a5b Mon Sep 17 00:00:00 2001 From: Yehuda Hassine Date: Fri, 19 Apr 2019 01:22:45 +0300 Subject: add message id + twitter widget --- Postman/PostmanViewController.php | 98 +++++++++++++++++++++------------------ Postman/PostmanWpMail.php | 32 +++++++++++++ style/postman.css | 17 +++++++ 3 files changed, 101 insertions(+), 46 deletions(-) diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php index e170987..0aa4370 100644 --- a/Postman/PostmanViewController.php +++ b/Postman/PostmanViewController.php @@ -48,7 +48,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { check_ajax_referer( 'postsmtp', 'security' ); $version = sanitize_text_field($_POST['version']); - $result = update_option('postman_release_version_'. $version, true ); + $result = update_option('postman_release_version', true ); } function delete_lock_file() { @@ -302,7 +302,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { */ private function displayTopNavigation() { $version = PostmanState::getInstance()->getVersion(); - $show = get_option('postman_release_version_'. $version ); + $show = get_option('postman_release_version' ); printf( '

%s

', sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ) ); if ( ! $show ) { @@ -316,50 +316,56 @@ if ( ! class_exists( 'PostmanViewController' ) ) { '; } - - print '
'; - print '
'; - print '
'; - print '
'; - printf( '

%s

', __( 'Configuration', 'post-smtp' ) ); - printf( '%s', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ), __( 'Start the Wizard', 'post-smtp' ) ); - printf( '

%s %s

', __( 'or', 'post-smtp' ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ), __( 'Show All Settings', 'post-smtp' ) ); - print '
'; - print '
'; - printf( '

%s

', _x( 'Actions', 'Main Menu', 'post-smtp' ) ); - print '
    '; - - // Grant permission with Google - PostmanTransportRegistry::getInstance()->getSelectedTransport()->printActionMenuItem(); - - if ( PostmanWpMailBinder::getInstance()->isBound() ) { - printf( '
  • %s
  • ', $this->getPageUrl( PostmanSendTestEmailController::EMAIL_TEST_SLUG ), __( 'Send a Test Email', 'post-smtp' ) ); - } else { - printf( '
  • %s
  • ', __( 'Send a Test Email', 'post-smtp' ) ); - } - - // import-export-reset menu item - if ( ! $this->options->isNew() || true ) { - $purgeLinkPattern = '
  • %2$s
  • '; - } else { - $purgeLinkPattern = '
  • %2$s
  • '; - } - $importTitle = __( 'Import', 'post-smtp' ); - $exportTile = __( 'Export', 'post-smtp' ); - $resetTitle = __( 'Reset Plugin', 'post-smtp' ); - $importExportReset = sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle ); - printf( $purgeLinkPattern, $this->getPageUrl( PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG ), sprintf( '%s', $importExportReset ) ); - print '
'; - print '
'; - print '
'; - printf( '

%s

', _x( 'Troubleshooting', 'Main Menu', 'post-smtp' ) ); - print '
    '; - printf( '
  • %s
  • ', $this->getPageUrl( PostmanConnectivityTestController::PORT_TEST_SLUG ), __( 'Connectivity Test', 'post-smtp' ) ); - printf( '
  • %s
  • ', $this->getPageUrl( PostmanDiagnosticTestController::DIAGNOSTICS_SLUG ), __( 'Diagnostic Test', 'post-smtp' ) ); - printf( '
  • %s
  • ', '#', wp_create_nonce( "postman" ), __( 'Release Lock File Error', 'post-smtp' ) ); - printf( '
  • %s
  • ', __( 'Online Support', 'post-smtp' ) ); - printf( '
  • %s
  • ', __( 'Guides', 'post-smtp' ) ); - print '
'; + echo '
'; + print '
'; + print '
'; + print '
'; + print '
'; + printf( '

%s

', __( 'Configuration', 'post-smtp' ) ); + printf( '%s', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ), __( 'Start the Wizard', 'post-smtp' ) ); + printf( '

%s %s

', __( 'or', 'post-smtp' ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ), __( 'Show All Settings', 'post-smtp' ) ); + print '
'; + print '
'; + printf( '

%s

', _x( 'Actions', 'Main Menu', 'post-smtp' ) ); + print '
    '; + + // Grant permission with Google + PostmanTransportRegistry::getInstance()->getSelectedTransport()->printActionMenuItem(); + + if ( PostmanWpMailBinder::getInstance()->isBound() ) { + printf( '
  • %s
  • ', $this->getPageUrl( PostmanSendTestEmailController::EMAIL_TEST_SLUG ), __( 'Send a Test Email', 'post-smtp' ) ); + } else { + printf( '
  • %s
  • ', __( 'Send a Test Email', 'post-smtp' ) ); + } + + // import-export-reset menu item + if ( ! $this->options->isNew() || true ) { + $purgeLinkPattern = '
  • %2$s
  • '; + } else { + $purgeLinkPattern = '
  • %2$s
  • '; + } + $importTitle = __( 'Import', 'post-smtp' ); + $exportTile = __( 'Export', 'post-smtp' ); + $resetTitle = __( 'Reset Plugin', 'post-smtp' ); + $importExportReset = sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle ); + printf( $purgeLinkPattern, $this->getPageUrl( PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG ), sprintf( '%s', $importExportReset ) ); + print '
'; + print '
'; + print '
'; + printf( '

%s

', _x( 'Troubleshooting', 'Main Menu', 'post-smtp' ) ); + print '
    '; + printf( '
  • %s
  • ', $this->getPageUrl( PostmanConnectivityTestController::PORT_TEST_SLUG ), __( 'Connectivity Test', 'post-smtp' ) ); + printf( '
  • %s
  • ', $this->getPageUrl( PostmanDiagnosticTestController::DIAGNOSTICS_SLUG ), __( 'Diagnostic Test', 'post-smtp' ) ); + printf( '
  • %s
  • ', '#', wp_create_nonce( "postman" ), __( 'Release Lock File Error', 'post-smtp' ) ); + printf( '
  • %s
  • ', __( 'Online Support', 'post-smtp' ) ); + printf( '
  • %s
  • ', __( 'Guides', 'post-smtp' ) ); + print '
'; + ?> + +
+ init(); + // Apply critical headers + $headers = $this->apply_default_headers( (array)$headers ); + // build the message $postmanMessage = $this->processWpMailCall( $to, $subject, $message, $headers, $attachments ); @@ -55,6 +58,35 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { return $this->sendMessage( $postmanMessage, $log ); } + /** + * @param array $headers + * @return array $headers + */ + private function apply_default_headers( $headers ) { + + $headers[] = 'Message-ID: ' . $this->createMessageId(); + + return $headers; + } + + /** + * Creates the Message-ID + * + * @return string + */ + public function createMessageId() { + + $id = md5(uniqid(time())); + + if (isset($_SERVER["SERVER_NAME"])) { + $hostName = $_SERVER["SERVER_NAME"]; + } else { + $hostName = php_uname('n'); + } + + return $id . '@' . $hostName; + } + /** * Builds a PostmanMessage based on the WordPress wp_mail parameters * diff --git a/style/postman.css b/style/postman.css index 3e6358c..2366e10 100644 --- a/style/postman.css +++ b/style/postman.css @@ -1,5 +1,22 @@ @CHARSET "UTF-8"; +.twitter-wrap { + display: flex; +} + +.twitter-wrap #postman-main-menu { + flex: 1; + margin: 0; + margin-right: 10px; + overflow: hidden; + max-height: 300px; + border-radius: 5px; +} + +.welcome-panel-content { + width: 100%; +} + #postman-main-menu.welcome-panel { padding: 0px 10px 5px; } -- cgit v1.2.3