options = $options; $this->rootPluginFilenameAndPath = $rootPluginFilenameAndPath; $this->authorizationToken = $authorizationToken; $this->oauthScribe = $oauthScribe; $this->adminController = $adminController; $this->logger = new PostmanLogger( get_class( $this ) ); $hostname = PostmanOptions::getInstance()->getHostname(); $transportType = PostmanOptions::getInstance()->getTransportType(); $auth_type = PostmanOptions::getInstance()->getAuthenticationType(); PostmanUtils::registerAdminMenu( $this, 'generateDefaultContent' ); PostmanUtils::registerAdminMenu( $this, 'addPurgeDataSubmenu' ); // initialize the scripts, stylesheets and form fields add_action( 'admin_init', array( $this, 'registerStylesAndScripts' ), 0 ); add_action( 'wp_ajax_delete_lock_file', array( $this, 'delete_lock_file' ) ); add_action( 'wp_ajax_dismiss_version_notify', array( $this, 'dismiss_version_notify' ) ); add_action( 'wp_ajax_dismiss_donation_notify', array( $this, 'dismiss_donation_notify' ) ); add_action( 'wp_ajax_ps-discard-less-secure-notification', array( $this, 'discard_less_secure_notification' ) ); $show_less_secure_notification = get_option( 'ps_hide_less_secure' ); if( !$show_less_secure_notification && $transportType == 'smtp' && $hostname == 'smtp.gmail.com' && ( $auth_type == 'plain' || $auth_type == 'login' ) ) { add_action( 'admin_notices', array( $this, 'google_less_secure_notice' ) ); } //add_action( 'admin_init', array( $this, 'do_activation_redirect' ) ); } function dismiss_version_notify() { check_admin_referer( 'postsmtp', 'security' ); $result = update_option('postman_release_version', true ); } function dismiss_donation_notify() { check_admin_referer( 'postsmtp', 'security' ); $result = update_option('postman_dismiss_donation', true ); } function delete_lock_file() { check_admin_referer( 'postman', 'security' ); if ( ! PostmanUtils::lockFileExists() ) { echo esc_html__('No lock file found.', 'post-smtp' ); die(); } echo PostmanUtils::deleteLockFile() == true ? esc_html__('Success, try to send test email.', 'post-smtp' ) : esc_html__('Failed, try again.', 'post-smtp' ); die(); } function do_activation_redirect() { // Bail if no activation redirect if ( ! get_transient( '_post_activation_redirect' ) ) { return; } // Delete the redirect transient delete_transient( '_post_activation_redirect' ); // Bail if activating from network, or bulk if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { return; } // Bail if the current user cannot see the about page if ( ! current_user_can( 'manage_options' ) ) { return; } // Redirect to bbPress about page wp_safe_redirect( add_query_arg( array( 'page' => 'post-about' ), admin_url( 'index.php' ) ) ); } public static function getPageUrl( $slug ) { return PostmanUtils::getPageUrl( $slug ); } /** * Add options page * * @since 2.1 Added `add_submenu_page` */ public function generateDefaultContent() { // This page will be under "Settings" $pageTitle = sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ); $pluginName = __( 'Post SMTP', 'post-smtp' ); $uniqueId = self::POSTMAN_MENU_SLUG; $pageOptions = array( $this, 'outputDefaultContent', ); $mainPostmanSettingsPage = add_menu_page( $pageTitle, $pluginName, Postman::MANAGE_POSTMAN_CAPABILITY_NAME, $uniqueId, $pageOptions, 'dashicons-email' ); //To change the text of top level menu add_submenu_page( $uniqueId, $pageTitle, 'Dashboard', Postman::MANAGE_POSTMAN_CAPABILITY_NAME, $uniqueId, $pageOptions ); // When the plugin options page is loaded, also load the stylesheet add_action( 'admin_print_styles-' . $mainPostmanSettingsPage, array( $this, 'enqueueHomeScreenStylesheet', ) ); } function enqueueHomeScreenStylesheet() { wp_enqueue_style( PostmanViewController::POSTMAN_STYLE ); wp_enqueue_script( PostmanViewController::POSTMAN_SCRIPT ); } /** * Register the Email Test screen */ public function addPurgeDataSubmenu() { $page = add_submenu_page( '', sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ), __( 'Post SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG, array( $this, 'outputPurgeDataContent', ) ); // When the plugin options page is loaded, also load the stylesheet add_action( 'admin_print_styles-' . $page, array( $this, 'enqueueHomeScreenStylesheet', ) ); } /** * Register and add settings */ public function registerStylesAndScripts() { if ( $this->logger->isTrace() ) { $this->logger->trace( 'registerStylesAndScripts()' ); } // register the stylesheet and javascript external resources $pluginData = apply_filters( 'postman_get_plugin_metadata', null ); wp_register_style( PostmanViewController::POSTMAN_STYLE, plugins_url( 'style/postman.css', $this->rootPluginFilenameAndPath ), null, $pluginData ['version'] ); wp_register_style( 'jquery_ui_style', plugins_url( 'style/jquery-steps/jquery-ui.css', $this->rootPluginFilenameAndPath ), PostmanViewController::POSTMAN_STYLE, '1.1.0' ); wp_register_style( 'jquery_steps_style', plugins_url( 'style/jquery-steps/jquery.steps.css', $this->rootPluginFilenameAndPath ), PostmanViewController::POSTMAN_STYLE, '1.1.0' ); wp_register_script( PostmanViewController::POSTMAN_SCRIPT, plugins_url( 'script/postman.js', $this->rootPluginFilenameAndPath ), array( PostmanViewController::JQUERY_SCRIPT, 'jquery-ui-core', 'jquery-ui-datepicker', ), $pluginData ['version'] ); wp_register_script( 'sprintf', plugins_url( 'script/sprintf/sprintf.min.js', $this->rootPluginFilenameAndPath ), null, '1.0.2' ); wp_register_script( 'jquery_steps_script', plugins_url( 'script/jquery-steps/jquery.steps.min.js', $this->rootPluginFilenameAndPath ), array( PostmanViewController::JQUERY_SCRIPT ), '1.1.0' ); wp_register_script( 'jquery_validation', plugins_url( 'script/jquery-validate/jquery.validate.min.js', $this->rootPluginFilenameAndPath ), array( PostmanViewController::JQUERY_SCRIPT ), '1.13.1' ); wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_ajax_msg', array( 'bad_response' => __( 'An unexpected error occurred', 'post-smtp' ), 'corrupt_response' => __( 'Unexpected PHP messages corrupted the Ajax response', 'post-smtp' ) ) ); wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_ajax', array( 'lessSecureNotice' => wp_create_nonce( 'less-secure-security' ) ) ); } /** * Options page callback */ public function outputDefaultContent() { // Set class property print '
'; print '
'; $version = PostmanState::getInstance()->getVersion(); printf( '

%s

', esc_html__( 'Post SMTP Setup', 'post-smtp' ) ); //Top Notification message if( !PostmanPreRequisitesCheck::isReady() ) { printf( '
%s
', esc_html__( 'Postman is unable to run. Email delivery is being handled by WordPress (or another plugin).', 'post-smtp' ) ); } else { $ready_messsage = PostmanTransportRegistry::getInstance()->getReadyMessage(); $statusMessage = $ready_messsage['message']; $transport = PostmanTransportRegistry::getInstance()->getSelectedTransport(); if ( PostmanTransportRegistry::getInstance()->getActiveTransport()->isConfiguredAndReady() ) { if ( $this->options->getRunMode() != PostmanOptions::RUN_MODE_PRODUCTION ) { printf( '
%s
', wp_kses_post( $statusMessage ) ); } else { printf( '
%s
What\'s Next? Get Started by Sending a Test Email! Send a Test Email
', wp_kses_post( $statusMessage ), esc_url( $this->getPageUrl( PostmanSendTestEmailController::EMAIL_TEST_SLUG ) ) ); } } elseif ( !$transport->has_granted() ) { $notice = $transport->get_not_granted_notice(); printf( '
%s
%s
', esc_html( $notice['message'] ), esc_url( POST_SMTP_ASSETS . 'images/icons/hand.png' ), esc_attr( $notice['url'] ), esc_html( $notice['url_text'] ) ); } else { printf( '
%s
%s %s
', wp_kses_post( $statusMessage ), esc_html__( 'Get Started by Setup Wizard!', 'post-smtp' ), esc_attr( $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ) ), esc_html__( 'Start the Wizard', 'post-smtp' ) ); } } //Main Content ?>

getSelectedTransport()->printActionMenuItem(); $oauth_link = ob_get_clean(); $oauth_link = apply_filters( 'post_smtp_oauth_actions', $oauth_link ); $has_link = preg_match('/<\s?[^\>]*\/?\s?>/i', $oauth_link ); if( $has_link ): ?>
isBound() ) { echo ' '; } else { echo '
'.esc_html__( 'Send a Test Email', 'post-smtp' ) .'
'; } ?>
%2$s '; $importTitle = __( 'Import', 'post-smtp' ); $exportTile = __( 'Export', 'post-smtp' ); $resetTitle = __( 'Reset Plugin', 'post-smtp' ); $importExportReset = sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle ); printf( wp_kses_post( $purgeLinkPattern ), esc_url( $this->getPageUrl( PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG ) ), sprintf( '%s', esc_html( $importExportReset ) ) ); do_action( 'post_smtp_extension_reset_link' ); ?>
printDeliveryDetails(); /* translators: where %d is the number of emails delivered */ print '

'; printf( wp_kses_post( _n( 'Postman has delivered %d email.', 'Postman has delivered %d emails.', esc_attr( PostmanState::getInstance()->getSuccessfulDeliveries() ) , 'post-smtp' ) ), esc_attr( PostmanState::getInstance()->getSuccessfulDeliveries() ) ); if ( $this->options->isMailLoggingEnabled() ) { print ' '; printf( wp_kses_post( __( 'The last %1$d email attempts are recorded in the log.', 'post-smtp' ) ), esc_attr( PostmanOptions::getInstance()->getMailLoggingMaxEntries() ), esc_attr( PostmanUtils::getEmailLogPageUrl() ) ); } print '

'; } if ( $this->options->isNew() ) { printf( '

%s

', esc_html( 'Thank-you for choosing Postman!', 'post-smtp' ) ); /* translators: where %s is the URL of the Setup Wizard */ printf( '

%s

', sprintf( wp_kses_post( 'Let\'s get started! All users are strongly encouraged to run the Setup Wizard.', 'post-smtp' ), esc_url( $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ) ) ) ); printf( '

%s

', sprintf( wp_kses_post( 'Alternately, manually configure your own settings and/or modify advanced options.', 'post-smtp' ), esc_attr( $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ) ) ) ); } else { if ( PostmanState::getInstance()->isTimeToReviewPostman() && ! PostmanOptions::getInstance()->isNew() ) { print '


'; /* translators: where %s is the URL to the WordPress.org review and ratings page */ printf( '

%s %s%s

', esc_html__( 'Please consider', 'post-smtp' ), esc_url( 'https://wordpress.org/support/plugin/post-smtp/reviews/?filter=5' ), esc_html__( 'leaving a review', 'post-smtp' ), esc_html( 'to help spread the word! :D', 'post-smtp' ) ); } printf( esc_html__( '%1$s Postman needs translators! Please take a moment to %2$s translate a few sentences on-line %3$s', 'post-smtp' ), '

', '', ' :-)

' ); } printf( '

%1$s%2$s %4$s

', esc_html__( 'New for v1.9.8!', 'post-smtp' ), esc_html__( ' Fallback - setup a second delivery method when the first one is failing', 'post-smtp' ), esc_url( 'https://postmansmtp.com/post-smtp-1-9-7-the-smtp-fallback/' ), esc_html__( 'Check the detailes here', 'post-smtp') ); print '
'; //Temporary disabled //
//
//

Download Our Featured Plugins For Free

//
//
//
//

Create Fully Responsive Email Templates in Just a Few Minutes With Email Templates

//
    //
  • A free WordPress email template plugin.
  • //
  • Quickest way to design elegant responsive emails.
  • //
  • Features fully compatible with Postnman SMTP.
  • //
// //
// //
//
//
// //
//
print "
"; print "
"; } /** */ private function printDeliveryDetails() { $currentTransport = PostmanTransportRegistry::getInstance()->getActiveTransport(); $deliveryDetails = $currentTransport->getDeliveryDetails( $this->options ); printf( '

%s

', wp_kses_post( $deliveryDetails ) ); } /** * * @param mixed $title * @param string $slug */ public static function outputChildPageHeader( $title, $slug = '' ) { $content = ''; $content .= sprintf( '

%s

', sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ) ); $content .= "

{$title}

"; $content .= sprintf( '', PostmanUtils::getSettingsPageUrl(), _x( 'Back To Main Menu', 'Return to main menu link', 'post-smtp' ) ); $content .= '
'; echo wp_kses_post( $content ); } /** */ public function outputPurgeDataContent() { $importTitle = __( 'Import', 'post-smtp' ); $exportTile = __( 'Export', 'post-smtp' ); $resetTitle = __( 'Reset Plugin', 'post-smtp' ); $options = $this->options; print '
'; PostmanViewController::outputChildPageHeader( sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle ) ); print '
'; printf( '

%s

', esc_html( $exportTile ) ); printf( '

%s

', esc_html__( 'Copy this data into another instance of Postman to duplicate the configuration.', 'post-smtp' ) ); $data = ''; if ( ! PostmanPreRequisitesCheck::checkZlibEncode() ) { $extraDeleteButtonAttributes = sprintf( 'disabled="true"' ); $data = ''; } else { $extraDeleteButtonAttributes = ''; if ( ! $options->isNew() ) { $data = $options->export(); } } printf( '', esc_attr( $extraDeleteButtonAttributes ), esc_textarea( $data ) ); print '
'; print '
'; printf( '

%s

', esc_html( $importTitle ) ); print '
'; wp_nonce_field( PostmanAdminController::IMPORT_SETTINGS_SLUG ); printf( '', esc_attr( PostmanAdminController::IMPORT_SETTINGS_SLUG ) ); print '

'; printf( '%s', esc_html__( 'Paste data from another instance of Postman here to duplicate the configuration.', 'post-smtp' ) ); if ( PostmanTransportRegistry::getInstance()->getSelectedTransport()->isOAuthUsed( PostmanOptions::getInstance()->getAuthenticationType() ) ) { $warning = __( 'Warning', 'post-smtp' ); $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.', 'post-smtp' ); printf( ' %s: %s', esc_html( $warning ), esc_html( $errorMessage ) ); } print '

'; printf( '', esc_textarea( $extraDeleteButtonAttributes ) ); submit_button( __( 'Import', 'post-smtp' ), 'button button-primary', 'import', true, $extraDeleteButtonAttributes ); print '
'; print '
'; print '
'; print '
'; printf( '

%s

', esc_html( $resetTitle ) ); print '
'; wp_nonce_field( PostmanAdminController::PURGE_DATA_SLUG ); printf( '', esc_attr( PostmanAdminController::PURGE_DATA_SLUG ) ); printf( '

%s

%s

', esc_html__( 'This will purge all of Postman\'s settings, including account credentials and the email log.', 'post-smtp' ), esc_html__( 'Are you sure?', 'post-smtp' ) ); printf( ' %s', esc_html__( 'Preserve my email logs', 'post-smtp' ) ); submit_button( $resetTitle, 'delete button button-secondary', 'submit', true ); print '
'; print '
'; print '
'; } public function google_less_secure_notice() { ?>
%1$s %3$s %4$s %6$s %7$s
%9$s
%10$s

', esc_html__( 'To help keep your account secure, Google will no longer support using third-party apps to sign in to your Google Account using only your username and primary password. You can ', 'post-smtp' ), esc_url( 'https://postmansmtp.com/gmail-is-disabling-less-secure-apps-feature-soon/' ), esc_html__( 'switch to the Auth 2.0', 'post-smtp' ), esc_html__( 'alternative or use your ', 'post-smtp' ), esc_url( 'https://postmansmtp.com/documentation/#setting-up-an-app-password-in-your-google-account' ), esc_html__( 'App Password', 'post-smtp' ), esc_html__( 'option to continue. ', 'post-smtp' ), esc_url( 'https://postmansmtp.com/gmail-is-disabling-less-secure-apps' ), esc_html__( 'Click here for more info', 'post-smtp' ), esc_html__( 'I understand and would like to discard this notice', 'post-smtp' ) ); ?>
'Success' ), 200 ); } wp_send_json_error( array( 'message' => 'Something went wrong' ), 500 ); } } }