logger = new PostmanLogger( get_class( $this ) ); $this->rootPluginFilenameAndPath = $rootPluginFilenameAndPath; $this->options = PostmanOptions::getInstance(); $this->settingsRegistry = new PostmanSettingsRegistry(); PostmanUtils::registerAdminMenu( $this, 'addConfigurationSubmenu' ); PostmanUtils::registerAdminMenu( $this, 'addSetupWizardSubmenu' ); // hook on the init event add_action( 'init', array( $this, 'on_init', ) ); // initialize the scripts, stylesheets and form fields add_action( 'admin_init', array( $this, 'on_admin_init', ) ); } /** * Functions to execute on the init event * * "Typically used by plugins to initialize. The current user is already authenticated by this time." * ref: http://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request */ public function on_init() { // register Ajax handlers new PostmanGetHostnameByEmailAjaxController(); new PostmanManageConfigurationAjaxHandler(); new PostmanImportConfigurationAjaxController( $this->options ); } /** * Fires on the admin_init method */ public function on_admin_init() { $this->registerStylesAndScripts(); $this->settingsRegistry->on_admin_init(); } /** * Register and add settings */ private 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_script( 'postman_manual_config_script', plugins_url( 'Postman/Postman-Configuration/postman_manual_config.js', $this->rootPluginFilenameAndPath ), array( PostmanViewController::JQUERY_SCRIPT, 'jquery-ui-core', 'jquery-ui-tabs', 'jquery_validation', PostmanViewController::POSTMAN_SCRIPT, ), $pluginData ['version'] ); wp_register_script( 'postman_wizard_script', plugins_url( 'Postman/Postman-Configuration/postman_wizard.js', $this->rootPluginFilenameAndPath ), array( PostmanViewController::JQUERY_SCRIPT, 'jquery_validation', 'jquery_steps_script', PostmanViewController::POSTMAN_SCRIPT, 'sprintf', ), $pluginData ['version'] ); } /** */ private function addLocalizeScriptsToPage() { $warning = __( 'Warning', 'post-smtp' ); /* translators: where %s is the name of the SMTP server */ wp_localize_script( 'postman_wizard_script', 'postman_smtp_mitm', sprintf( '%s: %s', $warning, __( 'connected to %1$s instead of %2$s.', 'post-smtp' ) ) ); /* translators: where %d is a port number */ wp_localize_script( 'postman_wizard_script', 'postman_wizard_bad_redirect_url', __( 'You are about to configure OAuth 2.0 with an IP address instead of a domain name. This is not permitted. Either assign a real domain name to your site or add a fake one in your local host file.', 'post-smtp' ) ); // user input wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_sender_email', '#input_' . PostmanOptions::MESSAGE_SENDER_EMAIL ); wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_sender_name', '#input_' . PostmanOptions::MESSAGE_SENDER_NAME ); wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_port_element_name', '#input_' . PostmanOptions::PORT ); wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_hostname_element_name', '#input_' . PostmanOptions::HOSTNAME ); // the enc input wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_enc_for_password_el', '#input_enc_type_password' ); // these are the ids for the