예제 #1
0
 /**
  * @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();
 }
예제 #2
0
 /**
  * @since 1.4.0
  *
  * @return string
  */
 public function render()
 {
     $values = Prompt_Optins::optins_options();
     $default_image_url = Prompt_Core::$url_path . '/media/optins/e-black-50.png';
     $popup_image = new Prompt_Attachment_Image($values['optins_popup_image'], $default_image_url, 500, 500);
     $inpost_image = new Prompt_Attachment_Image($values['optins_inpost_image'], $default_image_url, 500, 500);
     $bottom_image = new Prompt_Attachment_Image($values['optins_bottom_image'], $default_image_url, 500, 500);
     $rows = array($this->input(array('name' => 'optins_default_image_url', 'type' => 'hidden', 'value' => $default_image_url)));
     $rows[] = html('div class="intro-text"', html('h2', __('Add optin forms to your site and turn visitors into subscribers', 'Postmatic')), html('P', __('Postmatic comes bundled with four different opt-in styles. They are lightweight, fast, and effective ways to build your audience.')));
     $rows[] = html('div class="optin-enable" id="optin-select-popup"', html('div class="cbox"', $this->input(array('type' => 'checkbox', 'name' => 'optins_popup_enable', 'extra' => array('id' => 'optins_popup_enable')), $values), html('label', array('for' => 'optins_popup_enable'), __('Enable Popups', 'Postmatic'))));
     $rows[] = html('div class="optin-enable gutter" id="optin-intro-popup"', html('div', html('h2', __('Popup over the page <small>(click to enable)</small>', 'Postmatic')), html('p', __('A traditional popup which displays over the page content using an animated modal window. This popup can be triggered depending how long a user has been on the page, when the user scrolls to the bottom of the post, or after the user leaves a comment if you are using <a href="http://gopostmatic.com/epoch">Epoch</a>.'))));
     $rows[] = html('div id="popup-options" class="gutter"', html('h3 class="col1"', __('How would you like to trigger this popup?', 'Postmatic')), html('div id="popup-type" class="col1"', $this->input(array('type' => 'radio', 'name' => 'optins_popup_type', 'choices' => Prompt_Optins::popup_bottom_trigger_options()), $values), $this->input(array('type' => 'checkbox', 'name' => 'optins_popup_admin_test', 'desc' => __('<strong>Enable test mode</strong>: Always trigger popup for Administrator-level users', 'Postmatic')), $values)), html('div id="popup-time"', html('h4 class="col1"', __('After how many seconds would you like this popup to pop?', 'Postmatic')), $this->input(array('type' => 'number', 'name' => 'optins_popup_time', 'extra' => array('class' => 'col1')), $values)), html('div id="popup-title-text" class="col2"', html('h3', __('Add a headline and some welcoming text.', 'Postmatic')), html('h4', __('Headline', 'Postmatic')), $this->input(array('type' => 'text', 'name' => 'optins_popup_title'), $values), html('h4', __('Text to display below headline<small>Allowed HTML: a, strong, em, ul, ol, li, img, p, h2, h3, h4</small>', 'Postmatic')), $this->input(array('type' => 'textarea', 'label' => 'd', 'name' => 'optins_popup_desc'), $values)), $this->theme_chooser_html('popup-theme', 'optins_popup_theme', __('Choose a theme. This controls how the popup looks on your site.', 'Postmatic'), $values), html('div id="popup-image" class="optin-image"', html('h3', __('Choose an image to display on the left side of your popup.', 'Postmatic')), html('p', sprintf(__('We haven\'t built our image chooser yet but have created 8 different icons for you to use (or you can upload your own). <a href="%s" target="_blank">Download them here</a> and add the ones you like to your media library (below). In the future just search your media library for the word <em>Postmatic</em>.', 'Postmatic'), Prompt_Core::$url_path . '/media/optins/postmatic-optin-icons.zip')), html('img', array('src' => $popup_image->url()))), $this->input(array('name' => 'optins_popup_image', 'type' => 'hidden'), $values), html('input class="button" type="button" name="optins_popup_image_button"', array('value' => __('Change', 'Postmatic'))), html('input class="button" type="button" name="optins_popup_image_reset_button"', array('value' => __('Reset', 'Postmatic'))));
     $rows[] = html('div class="optin-enable" id="optin-select-bottom"', html('div class="cbox"', $this->input(array('type' => 'checkbox', 'name' => 'optins_bottom_enable', 'value' => 1, 'extra' => array('id' => 'optins_bottom_enable')), $values), html('label', array('for' => 'optins_bottom_enable'), __('Enable bottom slider', 'Postmatic'))));
     $rows[] = html('div class="optin-enable gutter" id="optin-intro-bottom"', html('div', html('h2', __('Slide in from the bottom <small>(click to enable)</small>', 'Postmatic')), html('p', __('A subtle slider that pops up from the bottom of the browser window. This popup can be triggered depending how long a user has been on the page, when the user scrolls to the bottom of the post, or after the user leaves a comment if you are using <a href="http://gopostmatic.com/epoch">Epoch</a>.'))));
     $rows[] = html('div id="bottom-options" class="gutter"', html('h3 class="col1"', __('When should this slider trigger?', 'Postmatic')), html('div id="bottom-type" class="col1"', $this->input(array('type' => 'radio', 'name' => 'optins_bottom_type', 'choices' => Prompt_Optins::popup_bottom_trigger_options()), $values)), html('div id="bottom-time"', html('h4 class="col1"', __('After how many seconds would you like the slider to slide?', 'Postmatic')), $this->input(array('type' => 'number', 'name' => 'optins_bottom_time', 'extra' => array('class' => 'col1')), $values)), html('div id="bottom-title-desc" class="col2"', html('h3', __('Add a headline and some welcoming text.', 'Postmatic')), html('h4', __('Headline', 'Postmatic')), $this->input(array('type' => 'text', 'name' => 'optins_bottom_title'), $values), html('h4', __('Text to display below headline<small>Allowed HTML: a, strong, em, ul, ol, li, img, p, h2, h3, h4</small>', 'Postmatic')), $this->input(array('type' => 'textarea', 'label' => 'd', 'name' => 'optins_bottom_desc'), $values)), $this->theme_chooser_html('bottom-theme', 'optins_bottom_theme', __('Choose a theme. This controls how the slider looks on your site.', 'Postmatic'), $values), html('div id="bottom-image" class="optin-image"', html('h3', __('Choose an image to display on the right side of your popup.', 'Postmatic')), html('p', sprintf(__('We haven\'t built our image chooser yet but have created 8 different icons for you to use (or you can upload your own). <a href="%s" target="_blank">Download them here</a> and add the ones you like to your media library (below). In the future just search your media library for the word <em>Postmatic</em>.', 'Postmatic'), Prompt_Core::$url_path . '/media/optins/postmatic-optin-icons.zip')), html('img', array('src' => $bottom_image->url()))), $this->input(array('name' => 'optins_bottom_image', 'type' => 'hidden'), $values), html('input class="button" type="button" name="optins_bottom_image_button"', array('value' => __('Change', 'Postmatic'))), html('input class="button" type="button" name="optins_bottom_image_reset_button"', array('value' => __('Reset', 'Postmatic'))));
     $rows[] = html('div class="optin-enable" id="optin-select-topbar"', html('div class="cbox"', $this->input(array('type' => 'checkbox', 'name' => 'optins_topbar_enable', 'value' => '1', 'extra' => array('id' => 'optins_topbar_enable')), $values), html('label', array('for' => 'optins_topbar_enable'), __('Enable the topbar', 'Postmatic'))));
     $rows[] = html('div class="optin-enable gutter" id="optin-intro-topbar"', html('div', html('h2', __('A bar across the top of your site <small>(click to enable)</small>', 'Postmatic')), html('p', __('A 50px tall bar that spans across the top of your site. The bar is a persistent (meaning it does no scroll with the rest of your content)  and unobtrusive reminder to subscribe. <strong>Note:</strong> may not render properly in all themes. This one is tricky. Give it a try to see.'))));
     $rows[] = html('div id="topbar-title-desc" class="gutter"', html('h3 scope="row"', __('What message should be in the bar?', 'Postmatic')), html('div', __('', 'Postmatic'), $this->input(array('type' => 'text', 'name' => 'optins_topbar_title'), $values)), $this->theme_chooser_html('topbar-theme', 'optins_topbar_theme', __('Choose a theme. This controls how the bar looks on your site.', 'Postmatic'), $values));
     if (isset($values['optins_inpost_ids'])) {
         if (is_array($values['optins_inpost_ids'])) {
             $values['optins_inpost_ids'] = implode(',', $values['optins_inpost_ids']);
         }
     }
     $rows[] = html('div class="optin-enable" id="optin-select-inline"', html('div id="inpost-enable" class="cbox"', $this->input(array('type' => 'checkbox', 'name' => 'optins_inpost_enable', 'value' => '1', 'extra' => array('id' => 'optins_inpost_enable')), $values), html('label', array('for' => 'optins_inpost_enable'), __('Enable after-the-post', 'Postmatic'))));
     $rows[] = html('div class="optin-enable gutter" id="optin-intro-inpost"', html('div', html('h2', __('A form at the end of each post <small>(click to enable)</small>', 'Postmatic')), html('p', __('A nicely styled form that automatically displays at the bottom of each post on your site and invites users to subscribe. Classy, simple, and effective.'))));
     $rows[] = html('div id="inpost-options" class="gutter"', html('div id="inpost-title-desc"', html('h4', __('Give the box a headline', 'Postmatic')), $this->input(array('type' => 'text', 'name' => 'optins_inpost_title'), $values), html('h4', __('Add some text inviting your users to subscribe', 'Postmatic')), $this->input(array('type' => 'textarea', 'label' => 'd', 'name' => 'optins_inpost_desc'), $values)), html('div id="inpost-ids"', $this->input(array('type' => 'text', 'name' => 'optins_inpost_ids', 'value' => 'all'), $values), __('IDs (comma separated) of posts to show in. Or use "all" to use on all posts.', 'Postmatic')), $this->theme_chooser_html('inpost-theme', 'optins_inpost_theme', __('Choose a theme. This controls how the form looks on your site.', 'Postmatic'), $values), html('div id="inpost-image" class="optin-image"', html('h3', __('Choose an image to display on the left side of your form.', 'Postmatic')), html('p', sprintf(__('We haven\'t built our image chooser yet but have created 8 different icons for you to use (or you can upload your own). <a href="%s" target="_blank">Download them here</a> and add the ones you like to your media library (below). In the future just search your media library for the word <em>Postmatic</em>.', 'Postmatic'), Prompt_Core::$url_path . '/media/optins/postmatic-optin-icons.zip')), html('img', array('src' => $inpost_image->url()))), $this->input(array('name' => 'optins_inpost_image', 'type' => 'hidden'), $values), html('input class="button" type="button" name="optins_inpost_image_button"', array('value' => __('Change', 'Postmatic'))), html('input class="button" type="button" name="optins_inpost_image_reset_button"', array('value' => __('Reset', 'Postmatic'))));
     $content = $this->table_wrap(implode('', $rows));
     return $this->form_wrap($content) . $this->footer();
 }
예제 #3
0
 /**
  * The current site icon URL.
  *
  * @since 2.0.0
  *
  * @return string
  */
 public static function url()
 {
     $url = get_site_icon_url(64);
     if ($url) {
         return $url;
     }
     $attachment_image = new Prompt_Attachment_Image(Prompt_Core::$options->get('site_icon'));
     $url = $attachment_image->url();
     if ($url) {
         return $url;
     }
     return path_join(Prompt_Core::$url_path, 'media/prompt-site-icon-64.png');
 }
예제 #4
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;
 }
예제 #5
0
 /**
  * Get the custom image URL for a type if set
  *
  * @param string $type
  * @return string Empty string if not set
  */
 protected static function get_custom_image_url($type)
 {
     $option_name = 'optins_' . $type . '_image';
     $options = self::optins_options();
     if (empty($options[$option_name])) {
         return '';
     }
     $image = new Prompt_Attachment_Image($options[$option_name]);
     return $image->url();
 }