/** * 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); }
/** * 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')); }