/** * @since 1.0.0 */ public function form_handler() { if (!empty($_POST['stylify_button'])) { $status = $this->stylify->refresh(); $message = is_wp_error($status) ? $status->get_error_message() : __('Colors updated.', 'Postmatic'); $class = is_wp_error($status) ? 'error' : 'updated'; Prompt_Core::$options->set('site_styles', $this->stylify->get_styles()); $this->add_notice($message, $class); return; } if (!empty($_POST['reset_site_styles_button'])) { Prompt_Core::$options->set('site_styles', array()); $this->stylify = new Prompt_Stylify(array()); $this->add_notice(__('Colors set to defaults.', 'Postmatic')); return; } if (!empty($_POST['send_test_email_button'])) { $to_address = sanitize_email($_POST['test_email_address']); if (!is_email($to_address)) { $this->add_notice(__('Test email was <strong>not sent</strong> to an invalid address.', 'Postmatic'), 'error'); return; } $html_template = new Prompt_Template('test-email.php'); $footnote = __('This is a test email sent by Postmatic. It is solely for demonstrating the Postmatic template and is not replyable. Also, that is not latin. <a href="https://en.wikipedia.org/wiki/Lorem_ipsum">It is Lorem ipsum</a>.', 'Postmatic'); $batch = new Prompt_Email_Batch(array('subject' => __('This is a test email. By Postmatic.', 'Postmatic'), 'html_content' => $html_template->render(), 'message_type' => Prompt_Enum_Message_Types::ADMIN, 'footnote_html' => $footnote, 'footnote_text' => $footnote)); $batch->add_individual_message_values(array('to_address' => $to_address)); if (!is_wp_error(Prompt_Factory::make_mailer($batch)->send())) { $this->add_notice(__('Test email <strong>sent</strong>.', 'Postmatic')); return; } } parent::form_handler(); }
/** * Detect if this retry attempt has already been made. * * @since 2.0.0 * * @return bool */ protected function already_retried() { $log = get_option(self::$retry_option, array()); $key = md5($this->retry_wait_seconds . serialize($this->batch->to_array())); if (isset($log[$key])) { return true; } $log[$key] = microtime(); update_option(self::$retry_option, $log, false); return false; }
/** * Send a comment a notification when their comment is rejected. * * This could be due to a deleted post, change in post status, or comments being closed. * * @param $user_id * @param $post_id */ public static function send_rejected_notification($user_id, $post_id) { $comment_author = get_userdata($user_id); $post = get_post($post_id); $post_title = $post ? $post->post_title : __('a deleted post', 'Postmatic'); $template_data = compact('comment_author', 'post', 'post_title'); /** * Filter comment rejected email template data. * * @param array $template_data { * @type WP_User $comment_author * @type WP_Post $post * @type string $post_title Post title or placeholder if post no longer exists * } */ $template_data = apply_filters('prompt/comment_rejected_email/template_data', $template_data); $subject = sprintf(__('Unable to publish your reply to "%s"', 'Postmatic'), $post_title); $template = new Prompt_Template('comment-rejected-email.php'); $batch = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => $comment_author->user_email, 'subject' => $subject, 'html_content' => $template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::ADMIN)); /** * Filter comment rejected email. * * @param Prompt_Email_Batch $batch * @param array $template_data see prompt/comment_reject_email/template_data */ $batch = apply_filters('prompt/comment_rejected_batch', $batch, $template_data); Prompt_Factory::make_mailer($batch)->send(); }
/** * Builds an email batch with content based on a subscribable object. * * @since 2.0.0 * * @param Prompt_Interface_Subscribable[]|Prompt_Interface_Subscribable $lists * @param array $message_data */ public function __construct($lists, $message_data = array()) { $this->lists = is_array($lists) ? $lists : array($lists); $this->users_data = array(); $this->message_data = $message_data; $message_data = array_merge(array('lists' => $this->lists), $message_data); /** * Filter new user subscription verification email template data. * @param array $message_data { * @type Prompt_Interface_Subscribable $lists The object being subscribed to * } */ $message_data = apply_filters('prompt/subscription_agreement_email/template_data', $message_data); $html_template = new Prompt_Template('subscription-agreement-email.php'); $text_template = new Prompt_Text_Template('subscription-agreement-email-text.php'); $subject = sprintf(__('Please verify your subscription to %s', 'Postmatic'), $this->lists[0]->subscription_object_label()); if (count($this->lists) > 1) { $subject = __('Please select your subscription', 'Postmatic'); } $batch_message_template = array('subject' => $subject, 'from_name' => get_option('blogname'), 'message_type' => Prompt_Enum_Message_Types::SUBSCRIPTION, 'html_content' => $html_template->render($message_data), 'text_content' => $text_template->render($message_data), 'reply_to' => '{{{reply_to}}}'); // Override template with message data foreach ($batch_message_template as $name => $value) { if (isset($message_data[$name])) { $batch_message_template[$name] = $message_data[$name]; } } $batch_message_template['footnote_html'] = $this->footnote_html($batch_message_template['message_type']); $batch_message_template['footnote_text'] = $this->footnote_text($batch_message_template['message_type']); parent::__construct($batch_message_template); }
/** * Send an email to a user who has had an account created for them. * * @param int|object $user * @param string $password * @param Prompt_Template $template */ public static function send_new_user_notification($user, $password, $template) { $user = is_integer($user) ? get_userdata($user) : $user; $template_data = compact('user', 'password'); /** * Filter new user email template data. * * @param array $template_data { * @type WP_User $user * @type string $password * } */ $template_data = apply_filters('prompt/new_user_email/template_data', $template_data); $subject = sprintf(__('Welcome to %s', 'Postmatic'), get_option('blogname')); $batch = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => $user->user_email, 'from_address' => get_option('admin_email'), 'subject' => $subject, 'html_content' => $template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::ADMIN)); /** * Filter new user email. * * @param Prompt_Email_Batch $batch * @param array $template_data { * @type WP_User $user * @type string $password * } */ $batch = apply_filters('prompt/new_user_batch', $batch, $template_data); Prompt_Factory::make_mailer($batch)->send(); }
public function form_handler() { $environment = new Prompt_Environment(); $user = wp_get_current_user(); $email = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => Prompt_Core::SUPPORT_EMAIL, 'from_address' => $user->user_email, 'from_name' => $user->display_name, 'subject' => sprintf(__('Diagnostics from %s', 'Postmatic'), html_entity_decode(get_option('blogname'))), 'html_content' => json_encode($environment->to_array()), 'message_type' => Prompt_Enum_Message_Types::ADMIN)); $sent = Prompt_Factory::make_mailer($email)->send(); if (is_wp_error($sent)) { Prompt_Logging::add_error('diagnostic_submission_error', __('Diagnostics could not be sent, please try a bug report.', 'Postmatic'), $sent); return; } $this->add_notice(__('Diagnostics <strong>sent</strong>.', 'Postmatic')); }
/** * Builds an email without specific recipient info that can be used as a template for all recipients. * * The set_recipient method can be called to fill in recipient-specific fields. * * @since 2.0.0 * * @param Prompt_Post_Rendering_Context $context Rendering context for the target post * @param array $args { * @type bool $excerpt_only Override the excerpt only checkbox in the delivery metabox. * } */ public function __construct(Prompt_Post_Rendering_Context $context, $args = array()) { $this->context = $context; $context->setup(); $prompt_author = $context->get_author(); $prompt_post = $context->get_post(); $is_api_delivery = Prompt_Enum_Email_Transports::API == Prompt_Core::$options->get('email_transport'); $will_strip_content = (!$is_api_delivery and $context->has_fancy_content()); $subject = html_entity_decode($prompt_post->get_wp_post()->post_title, ENT_QUOTES); list($footnote_html, $footnote_text) = $this->footnote_content(); if ('draft' == $prompt_post->get_wp_post()->post_status) { /* translators: %s is a post title */ $subject = sprintf(__('PREVIEW of %s', 'Postmatic'), $subject); $footnote_html = $footnote_text = ''; } $excerpt_only = Prompt_Admin_Delivery_Metabox::excerpt_only($prompt_post->id()); if (isset($args['excerpt_only'])) { $excerpt_only = $args['excerpt_only']; } $this->comments = get_approved_comments($prompt_post->id()); $template_data = array('prompt_author' => $prompt_author, 'prompt_post' => $prompt_post, 'featured_image_src' => $context->get_the_featured_image_src(), 'excerpt_only' => $excerpt_only, 'the_text_content' => $context->get_the_text_content(), 'subject' => $subject, 'alternate_versions_menu' => $context->alternate_versions_menu(), 'is_api_delivery' => $is_api_delivery, 'will_strip_content' => $will_strip_content, 'comments' => $this->comments); /** * Filter new post email template data. * * @param array $template_data { * @type Prompt_User $prompt_author * @type Prompt_Post $prompt_post * @type array $featured_image_src url, width, height * @type bool $excerpt_only whether to include only the post excerpt * @type string $the_text_content * @type string $subject * @type bool $is_api_delivery * @type bool $will_strip_content * } */ $template_data = apply_filters('prompt/post_email/template_data', $template_data); $html_template = new Prompt_Template("new-post-email.php"); $text_template = new Prompt_Text_Template("new-post-email-text.php"); $batch_message_template = array('subject' => $subject, 'from_name' => '{{{from_name}}}', 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::POST, 'reply_to' => '{{{reply_to}}}', 'footnote_html' => $footnote_html, 'footnote_text' => $footnote_text); $this->replyable = (comments_open($prompt_post->id()) and !$excerpt_only); if (!$this->replyable) { $batch_message_template['from_address'] = $prompt_author->get_wp_user()->user_email; } $default_values = array('from_name' => $this->to_utf8(get_option('blogname'))); $context->reset(); parent::__construct($batch_message_template, array(), $default_values); }
/** * @since 1.0.0 * * @param array $recipients * @param string $subject * @param string $message */ public function schedule_invites($recipients, $subject, $message) { $users_data = array(); $address_index = array(); $failures = array(); $lists = Prompt_Subscribing::get_signup_lists(); $current_user = wp_get_current_user(); foreach ($recipients as $recipient) { $to_address = Prompt_Email_Batch::address($recipient); $lower_case_to_address = strtolower($to_address); if (isset($address_index[$lower_case_to_address])) { $failures[] = __('Duplicate email address', 'Postmatic') . ': ' . $recipient; continue; } if (!is_email($to_address)) { $failures[] = __('Invalid email address', 'Postmatic') . ': ' . $recipient; continue; } $user = get_user_by('email', $to_address); if ($user and $this->is_subscribed_to_any($user->ID, $lists)) { $failures[] = __('Already subscribed', 'Postmatic') . ': ' . $recipient; continue; } $address_index[$lower_case_to_address] = true; $to_name = Prompt_Email_Batch::name($recipient); $users_data[] = array('user_email' => $to_address, 'display_name' => $to_name); } if (!empty($users_data)) { $message_data = array('subject' => html_entity_decode($subject, ENT_QUOTES), 'invite_introduction' => $message, 'message_type' => Prompt_Enum_Message_Types::INVITATION, 'from_name' => $current_user->display_name . ' - ' . get_option('blogname')); Prompt_Subscription_Mailing::schedule_agreements($lists, $users_data, $message_data); $confirmation_format = _n('Success. %d invite sent.', 'Success. %d invites sent.', count($users_data), 'Postmatic'); $this->add_notice(sprintf($confirmation_format, count($users_data))); } if (!empty($failures)) { $failure_notice = __('Something went wrong and these invites were not sent: ', 'Postmatic') . '<br/>' . implode('<br/>', $failures); $this->add_notice($failure_notice, 'error'); } }
/** * Builds an email batch with content and recipients based on a comment. * * @since 2.0.0 * * @param object $comment Target comment * @param Prompt_Comment_Flood_Controller */ public function __construct($comment, Prompt_Comment_Flood_Controller $flood_controller = null) { $this->comment = $comment; $this->prompt_post = $prompt_post = new Prompt_Post($this->comment->comment_post_ID); $this->flood_controller = $flood_controller ? $flood_controller : new Prompt_Comment_Flood_Controller($comment); $this->subscribed_post_title_link = html('a', array('href' => get_permalink($this->prompt_post->id())), get_the_title($this->prompt_post->id())); $comment_author = $this->comment_author_user(); $is_api_delivery = Prompt_Enum_Email_Transports::API == Prompt_Core::$options->get('email_transport'); $parent_comment = $parent_author = null; $parent_author_name = ''; $template_file = 'new-comment-email.php'; if ($this->comment->comment_parent) { $parent_comment = get_comment($this->comment->comment_parent); $parent_author = get_userdata($parent_comment->user_id); $parent_author_name = $parent_author ? $parent_author->display_name : $parent_comment->comment_author; $parent_author_name = $parent_author_name ? $parent_author_name : __('Anonymous', 'Postmatic'); $template_file = $is_api_delivery ? 'comment-reply-email.php' : $template_file; } $this->parent_comment = $parent_comment; $this->parent_author = $parent_author; $this->parent_author_name = $parent_author_name; $commenter_name = $comment_author ? $comment_author->display_name : $this->comment->comment_author; $commenter_name = $commenter_name ? $commenter_name : __('Anonymous', 'Postmatic'); $this->commenter_name = $commenter_name; $post_author = get_userdata($prompt_post->get_wp_post()->post_author); $post_author_name = $post_author ? $post_author->display_name : __('Anonymous', 'Postmatic'); $this->set_previous_comments(); $template_data = array('comment_author' => $comment_author, 'comment' => $this->comment, 'commenter_name' => $commenter_name, 'subscribed_post' => $prompt_post, 'subscribed_post_author_name' => $post_author_name, 'subscribed_post_title_link' => $this->subscribed_post_title_link, 'previous_comments' => $this->previous_comments, 'parent_author' => $parent_author, 'parent_author_name' => $parent_author_name, 'parent_comment' => $parent_comment, 'comment_header' => true, 'is_api_delivery' => $is_api_delivery); /** * Filter comment email template data. * * @param array $template_data { * @type WP_User $comment_author * @type WP_User $subscriber * @type object $comment * @type Prompt_post $subscribed_post * @type string $subscribed_post_author_name * @type array $previous_comments * @type WP_User $parent_author * @type string $parent_author_name * @type object $parent_comment * @type bool $comment_header * @type bool $is_api_delivery * } */ $template_data = apply_filters('prompt/comment_email/template_data', $template_data); $html_template = new Prompt_Template($template_file); $text_template = new Prompt_Text_Template(str_replace('.php', '-text.php', $template_file)); /* translators: %1$s is a subscription list title, %2$s the unsubscribe command */ $footnote_format = __('You received this email because you\'re subscribed to %1$s. To no longer receive other comments or replies in this discussion reply with the word \'%2$s\'.', 'Postmatic'); $message_template = array('from_name' => $commenter_name, 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::COMMENT, 'subject' => '{{{subject}}}', 'reply_to' => '{{{reply_to}}}', 'footnote_html' => sprintf($footnote_format, $this->prompt_post->subscription_object_label(), "<a href=\"{$this->unsubscribe_mailto()}\">" . Prompt_Unsubscribe_Matcher::target() . "</a>"), 'footnote_text' => sprintf($footnote_format, $this->prompt_post->subscription_object_label(Prompt_Enum_Content_Types::TEXT), Prompt_Unsubscribe_Matcher::target())); parent::__construct($message_template); $recipient_ids = array_diff($this->flood_controlled_recipient_ids(), $this->sent_recipient_ids()); /** * Filter whether to send new comment notifications. * * @param boolean $send Default true. * @param object $comment * @param array $recipient_ids */ if (!apply_filters('prompt/send_comment_notifications', true, $this->comment, $recipient_ids)) { return null; } $this->add_recipients($recipient_ids); }
/** * Report new errors. * * @since 2.0.0 */ public static function submit() { $user = wp_get_current_user(); $last_submit_time = self::get_last_submission_time(); update_option(self::$last_submit_option_name, time(), $autoload = false); $message = array('error_log' => self::get_log($last_submit_time, ARRAY_A)); $environment = new Prompt_Environment(); $message = array_merge($message, $environment->to_array()); $email = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => Prompt_Core::SUPPORT_EMAIL, 'from_address' => $user->exists() ? $user->user_email : get_option('admin_email'), 'from_name' => $user->exists() ? $user->display_name : '', 'subject' => sprintf('Error submission from %s', html_entity_decode(get_option('blogname'))), 'text_content' => json_encode($message), 'message_type' => Prompt_Enum_Message_Types::ADMIN)); $sent = Prompt_Factory::make_mailer($email, Prompt_Enum_Email_Transports::LOCAL)->send(); if (is_wp_error($sent) and Prompt_Core::$options->get('prompt_key')) { $sent = Prompt_Factory::make_mailer($email, Prompt_Enum_Email_Transports::API)->send(); } return $sent; }
/** * @since 2.0.0 */ protected function forward() { $text = $this->get_message_text(); $from_user = get_user_by('id', $this->from_user_id); $to_user = get_user_by('id', $this->to_user_id); $command = new Prompt_Forward_Command(); $command->set_keys(array('', '', $this->to_user_id, $this->from_user_id)); $template_data = array('sender' => $from_user, 'message' => $text); $html_template = new Prompt_Template('forward-email.php'); $batch = Prompt_Email_Batch::make_for_single_recipient(array('to_address' => $to_user->user_email, 'from_name' => $from_user->display_name, 'subject' => $this->message->subject, 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::ADMIN, 'reply_to' => array('trackable-address' => Prompt_Command_Handling::get_command_metadata($command)))); Prompt_Factory::make_mailer($batch)->send(); }
/** * @since 1.0.0 * @return string */ protected function import_content() { $api_key = sanitize_text_field($_POST['mailchimp_api_key']); $list_id = sanitize_text_field($_POST[$this->import_list_name]); $signup_list_index = absint($_POST['signup_list_index']); $signup_lists = Prompt_Subscribing::get_signup_lists(); $import = new Prompt_Admin_MailChimp_Import($api_key, $list_id, $signup_lists[$signup_list_index]); $import->execute(); $content = html('h3', __('Here\'s how it went', 'Postmatic')); $content .= $import->get_error() ? $import->get_error()->get_error_message() : ''; $results_format = _n('Imported one subscriber.', 'Imported %1$s subscribers.', $import->get_imported_count(), 'Postmatic'); if ($import->get_already_subscribed_count() > 0) { $results_format .= ' ' . _n('The one valid user we found was already subscribed.', 'The %2$s valid users we found were already subscribed.', $import->get_already_subscribed_count(), 'Postmatic'); } $rejects = $import->get_rejected_subscribers(); $reject_content = ''; $reject_button = ''; if ($rejects) { $results_format .= '<br />' . _n('One user didn\'t qualify for importing.', 'There were %3$s users which didn\'t qualify for importing.', count($rejects)); $reject_content = html('div id="mailpoet-import-intro"', html('div', html('h4', __('Why weren\'t more of my users imported?', 'Postmatic')), html('p', __('We have a very strict policy regarding user imports: <em>we will never allow anyone to be subscribed to a blog running Postmatic without them having opted in</em> (such as subscriber lists bought and imported in bulk for spamming). Because of this we will not import any MailChimp subscribers unless the following two conditions are true:', 'Postmatic')), html('ol', html('li', __('The user has double opted-in to your MailChimp list', 'Postmatic')), html('li', __('The user exists on a list which is at least 14 days old', 'Postmatic'))), html('h5', __('Why so strict?', 'Postmatic')), html('p', __('Bulk importing unwilling users is easy in MailChimp. If we did not hold our import to a higher standard those unwilling users could be imported into Postmatic. And then they would spam your users. MailChimp is a one-way street. Postmatic is a conversation. That\'s a very important difference.', 'Postmatic')), html('h4', __('But we do have good news', 'Postmatic')), html('p', __('You can send an email to your remaining users. They will be invited to join your site by simply replying.', 'Postmatic')))); $rejected_addresses = array(); foreach ($rejects as $reject) { $name = trim($reject['email']); //$name = trim( $reject['firstname'] . ' ' . $reject['lastname'] ); $rejected_addresses[] = Prompt_Email_Batch::name_address($reject['email'], $name); } $reject_button = html('input', array('name' => $this->rejected_addresses_name, 'class' => 'button', 'data-addresses' => implode(",", $rejected_addresses), 'type' => 'submit', 'value' => __('Preview and send the invitations', 'Postmatic'))); } $content = html('p', $content, sprintf($results_format, $import->get_imported_count(), $import->get_already_subscribed_count(), count($rejects)), $reject_content, $reject_button); return $content; }
protected function send_notifications($recipient_ids) { $template_data = array('post' => $this->prompt_post, 'comment_header' => true); /** * Filter comment email template data. * * @param array $template_data { * @type Prompt_post $post * @type bool $comment_header * } */ $template_data = apply_filters('prompt/comment_flood_email/template_data', $template_data); $html_template = new Prompt_Template('comment-flood-email.php'); $text_template = new Prompt_Text_Template('comment-flood-email-text.php'); $footnote_html = sprintf(__('You received this email because you\'re subscribed to %s.', 'Postmatic'), $this->prompt_post->subscription_object_label()); $batch = new Prompt_Email_Batch(array('subject' => __('We\'re pausing comment notices for you.', 'Postmatic'), 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::SUBSCRIPTION, 'reply_to' => '{{{reply_to}}}', 'footnote_html' => $footnote_html, 'footnote_text' => Prompt_Content_Handling::reduce_html_to_utf8($footnote_html))); foreach ($recipient_ids as $recipient_id) { $subscriber = get_userdata($recipient_id); if (!$subscriber or !$subscriber->user_email) { continue; } $command = new Prompt_Comment_Flood_Command(); $command->set_post_id($this->prompt_post->id()); $command->set_user_id($recipient_id); $batch->add_individual_message_values(array('to_address' => $subscriber->user_email, 'reply_to' => Prompt_Email_Batch::trackable_address(Prompt_Command_Handling::get_command_metadata($command)))); } /** * Filter comment notification email batch. * * @param Prompt_Email_Batch $batch * @param array $template_data see prompt/comment_email/template_data */ $batch = apply_filters('prompt/comment_flood_email_batch', $batch, $template_data); Prompt_Factory::make_mailer($batch)->send(); }
/** * Render handlebars fields in the batch template using a set of individual message values. * * @since 2.0.0 * * @param array $values * @param object $outbound_message * @return array */ protected function render_individual_email($values, $outbound_message) { $template = $this->batch->get_batch_message_template(); $values = array_merge($this->batch->get_default_values(), $values); $email_fields = array(); $reply_to = isset($values['reply_to']) ? $values['reply_to'] : null; if ($reply_to) { $email_fields['metadata'] = $reply_to['trackable-address']; unset($values['reply_to']); } $values['ref_id'] = $outbound_message ? $outbound_message->id : 'noreply'; foreach ($template as $field_name => $field_template) { $email_fields[$field_name] = $this->handlebars->render_string($field_template, $values); } if ($outbound_message) { $email_fields['reply_address'] = Prompt_Email_Batch::address($outbound_message->reply_to); $email_fields['reply_name'] = Prompt_Email_Batch::name($outbound_message->reply_to); } return $email_fields; }
/** * Get import results in HTML. * * @since 1.0.0 * @return string */ protected function import_content() { $list_id = intval($_POST[$this->import_list_name]); $signup_list_index = intval($_POST['signup_list_index']); $signup_lists = Prompt_Subscribing::get_signup_lists(); $signup_list = $signup_lists[$signup_list_index]; $import = Prompt_Admin_Mailpoet_Import::make($list_id, $signup_list); $import->execute(); $content = html('h3', __('Here\'s how it went:', 'Postmatic')); $content .= $import->get_error() ? $import->get_error()->get_error_message() : ''; $results_format = _n('Imported one subscriber.', 'Imported %1$s subscribers.', $import->get_imported_count(), 'Postmatic'); if ($import->get_already_subscribed_count() > 0) { $results_format .= ' ' . _n('The one valid user we found was already subscribed.', 'The %2$s valid users we found were already subscribed.', $import->get_already_subscribed_count(), 'Postmatic'); } $rejects = $import->get_rejected_subscribers(); $reject_content = ''; $reject_button = ''; if ($rejects) { $results_format .= '<br />' . _n('One user didn\'t qualify for importing.', 'There were %3$s users which didn\'t qualify for importing.', count($rejects)); $reject_content = html('div id="mailpoet-import-intro"', html('div', html('h4', __('Why weren\'t more of my users imported?', 'Postmatic')), html('p', __('We have a very strict policy regarding user imports: <em>we will never allow anyone to be subscribed to a blog running Postmatic without them having opted in</em> (such as subscriber lists bought and imported in bulk for spamming). Because of this we will not import any Mailpoet subscribers unless the following two conditions are true:', 'Postmatic')), html('ol', html('li', __('The user has opened an email you sent through Mailpoet', 'Postmatic')), html('li', __('The user has clicked a link within an email you sent through Mailpoet', 'Postmatic'))), html('h5', __('Why so strict?', 'Postmatic')), html('p', __('Bulk importing unwilling users and marking them as opted-in is easy in Mailpoet. If we did not hold our import to a higher standard the magic button below would allow those unwilling users to be imported into Postmatic. And then they would spam your grandmother. Nobody wants that. Plus, if a subscriber does not open or interact with your emails maybe they aren\'t all that good of a match anyway, right? Think of it as spring cleaning.', 'Postmatic')), html('h4', __('But we do have good news', 'Postmatic')), html('p', __('You can send an email to your remaining users. They will be invited to join your site by simply replying.', 'Postmatic')))); $rejected_addresses = array(); foreach ($rejects as $reject) { $name = trim($reject['firstname'] . ' ' . $reject['lastname']); $rejected_addresses[] = Prompt_Email_Batch::name_address($reject['email'], $name); } $reject_button = html('input', array('name' => $this->rejected_addresses_name, 'class' => 'button', 'data-addresses' => implode(",", $rejected_addresses), 'type' => 'submit', 'value' => __('Preview and send the invitations', 'Postmatic'))); } $content = html('p', $content, sprintf($results_format, $import->get_imported_count(), $import->get_already_subscribed_count(), count($rejects)), $reject_content, $reject_button); return $content; }
/** * Generate comment reply address macros from comments and the replying user ID. * * @since 2.0.0 * * @param array $comments * @param int $replier_id * @return array */ public static function get_comment_reply_macros(array $comments, $replier_id) { $macros = array(); foreach ($comments as $comment) { $macros['reply_to_comment_' . $comment->comment_ID] = Prompt_Email_Batch::trackable_address(self::get_comment_command_metadata($replier_id, $comment->comment_post_ID, $comment->comment_ID)); } return $macros; }