function wptuts_register_pointer_testing($p) { // only do this for administrators if (PostmanUtils::isAdmin()) { $p['postman16_log'] = array('target' => '.configure_manually', 'options' => array('content' => sprintf('<h3> %s </h3> <p> %s </p>', __('New for v1.6! Email Log', 'postman-smtp'), __('Enable to save a copy of all your emails. Great for troubleshooting or as a backup for messages that get lost. <b>Access the Email Log in the Tools menu.</b>', 'postman-smtp')), 'position' => array('edge' => 'top', 'align' => 'left'))); return $p; } }
function wptuts_register_pointer_testing($p) { // only do this for administrators if (PostmanUtils::isAdmin() && false) { $p['postman16_log'] = array('target' => '.configure_manually', 'options' => array('content' => '', 'position' => array('edge' => 'top', 'align' => 'left'))); return $p; } }
/** * Constructor * * @param unknown $rootPluginFilenameAndPath */ public function __construct($rootPluginFilenameAndPath) { assert(!empty($rootPluginFilenameAndPath)); assert(PostmanUtils::isAdmin()); assert(is_admin()); $this->logger = new PostmanLogger(get_class($this)); $this->rootPluginFilenameAndPath = $rootPluginFilenameAndPath; PostmanUtils::registerAdminMenu($this, 'addPortTestSubmenu'); // 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')); }
/** * Constructor * * @param unknown $rootPluginFilenameAndPath */ public function __construct($rootPluginFilenameAndPath) { assert(!empty($rootPluginFilenameAndPath)); assert(PostmanUtils::isAdmin()); assert(is_admin()); $this->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')); }
/** * Register and add settings */ private function registerSettings() { // only administrators should be able to trigger this if (PostmanUtils::isAdmin()) { // $sanitizer = new PostmanInputSanitizer(); register_setting(PostmanAdminController::SETTINGS_GROUP_NAME, PostmanOptions::POSTMAN_OPTIONS, array($sanitizer, 'sanitize')); // Sanitize add_settings_section('transport_section', __('Transport', Postman::TEXT_DOMAIN), array($this, 'printTransportSectionInfo'), 'transport_options'); add_settings_field(PostmanOptions::TRANSPORT_TYPE, _x('Type', '(i.e.) What kind is it?', Postman::TEXT_DOMAIN), array($this, 'transport_type_callback'), 'transport_options', 'transport_section'); // the Message From section add_settings_section(PostmanAdminController::MESSAGE_FROM_SECTION, _x('From Address', 'The Message Sender Email Address', Postman::TEXT_DOMAIN), array($this, 'printMessageFromSectionInfo'), PostmanAdminController::MESSAGE_FROM_OPTIONS); add_settings_field(PostmanOptions::MESSAGE_SENDER_EMAIL, __('Email Address', Postman::TEXT_DOMAIN), array($this, 'from_email_callback'), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION); add_settings_field(PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, '', array($this, 'prevent_from_email_override_callback'), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION); add_settings_field(PostmanOptions::MESSAGE_SENDER_NAME, __('Name', Postman::TEXT_DOMAIN), array($this, 'sender_name_callback'), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION); add_settings_field(PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, '', array($this, 'prevent_from_name_override_callback'), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION); // the Additional Addresses section add_settings_section(PostmanAdminController::MESSAGE_SECTION, __('Additional Email Addresses', Postman::TEXT_DOMAIN), array($this, 'printMessageSectionInfo'), PostmanAdminController::MESSAGE_OPTIONS); add_settings_field(PostmanOptions::REPLY_TO, __('Reply-To', Postman::TEXT_DOMAIN), array($this, 'reply_to_callback'), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION); add_settings_field(PostmanOptions::FORCED_TO_RECIPIENTS, __('To Recipient(s)', Postman::TEXT_DOMAIN), array($this, 'to_callback'), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION); add_settings_field(PostmanOptions::FORCED_CC_RECIPIENTS, __('Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN), array($this, 'cc_callback'), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION); add_settings_field(PostmanOptions::FORCED_BCC_RECIPIENTS, __('Blind Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN), array($this, 'bcc_callback'), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION); // the Additional Headers section add_settings_section(PostmanAdminController::MESSAGE_HEADERS_SECTION, __('Additional Headers', Postman::TEXT_DOMAIN), array($this, 'printAdditionalHeadersSectionInfo'), PostmanAdminController::MESSAGE_HEADERS_OPTIONS); add_settings_field(PostmanOptions::ADDITIONAL_HEADERS, __('Custom Headers', Postman::TEXT_DOMAIN), array($this, 'headers_callback'), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION); // the Email Validation section add_settings_section(PostmanAdminController::EMAIL_VALIDATION_SECTION, __('Validation', Postman::TEXT_DOMAIN), array($this, 'printEmailValidationSectionInfo'), PostmanAdminController::EMAIL_VALIDATION_OPTIONS); add_settings_field(PostmanOptions::ENVELOPE_SENDER, __('Email Address', Postman::TEXT_DOMAIN), array($this, 'disable_email_validation_callback'), PostmanAdminController::EMAIL_VALIDATION_OPTIONS, PostmanAdminController::EMAIL_VALIDATION_SECTION); // the Logging section add_settings_section(PostmanAdminController::LOGGING_SECTION, __('Email Log Settings', Postman::TEXT_DOMAIN), array($this, 'printLoggingSectionInfo'), PostmanAdminController::LOGGING_OPTIONS); add_settings_field('logging_status', __('Enable Logging', Postman::TEXT_DOMAIN), array($this, 'loggingStatusInputField'), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION); add_settings_field('logging_max_entries', __('Maximum Log Entries', 'Configuration Input Field', Postman::TEXT_DOMAIN), array($this, 'loggingMaxEntriesInputField'), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION); add_settings_field(PostmanOptions::TRANSCRIPT_SIZE, __('Maximum Transcript Size', Postman::TEXT_DOMAIN), array($this, 'transcriptSizeInputField'), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION); // the Network section add_settings_section(PostmanAdminController::NETWORK_SECTION, __('Network Settings', Postman::TEXT_DOMAIN), array($this, 'printNetworkSectionInfo'), PostmanAdminController::NETWORK_OPTIONS); add_settings_field('connection_timeout', _x('TCP Connection Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN), array($this, 'connection_timeout_callback'), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION); add_settings_field('read_timeout', _x('TCP Read Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN), array($this, 'read_timeout_callback'), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION); // the Advanced section add_settings_section(PostmanAdminController::ADVANCED_SECTION, _x('Miscellaneous Settings', 'Configuration Section Title', Postman::TEXT_DOMAIN), array($this, 'printAdvancedSectionInfo'), PostmanAdminController::ADVANCED_OPTIONS); add_settings_field(PostmanOptions::LOG_LEVEL, _x('PHP Log Level', 'Configuration Input Field', Postman::TEXT_DOMAIN), array($this, 'log_level_callback'), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION); add_settings_field(PostmanOptions::RUN_MODE, _x('Delivery Mode', 'Configuration Input Field', Postman::TEXT_DOMAIN), array($this, 'runModeCallback'), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION); add_settings_field(PostmanOptions::STEALTH_MODE, _x('Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails', Postman::TEXT_DOMAIN), array($this, 'stealthModeCallback'), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION); add_settings_field(PostmanOptions::TEMPORARY_DIRECTORY, __('Temporary Directory', Postman::TEXT_DOMAIN), array($this, 'temporaryDirectoryCallback'), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION); } }
/** * Check for configuration errors and displays messages to the user */ public function check_for_configuration_errors() { $options = PostmanOptions::getInstance(); $authToken = PostmanOAuthToken::getInstance(); // did Postman fail binding to wp_mail()? if ($this->wpMailBinder->isUnboundDueToException()) { // this message gets printed on ANY WordPress admin page, as it's a pretty fatal error that // may occur just by activating a new plugin if (PostmanUtils::isAdmin() && is_admin()) { // I noticed the wpMandrill and SendGrid plugins have the exact same error message here // I've adopted their error message as well, for shits and giggles .... :D $this->messageHandler->addError(__('Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.', 'postman-smtp')); // $this->messageHandler->addError ( __ ( 'Error: Postman is properly configured, but the current theme or another plugin is preventing service.', 'postman-smtp' ) ); } } else { if (!$this->wpMailBinder->isBound()) { $transport = PostmanTransportRegistry::getInstance()->getCurrentTransport(); $scribe = PostmanConfigTextHelperFactory::createScribe($options->getHostname(), $transport); $readyToSend = PostmanTransportRegistry::getInstance()->isPostmanReadyToSendEmail($options, $authToken); $virgin = $options->isNew(); if (!$readyToSend && !$virgin) { // if the configuration is broken, and the user has started to configure the plugin // show this error message $message = PostmanTransportRegistry::getInstance()->getCurrentTransport()->getMisconfigurationMessage($scribe, $options, $authToken); if ($message) { // output the warning message $this->logger->warn('Transport has a configuration problem: ' . $message); // on pages that are Postman admin pages only, show this error message if (PostmanUtils::isAdmin() && PostmanUtils::isCurrentPagePostmanAdmin()) { $this->messageHandler->addError($message); } } } // on pages that are NOT Postman admin pages only, show this error message if (!PostmanUtils::isCurrentPagePostmanAdmin() && !$readyToSend) { // on pages that are *NOT* Postman admin pages only.... // if the configuration is broken // show this error message add_action('admin_notices', array($this, 'display_configuration_required_warning')); } } } }
/** * From http://www.hughlashbrooke.com/2014/02/wordpress-add-items-glance-widget/ * http://coffeecupweb.com/how-to-add-custom-post-types-to-at-a-glance-dashboard-widget-in-wordpress/ * * @param unknown $items * @return string */ function customizeAtAGlanceDashboardWidget($items = array()) { // only modify the At-a-Glance for administrators if (PostmanUtils::isAdmin()) { $post_types = array(PostmanEmailLogPostType::POSTMAN_CUSTOM_POST_TYPE_SLUG); foreach ($post_types as $type) { if (!post_type_exists($type)) { continue; } $num_posts = wp_count_posts($type); if ($num_posts) { $published = intval($num_posts->publish); $privated = intval($num_posts->private); $post_type = get_post_type_object($type); $text = _n('%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $privated, Postman::TEXT_DOMAIN); $text = sprintf($text, number_format_i18n($privated)); $items[] = sprintf('<a class="%1$s-count" href="%3$s">%2$s</a>', $type, $text, PostmanUtils::getEmailLogPageUrl()) . "\n"; } } return $items; } }
/** * Functions to execute on the admin_init event * * "Runs at the beginning of every admin page before the page is rendered." * ref: http://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_an_Admin_Page_Request */ public function on_admin_init() { // only administrators should be able to trigger this if (PostmanUtils::isAdmin()) { $this->registerStylesAndScripts(); } }
/** * Register and add settings */ public function initializeAdminPage() { // only administrators should be able to trigger this if (PostmanUtils::isAdmin()) { // $sanitizer = new PostmanInputSanitizer($this->options); register_setting(PostmanAdminController::SETTINGS_GROUP_NAME, PostmanOptions::POSTMAN_OPTIONS, array($sanitizer, 'sanitize')); // Sanitize add_settings_section('transport_section', _x('Transport', 'The Transport is the method for sending mail, SMTP or API', 'postman-smtp'), array($this, 'printTransportSectionInfo'), 'transport_options'); add_settings_field(PostmanOptions::TRANSPORT_TYPE, _x('Transport', 'The Transport is the method for sending mail, SMTP or API', 'postman-smtp'), array($this, 'transport_type_callback'), 'transport_options', 'transport_section'); // Sanitize add_settings_section(PostmanAdminController::SMTP_SECTION, _x('Transport Settings', 'Configuration Section Title', 'postman-smtp'), array($this, 'printSmtpSectionInfo'), PostmanAdminController::SMTP_OPTIONS); add_settings_field(PostmanOptions::HOSTNAME, __('Outgoing Mail Server Hostname', 'postman-smtp'), array($this, 'hostname_callback'), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION); add_settings_field(PostmanOptions::PORT, __('Outgoing Mail Server Port', 'postman-smtp'), array($this, 'port_callback'), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION); add_settings_field(PostmanOptions::ENCRYPTION_TYPE, _x('Security', 'Configuration Input Field', 'postman-smtp'), array($this, 'encryption_type_callback'), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION); add_settings_field(PostmanOptions::AUTHENTICATION_TYPE, _x('Authentication', 'Authentication proves the user\'s identity', 'postman-smtp'), array($this, 'authentication_type_callback'), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION); add_settings_section(PostmanAdminController::BASIC_AUTH_SECTION, _x('Authentication', 'Authentication proves the user\'s identity', 'postman-smtp'), array($this, 'printBasicAuthSectionInfo'), PostmanAdminController::BASIC_AUTH_OPTIONS); add_settings_field(PostmanOptions::BASIC_AUTH_USERNAME, _x('Username', 'Configuration Input Field', 'postman-smtp'), array($this, 'basic_auth_username_callback'), PostmanAdminController::BASIC_AUTH_OPTIONS, PostmanAdminController::BASIC_AUTH_SECTION); add_settings_field(PostmanOptions::BASIC_AUTH_PASSWORD, __('Password', 'postman-smtp'), array($this, 'basic_auth_password_callback'), PostmanAdminController::BASIC_AUTH_OPTIONS, PostmanAdminController::BASIC_AUTH_SECTION); // the OAuth section add_settings_section(PostmanAdminController::OAUTH_SECTION, _x('Authentication', 'Authentication proves the user\'s identity', 'postman-smtp'), array($this, 'printOAuthSectionInfo'), PostmanAdminController::OAUTH_OPTIONS); add_settings_field('callback_domain', sprintf('<span id="callback_domain">%s</span>', $this->oauthScribe->getCallbackDomainLabel()), array($this, 'callback_domain_callback'), PostmanAdminController::OAUTH_OPTIONS, PostmanAdminController::OAUTH_SECTION); add_settings_field('redirect_url', sprintf('<span id="redirect_url">%s</span>', $this->oauthScribe->getCallbackUrlLabel()), array($this, 'redirect_url_callback'), PostmanAdminController::OAUTH_OPTIONS, PostmanAdminController::OAUTH_SECTION); add_settings_field(PostmanOptions::CLIENT_ID, _x($this->oauthScribe->getClientIdLabel(), 'Configuration Input Field', 'postman-smtp'), array($this, 'oauth_client_id_callback'), PostmanAdminController::OAUTH_OPTIONS, PostmanAdminController::OAUTH_SECTION); add_settings_field(PostmanOptions::CLIENT_SECRET, _x($this->oauthScribe->getClientSecretLabel(), 'Configuration Input Field', 'postman-smtp'), array($this, 'oauth_client_secret_callback'), PostmanAdminController::OAUTH_OPTIONS, PostmanAdminController::OAUTH_SECTION); // the Message Sender section add_settings_section(PostmanAdminController::MESSAGE_SENDER_SECTION, _x('Envelope From Address', 'The Envelope Sender Email Address', 'postman-smtp'), array($this, 'printMessageSenderSectionInfo'), PostmanAdminController::MESSAGE_SENDER_OPTIONS); add_settings_field(PostmanOptions::ENVELOPE_SENDER, __('Email Address', 'postman-smtp'), array($this, 'sender_email_callback'), PostmanAdminController::MESSAGE_SENDER_OPTIONS, PostmanAdminController::MESSAGE_SENDER_SECTION); // the Message From section add_settings_section(PostmanAdminController::MESSAGE_FROM_SECTION, _x('Message From Address', 'The Message Sender Email Address', 'postman-smtp'), array($this, 'printMessageFromSectionInfo'), PostmanAdminController::MESSAGE_FROM_OPTIONS); add_settings_field(PostmanOptions::MESSAGE_SENDER_EMAIL, __('Email Address', 'postman-smtp'), array($this, 'from_email_callback'), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION); add_settings_field(PostmanOptions::PREVENT_MESSAGE_SENDER_EMAIL_OVERRIDE, '', array($this, 'prevent_from_email_override_callback'), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION); add_settings_field(PostmanOptions::MESSAGE_SENDER_NAME, __('Name', 'postman-smtp'), array($this, 'sender_name_callback'), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION); add_settings_field(PostmanOptions::PREVENT_MESSAGE_SENDER_NAME_OVERRIDE, '', array($this, 'prevent_from_name_override_callback'), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION); // the Additional Addresses section add_settings_section(PostmanAdminController::MESSAGE_SECTION, __('Additional Email Addresses', 'postman-smtp'), array($this, 'printMessageSectionInfo'), PostmanAdminController::MESSAGE_OPTIONS); add_settings_field(PostmanOptions::REPLY_TO, _x('Reply-To', 'The email address to address replies to', 'postman-smtp'), array($this, 'reply_to_callback'), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION); add_settings_field(PostmanOptions::FORCED_TO_RECIPIENTS, __('To Recipient(s)', 'postman-smtp'), array($this, 'to_callback'), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION); add_settings_field(PostmanOptions::FORCED_CC_RECIPIENTS, __('Carbon Copy Recipient(s)', 'postman-smtp'), array($this, 'cc_callback'), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION); add_settings_field(PostmanOptions::FORCED_BCC_RECIPIENTS, __('Blind Carbon Copy Recipient(s)', 'postman-smtp'), array($this, 'bcc_callback'), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION); // the Additional Headers section add_settings_section(PostmanAdminController::MESSAGE_HEADERS_SECTION, __('Additional Headers', 'postman-smtp'), array($this, 'printAdditionalHeadersSectionInfo'), PostmanAdminController::MESSAGE_HEADERS_OPTIONS); add_settings_field(PostmanOptions::ADDITIONAL_HEADERS, __('Custom Headers', 'postman-smtp'), array($this, 'headers_callback'), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION); // the Logging section add_settings_section(PostmanAdminController::LOGGING_SECTION, __('Email Log Settings', 'postman-smtp'), array($this, 'printLoggingSectionInfo'), PostmanAdminController::LOGGING_OPTIONS); add_settings_field('logging_status', __('Enable Logging', 'postman-smtp'), array($this, 'loggingStatusInputField'), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION); add_settings_field('logging_max_entries', __('Maximum Number of Log Entries', 'Configuration Input Field', 'postman-smtp'), array($this, 'loggingMaxEntriesInputField'), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION); add_settings_field(PostmanOptions::TRANSCRIPT_SIZE, __('Maximum Number of Lines in a Transcript', 'postman-smtp'), array($this, 'transcriptSizeInputField'), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION); // the Network section add_settings_section(PostmanAdminController::NETWORK_SECTION, __('Network Settings', 'postman-smtp'), array($this, 'printNetworkSectionInfo'), PostmanAdminController::NETWORK_OPTIONS); add_settings_field('connection_timeout', _x('TCP Connection Timeout (sec)', 'Configuration Input Field', 'postman-smtp'), array($this, 'connection_timeout_callback'), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION); add_settings_field('read_timeout', _x('TCP Read Timeout (sec)', 'Configuration Input Field', 'postman-smtp'), array($this, 'read_timeout_callback'), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION); // the Advanced section add_settings_section(PostmanAdminController::ADVANCED_SECTION, _x('Miscellaneous Settings', 'Configuration Section Title', 'postman-smtp'), array($this, 'printAdvancedSectionInfo'), PostmanAdminController::ADVANCED_OPTIONS); add_settings_field(PostmanOptions::LOG_LEVEL, _x('PHP Log Level', 'Configuration Input Field', 'postman-smtp'), array($this, 'log_level_callback'), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION); add_settings_field(PostmanOptions::RUN_MODE, _x('Delivery Mode', 'Configuration Input Field', 'postman-smtp'), array($this, 'runModeCallback'), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION); add_settings_field(PostmanOptions::STEALTH_MODE, _x('Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails', 'postman-smtp'), array($this, 'stealthModeCallback'), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION); add_settings_field(PostmanOptions::TEMPORARY_DIRECTORY, __('Temporary Directory', 'postman-smtp'), array($this, 'temporaryDirectoryCallback'), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION); // the Test Email section register_setting('email_group', PostmanAdminController::TEST_OPTIONS); add_settings_section('TEST_EMAIL', _x('Test Your Setup', 'Configuration Section Title', 'postman-smtp'), array($this, 'printTestEmailSectionInfo'), PostmanAdminController::POSTMAN_TEST_SLUG); add_settings_field('test_email', _x('Recipient Email Address', 'Configuration Input Field', 'postman-smtp'), array($this, 'test_email_callback'), PostmanAdminController::POSTMAN_TEST_SLUG, 'TEST_EMAIL'); } }
/** * This is the general message that Postman requires configuration, to warn users who think * the plugin is ready-to-go as soon as it is activated. * This message only goes away once the plugin is configured. */ public function display_configuration_required_warning() { if (PostmanUtils::isAdmin()) { if ($this->logger->isDebug()) { $this->logger->debug('Displaying configuration required warning'); } $message = sprintf(PostmanTransportRegistry::getInstance()->getReadyMessage()); $goToSettings = sprintf('<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl(), __('Settings', Postman::TEXT_DOMAIN)); $goToEmailLog = sprintf('%s', _x('Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN)); if (PostmanOptions::getInstance()->isMailLoggingEnabled()) { $goToEmailLog = sprintf('<a href="%s">%s</a>', PostmanUtils::getEmailLogPageUrl(), $goToEmailLog); } $message .= sprintf(' %s | %s', $goToEmailLog, $goToSettings); $this->messageHandler->printMessage($message, PostmanMessageHandler::WARNING_CLASS); } }
/** * Add "Settings" link to the plugin action page * * @param unknown $links * @return multitype: */ public function postmanModifyLinksOnPluginsListPage($links) { // only administrators should be able to trigger this if (PostmanUtils::isAdmin()) { $mylinks = array(sprintf('<a href="%s" class="postman_settings">%s</a>', PostmanUtils::getSettingsPageUrl(), __('Settings', Postman::TEXT_DOMAIN))); return array_merge($mylinks, $links); } }
/** * Register the page */ function postmanAddMenuItem() { // only do this for administrators if (PostmanUtils::isAdmin()) { $this->logger->trace('created PostmanEmailLog admin menu item'); $page = add_management_page(__('Postman Email Log', 'postman-smtp'), _x('Email Log', 'The log of Emails that have been delivered', 'postman-smtp'), 'read_private_posts', 'postman_email_log', array($this, 'postman_render_email_page')); // When the plugin options page is loaded, also load the stylesheet add_action('admin_print_styles-' . $page, array($this, 'postman_email_log_enqueue_resources')); } }