/**
  * @since 1.0.0
  * @return string
  */
 public function render()
 {
     $introduction = html('div class="intro-text"', html('h2', __('Customize Your Postmatic Template', 'Postmatic')), html('p', __('Since we\'ll be sending via email the focus should be on <em>your content</em>. That\'s why we keep things simple. Configure you colors, header and footer. Postmatic will handle what goes in between.', 'Postmatic')));
     $email_header_image = new Prompt_Attachment_Image($this->options->get('email_header_image'));
     $rows = array();
     $style_reset_html = '';
     if ($this->stylify->get_styles()) {
         $style_reset_html = html('input class="button" type="submit" name="reset_site_styles_button"', array('value' => __('Use defaults', 'Postmatic')));
     }
     $rows[] = html('tr class="stylify"', html('th scope="row"', __('Color palette detection', 'Postmatic'), '<br/>', html('small', __('Want the Postmatic template to use your typography and colors? Do so with a single click. We\'ll analyze the active theme and make your email template follow suit.', 'Postmatic'))), html('td', html('span class="site-color"', array('style' => 'background-color: ' . $this->stylify->get_value('a', 'color', '#000'))), html('span class="site-color"', array('style' => 'background-color: ' . $this->stylify->get_value('h1', 'color', '#000'))), html('span class="site-color"', array('style' => 'background-color: ' . $this->stylify->get_value('h2', 'color', '#000'))), html('span class="site-color"', array('style' => 'background-color: ' . $this->stylify->get_value('h3', 'color', '#000'))), html('span class="site-color"', array('style' => 'background-color: ' . $this->stylify->get_value('h4', 'color', '#000'))), html('div', html('input class="button" type="submit" name="stylify_button"', array('value' => __('Refresh', 'Postmatic'))), $style_reset_html)));
     if (Prompt_Enum_Email_Transports::API == Prompt_Core::$options->get('email_transport')) {
         $rows[] = $this->row_wrap(__('Email header type', 'Postmatic'), $this->input(array('type' => 'radio', 'name' => 'email_header_type', 'choices' => array(Prompt_Enum_Email_Header_Types::IMAGE => __('Image', 'Postmatic'), Prompt_Enum_Email_Header_Types::TEXT => __('Text', 'Postmatic'))), $this->options->get()));
         $rows[] = html('tr class="email-header-image"', html('th scope="row"', __('Email header image', 'Postmatic'), '<br/>', html('small', __('Choose a header image to be used when sending new posts, digests, letters, invitations, and subscription confirmations. Will be displayed at half the size of your uploaded image to support retina displays. The ideal width to fill the full header area is 1440px wide.', 'Postmatic'))), html('td', html('img', array('src' => $email_header_image->url(), 'width' => $email_header_image->width() / 2, 'height' => $email_header_image->height() / 2, 'class' => 'alignleft')), html('div class="uploader"', $this->input(array('name' => 'email_header_image', 'type' => 'hidden'), $this->options->get()), html('input class="button" type="button" name="email_header_image_button"', array('value' => __('Change', 'Postmatic'))))));
     }
     $rows[] = html('tr class="email-header-text"', html('th scope="row"', __('Email header text', 'Postmatic'), '<br/>', html('small', __('This text will show next to your site icon in simpler transactional emails such as comment notifications.', 'Postmatic'))), html('td', $this->input(array('name' => 'email_header_text', 'type' => 'text', 'extra' => 'class=last-submit'), $this->options->get())));
     if (Prompt_Enum_Email_Transports::API == Prompt_Core::$options->get('email_transport')) {
         $rows[] = html('tr class="site-icon"', html('th scope="row"', __('Site icon', 'Postmatic'), '<br/>', html('small', __('This is based on your site\'s favicon, and used in comment notifications in place of the header image.', 'Postmatic'))), html('td', html('img', array('src' => Prompt_Site_Icon::url(), 'width' => 32, 'height' => 32, 'class' => 'alignleft')), html('div', html('a', array('href' => admin_url('customize.php?autofocus[control]=site_icon')), __('Change in the customizer', 'Postmatic')))));
         $rows[] = $this->row_wrap(__('Email footer type', 'Postmatic'), $this->input(array('type' => 'radio', 'name' => 'email_footer_type', 'choices' => array(Prompt_Enum_Email_Footer_Types::WIDGETS => __('Widgets', 'Postmatic'), Prompt_Enum_Email_Header_Types::TEXT => __('Text', 'Postmatic'))), $this->options->get()));
         $rows[] = html('tr class="email-footer-widgets"', html('th scope="row"', __('Footer Widgets', 'Postmatic')), html('td', __('You can define widgets for your footer at ', 'Postmatic'), html('a', array('href' => admin_url('widgets.php')), __('Appearance > Widgets', 'Postmatic'))));
         $rows[] = html('tr class="email-footer-credit"', html('th scope="row"', __('Share the love?', 'Postmatic')), html('td', $this->input(array('name' => 'email_footer_credit', 'type' => 'checkbox', 'desc' => __('Include "Delivered by Postmatic" in the footer area. We appreciate it!', 'Postmatic'), 'extra' => 'class=last-submit'), $this->options->get())));
     }
     $rows[] = html('tr class="email-footer-text"', html('th scope="row"', __('Email footer text', 'Postmatic')), html('td', $this->input(array('name' => 'email_footer_text', 'type' => 'text', 'extra' => 'class=last-submit'), $this->options->get())));
     $rows[] = html('tr', html('th scope="row"', __('Send a test email to', 'Postmatic')), html('td', $this->input(array('type' => 'text', 'name' => 'test_email_address', 'value' => wp_get_current_user()->user_email, 'extra' => 'class=no-submit'), $_POST), html('input class="button" type="submit" name="send_test_email_button"', array('value' => __('Send', 'Postmatic')))));
     ob_start();
     wp_editor($this->options->get('subscribed_introduction'), 'subscribed_introduction');
     $subscriber_welcome_editor = ob_get_clean();
     $subscriber_welcome_content = html('div id="subscriber-welcome-message"', html('h3', __('Custom welcome message', 'Postmatic')), html('p', __('When someone sucessfully subscribes to your site we\'ll shoot back a confirmation note. Use this as a place to say thanks, or even offer an incentive.', 'Postmatic')), $subscriber_welcome_editor);
     $content = $this->table_wrap(implode('', $rows)) . $subscriber_welcome_content;
     return $introduction . $this->form_wrap($content) . $this->footer();
 }
Beispiel #2
0
 /**
  * Construct an email batch
  *
  * @since 2.0.0
  *
  * @param array $batch_message_template {
  *      Handlebars template fields to use for every email in the batch
  * @var string $html_content Required. Email message HTML content template
  * @var string $message_type Required. See Prompt_Enum_Message_Types.
  * @var string $text_content Optional. Email message text content template
  * @var string $to_address Optional, but required as an individual message value. Default '{{{to_address}}}'
  * @var string $to_name Optional, default '{{{to_name}}}'
  * @var string $subject Optional, default 'This is a test email. By Postmatic.'
  * @var string $from_name Optional, default blogname.
  * @var string $from_address Optional, default '*****@*****.**'
  * }
  * @param array $individual_message_values {
  *      Array of key/value pairs to create an email from the template, may contain your own custom values too.
  * @var string $to_address Required.
  * @var string $to_name Optional.
  * @var string $reply_to Optional, for trackable replies: array( 'trackable-address' => $metadata )
  * }
  * @param array $default_values Key/value pairs to use when a key is missing from individual message values.
  */
 public function __construct($batch_message_template = array(), $individual_message_values = array(), $default_values = array())
 {
     $brand_type = Prompt_Core::$options->get('email_header_type');
     $brand_image_id = 0;
     if (Prompt_Enum_Email_Header_Types::IMAGE === $brand_type) {
         $brand_image_id = Prompt_Core::$options->get('email_header_image');
         $batch_message_template['is_image_header'] = true;
     }
     $brand_image = new Prompt_Attachment_Image($brand_image_id);
     $site_icon_url = get_site_icon_url(64);
     if (!$site_icon_url) {
         $site_icon = new Prompt_Attachment_Image(Prompt_Core::$options->get('site_icon'));
         $site_icon_url = $site_icon->url();
     }
     $site_styles = new Prompt_Stylify(Prompt_Core::$options->get('site_styles'));
     ob_start();
     do_action('prompt/html_email/print_styles');
     $integration_css = ob_get_clean();
     $footer_type = Prompt_Core::$options->get('email_footer_type');
     $footer_text = Prompt_Core::$options->get('email_footer_text');
     $use_comment_sidebar = false;
     if (isset($batch_message_template['message_type'])) {
         $batch_message_template['is_' . str_replace('-', '_', $batch_message_template['message_type'])] = true;
         $use_comment_sidebar = in_array($batch_message_template['message_type'], array(Prompt_Enum_Message_Types::COMMENT, Prompt_Enum_Message_Types::COMMENT_MODERATION));
     }
     $default_template_values = array('to_name' => '{{{to_name}}}', 'to_address' => '{{{to_address}}}', 'subject' => __('This is a test email. By Postmatic.', 'Postmatic'), 'from_name' => get_option('blogname'), 'from_address' => self::default_from_email(), 'blogname' => get_option('blogname'), 'brand_type' => $brand_type, 'brand_text' => Prompt_Core::$options->get('email_header_text'), 'small_brand_image' => $brand_image->width() < 1440, 'brand_image_url' => $brand_image->url(), 'brand_image_width' => $brand_image->width() / 2, 'brand_image_height' => $brand_image->height() / 2, 'site_icon_url' => $site_icon_url, 'site_css' => $site_styles->get_css() . $integration_css, 'footer_html' => Prompt_Enum_Email_Footer_Types::WIDGETS == $footer_type ? $this->footer_widgets_html($use_comment_sidebar) : $footer_text, 'footer_text' => $footer_text, 'credit_html' => $this->credit_html(), 'credit_text' => $this->credit_text(), 'footnote_html' => '', 'footnote_text' => '');
     $this->batch_message_template = wp_parse_args($batch_message_template, $default_template_values);
     $this->individual_message_values = $individual_message_values;
     $this->default_values = $default_values;
 }