/** * 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; } }
/** * 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); } }
/** * Options page callback */ public function outputDefaultContent() { // Set class property print '<div class="wrap">'; $this->displayTopNavigation(); if (PostmanTransportRegistry::getInstance()->isPostmanReadyToSendEmail($this->options, $this->authorizationToken) && PostmanPreRequisitesCheck::isReady()) { if ($this->options->getRunMode() != PostmanOptions::RUN_MODE_PRODUCTION) { printf('<p><span style="background-color:yellow">%s</span></p>', __('Postman is in <em>non-Production</em> mode and is dumping all emails.', 'postman-smtp')); } else { printf('<p><span style="color:green;padding:2px 5px; font-size:1.2em">%s</span></p>', __('Postman is configured.', 'postman-smtp')); $currentTransport = PostmanTransportRegistry::getInstance()->getCurrentTransport(); $deliveryDetails = $currentTransport->getDeliveryDetails($this->options); printf('<p style="margin:0 10px"><span>%s</span></p>', $deliveryDetails); } /* translators: where %d is the number of emails delivered */ printf('<p style="margin:10px 10px"><span>%s', sprintf(_n('Postman has delivered <span style="color:green">%d</span> email for you.', 'Postman has delivered <span style="color:green">%d</span> emails for you.', PostmanStats::getInstance()->getSuccessfulDeliveries(), 'postman-smtp'), PostmanStats::getInstance()->getSuccessfulDeliveries())); if ($this->options->isMailLoggingEnabled()) { print ' '; printf('<a href="%s">%s</a>.</span></p>', PostmanUtils::getEmailLogPageUrl(), __('View the log', 'postman-smtp')); } if (PostmanState::getInstance()->isTimeToReviewPostman() && !PostmanOptions::getInstance()->isNew()) { print '</br><hr width="70%"></br>'; /* translators: where %s is the URL to the WordPress.org review and ratings page */ printf('%s</span></p>', sprintf(__('Please consider <a href="%s">leaving a review</a> to help spread the word! :D', 'postman-smtp'), 'https://wordpress.org/support/view/plugin-reviews/postman-smtp?filter=5')); } } else { printf('<p><span style="color:red; padding:2px 5px; font-size:1.1em">%s</span></p>', __('Postman is <em>not</em> handling email delivery.', 'postman-smtp')); if ($this->options->isNew()) { printf('<h3>%s</h3>', __('Thank-you for choosing Postman!', 'postman-smtp')); /* translators: where %s is the URL of the Setup Wizard */ printf('<p><span>%s</span></p>', sprintf(__('Let\'s get started! All users are strongly encouraged to <a href="%s">run the Setup Wizard</a>.', 'postman-smtp'), $this->getPageUrl(self::CONFIGURATION_WIZARD_SLUG))); } } }
/** * Options page callback */ public function outputDefaultContent() { // Set class property print '<div class="wrap">'; $this->displayTopNavigation(); if (!PostmanPreRequisitesCheck::isReady()) { printf('<p><span style="color:red; padding:2px 0; font-size:1.1em">%s</span></p>', __('Postman is unable to run. Email delivery is being handled by WordPress (or another plugin).', Postman::TEXT_DOMAIN)); } else { $statusMessage = PostmanTransportRegistry::getInstance()->getReadyMessage(); if (PostmanTransportRegistry::getInstance()->getActiveTransport()->isConfiguredAndReady()) { if ($this->options->getRunMode() != PostmanOptions::RUN_MODE_PRODUCTION) { printf('<p><span style="background-color:yellow">%s</span></p>', $statusMessage); } else { printf('<p><span style="color:green;padding:2px 0; font-size:1.1em">%s</span></p>', $statusMessage); } } else { printf('<p><span style="color:red; padding:2px 0; font-size:1.1em">%s</span></p>', $statusMessage); } $this->printDeliveryDetails(); /* translators: where %d is the number of emails delivered */ print '<p style="margin:10px 10px"><span>'; printf(_n('Postman has delivered <span style="color:green">%d</span> email.', 'Postman has delivered <span style="color:green">%d</span> emails.', PostmanState::getInstance()->getSuccessfulDeliveries(), Postman::TEXT_DOMAIN), PostmanState::getInstance()->getSuccessfulDeliveries()); if ($this->options->isMailLoggingEnabled()) { print ' '; printf(__('The last %d email attempts are recorded <a href="%s">in the log</a>.', Postman::TEXT_DOMAIN), PostmanOptions::getInstance()->getMailLoggingMaxEntries(), PostmanUtils::getEmailLogPageUrl()); } print '</span></p>'; } if ($this->options->isNew()) { printf('<h3 style="padding-top:10px">%s</h3>', __('Thank-you for choosing Postman!', Postman::TEXT_DOMAIN)); /* translators: where %s is the URL of the Setup Wizard */ printf('<p><span>%s</span></p>', sprintf(__('Let\'s get started! All users are strongly encouraged to <a href="%s">run the Setup Wizard</a>.', Postman::TEXT_DOMAIN), $this->getPageUrl(PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG))); printf('<p><span>%s</span></p>', sprintf(__('Alternately, <a href="%s">manually configure</a> your own settings and/or modify advanced options.', Postman::TEXT_DOMAIN), $this->getPageUrl(PostmanConfigurationController::CONFIGURATION_SLUG))); } else { if (PostmanState::getInstance()->isTimeToReviewPostman() && !PostmanOptions::getInstance()->isNew()) { print '</br><hr width="70%"></br>'; /* translators: where %s is the URL to the WordPress.org review and ratings page */ printf('%s</span></p>', sprintf(__('Please consider <a href="%s">leaving a review</a> to help spread the word! :D', Postman::TEXT_DOMAIN), 'https://wordpress.org/support/view/plugin-reviews/postman-smtp?filter=5')); } printf('<p><span>%s :-)</span></p>', sprintf(__('Postman needs translators! Please take a moment to <a href="%s">translate a few sentences on-line</a>', Postman::TEXT_DOMAIN), 'https://translate.wordpress.org/projects/wp-plugins/postman-smtp/stable')); } printf('<p><span>%s</span></p>', __('<b style="background-color:yellow">New for v1.7!</style></b> Send mail with the Mandrill or SendGrid APIs.', Postman::TEXT_DOMAIN)); }