/** * The constructor * * @param unknown $rootPluginFilenameAndPath * - the __FILE__ of the caller */ public function __construct($rootPluginFilenameAndPath, $version) { assert(!empty($rootPluginFilenameAndPath)); assert(!empty($version)); $this->rootPluginFilenameAndPath = $rootPluginFilenameAndPath; // load the dependencies require_once 'PostmanOptions.php'; require_once 'PostmanState.php'; require_once 'PostmanLogger.php'; require_once 'PostmanUtils.php'; require_once 'Postman-Mail/PostmanTransportRegistry.php'; require_once 'Postman-Mail/PostmanDefaultModuleTransport.php'; require_once 'Postman-Mail/PostmanSmtpModuleTransport.php'; require_once 'Postman-Mail/PostmanGmailApiModuleTransport.php'; require_once 'Postman-Mail/PostmanMandrillTransport.php'; require_once 'Postman-Mail/PostmanSendGridTransport.php'; require_once 'PostmanOAuthToken.php'; require_once 'PostmanWpMailBinder.php'; require_once 'PostmanConfigTextHelper.php'; require_once 'Postman-Email-Log/PostmanEmailLogPostType.php'; require_once 'Postman-Mail/PostmanMyMailConnector.php'; // get plugin metadata - alternative to get_plugin_data $this->pluginData = array('name' => __('Postman SMTP', Postman::TEXT_DOMAIN), 'version' => $version); // register the plugin metadata filter (part of the Postman API) add_filter('postman_get_plugin_metadata', array($this, 'getPluginMetaData')); // create an instance of the logger $this->logger = new PostmanLogger(get_class($this)); if ($this->logger->isDebug()) { $this->logger->debug(sprintf('%1$s v%2$s starting', $this->pluginData['name'], $this->pluginData['version'])); } if (isset($_REQUEST['page']) && $this->logger->isTrace()) { $this->logger->trace('Current page: ' . $_REQUEST['page']); } // register the email transports $this->registerTransports($rootPluginFilenameAndPath); // store an instance of the WpMailBinder $this->wpMailBinder = PostmanWpMailBinder::getInstance(); // bind to wp_mail - this has to happen before the "init" action // this design allows other plugins to register a Postman transport and call bind() // bind may be called more than once $this->wpMailBinder->bind(); // registers the custom post type for all callers PostmanEmailLogPostType::automaticallyCreatePostType(); // run the DatastoreUpgrader any time there is a version mismatch if (PostmanState::getInstance()->getVersion() != $this->pluginData['version']) { // manually trigger the activation hook if ($this->logger->isInfo()) { $this->logger->info(sprintf("Upgrading datastore from version %s to %s", PostmanState::getInstance()->getVersion(), $this->pluginData['version'])); } require_once 'PostmanInstaller.php'; $upgrader = new PostmanInstaller(); $upgrader->activatePostman(); } // MyMail integration new PostmanMyMailConnector($rootPluginFilenameAndPath); // register the shortcode handler on the add_shortcode event add_shortcode('postman-version', array($this, 'version_shortcode')); // hook on the plugins_loaded event add_action('plugins_loaded', array($this, 'on_plugins_loaded')); // hook on the wp_loaded event add_action('wp_loaded', array($this, 'on_wp_loaded')); // hook on the acivation event register_activation_hook($rootPluginFilenameAndPath, array($this, 'on_activation')); // hook on the deactivation event register_deactivation_hook($rootPluginFilenameAndPath, array($this, 'on_deactivation')); }
/** * The constructor * * @param unknown $rootPluginFilenameAndPath * - the __FILE__ of the caller */ public function __construct($rootPluginFilenameAndPath, $version) { assert(!empty($rootPluginFilenameAndPath)); assert(!empty($version)); $this->rootPluginFilenameAndPath = $rootPluginFilenameAndPath; // load the dependencies require_once 'PostmanOptions.php'; require_once 'PostmanState.php'; require_once 'PostmanLogger.php'; require_once 'PostmanUtils.php'; require_once 'Postman-Mail/PostmanTransportRegistry.php'; require_once 'Postman-Mail/PostmanSmtpModuleTransport.php'; require_once 'Postman-Mail/PostmanGmailApiModuleTransport.php'; require_once 'PostmanOAuthToken.php'; require_once 'PostmanWpMailBinder.php'; require_once 'PostmanConfigTextHelper.php'; require_once 'Postman-Email-Log/PostmanEmailLogPostType.php'; require_once 'Postman-Mail/PostmanMyMailConnector.php'; // get plugin metadata - alternative to get_plugin_data $this->pluginData = array('name' => __('Postman SMTP', 'postman-smtp'), 'version' => $version); // register the plugin metadata filter (part of the Postman API) add_filter('postman_get_plugin_metadata', array($this, 'getPluginMetaData')); // create an instance of the logger $this->logger = new PostmanLogger(get_class($this)); $this->logger->debug(sprintf('%1$s v%2$s starting', $this->pluginData['name'], $this->pluginData['version'])); if (isset($_REQUEST['page'])) { $this->logger->trace('Current page: ' . $_REQUEST['page']); } // load the text domain $this->loadTextDomain($rootPluginFilenameAndPath); // register the email transports $this->registerTransports(); // store an instance of the WpMailBinder $this->wpMailBinder = PostmanWpMailBinder::getInstance(); // bind to wp_mail - this has to happen before the "init" action // this design allows other plugins to register a Postman transport and call bind() // bind may be called more than once $this->wpMailBinder->bind(); // registers the custom post type for all callers PostmanEmailLogPostType::automaticallyCreatePostType(); // register activation handler on the activation event // must be called in constructor if (PostmanState::getInstance()->getVersion() != $this->pluginData['version']) { require_once 'PostmanDatastoreUpgrader.php'; $this->logger->info(sprintf("Upgrading datastore from version %s to %s", PostmanState::getInstance()->getVersion(), $this->pluginData['version'])); $activate = new PostmanActivationHandler(); $activate->activate_postman(); } // register the shortcode handler on the add_shortcode event add_shortcode('postman-version', array($this, 'version_shortcode')); // load the administration screens if (is_admin()) { // the is_admin check only tells us that we are not on the public pages $this->setup_admin(); } // register the check for configuration errors on the wp_loaded hook, // because we want it to run after the OAuth Grant Code check on the init hook add_action('wp_loaded', array($this, 'check_for_configuration_errors')); // MyMail integration new PostmanMyMailConnector($rootPluginFilenameAndPath); }
/** */ private function displayTopNavigation() { screen_icon(); printf('<h2>%s</h2>', sprintf(__('%s Setup', Postman::TEXT_DOMAIN), __('Postman SMTP', Postman::TEXT_DOMAIN))); print '<div id="postman-main-menu" class="welcome-panel">'; print '<div class="welcome-panel-content">'; print '<div class="welcome-panel-column-container">'; print '<div class="welcome-panel-column">'; printf('<h4>%s</h4>', __('Configuration', Postman::TEXT_DOMAIN)); printf('<a class="button button-primary button-hero" href="%s">%s</a>', $this->getPageUrl(PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG), __('Start the Wizard', Postman::TEXT_DOMAIN)); printf('<p class="">or <a href="%s" class="configure_manually">%s</a></p>', $this->getPageUrl(PostmanConfigurationController::CONFIGURATION_SLUG), __('Show All Settings', Postman::TEXT_DOMAIN)); print '</div>'; print '<div class="welcome-panel-column">'; printf('<h4>%s</h4>', _x('Actions', 'Main Menu', Postman::TEXT_DOMAIN)); print '<ul>'; // Grant permission with Google PostmanTransportRegistry::getInstance()->getSelectedTransport()->printActionMenuItem(); if (PostmanWpMailBinder::getInstance()->isBound()) { printf('<li><a href="%s" class="welcome-icon send_test_email">%s</a></li>', $this->getPageUrl(PostmanSendTestEmailController::EMAIL_TEST_SLUG), __('Send a Test Email', Postman::TEXT_DOMAIN)); } else { printf('<li><div class="welcome-icon send_test_email">%s</div></li>', __('Send a Test Email', Postman::TEXT_DOMAIN)); } // import-export-reset menu item if (!$this->options->isNew() || true) { $purgeLinkPattern = '<li><a href="%1$s" class="welcome-icon oauth-authorize">%2$s</a></li>'; } else { $purgeLinkPattern = '<li>%2$s</li>'; } $importTitle = __('Import', Postman::TEXT_DOMAIN); $exportTile = __('Export', Postman::TEXT_DOMAIN); $resetTitle = __('Reset Plugin', Postman::TEXT_DOMAIN); $importExportReset = sprintf('%s/%s/%s', $importTitle, $exportTile, $resetTitle); printf($purgeLinkPattern, $this->getPageUrl(PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG), sprintf('%s', $importExportReset)); print '</ul>'; print '</div>'; print '<div class="welcome-panel-column welcome-panel-last">'; printf('<h4>%s</h4>', _x('Troubleshooting', 'Main Menu', Postman::TEXT_DOMAIN)); print '<ul>'; printf('<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl(PostmanConnectivityTestController::PORT_TEST_SLUG), __('Connectivity Test', Postman::TEXT_DOMAIN)); printf('<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl(PostmanDiagnosticTestController::DIAGNOSTICS_SLUG), __('Diagnostic Test', Postman::TEXT_DOMAIN)); printf('<li><a href="https://wordpress.org/support/plugin/postman-smtp" class="welcome-icon postman_support">%s</a></li>', __('Online Support', Postman::TEXT_DOMAIN)); print '</ul></div></div></div></div>'; }