/** * Generates the content for the optin. * @return string */ public static function generate_form_content($optin_id, $page_id, $details = array()) { if (empty($details)) { $all_optins = ET_Bloom::get_bloom_options(); $details = $all_optins[$optin_id]; } $hide_img_mobile_class = isset($details['hide_mobile']) && '1' == $details['hide_mobile'] ? 'et_bloom_hide_mobile' : ''; $image_animation_class = isset($details['image_animation']) ? esc_attr(' et_bloom_image_' . $details['image_animation']) : 'et_bloom_image_no_animation'; $image_class = $hide_img_mobile_class . $image_animation_class . ' et_bloom_image'; // Translate all strings if WPML is enabled if (function_exists('icl_translate')) { $optin_title = icl_translate('bloom', 'optin_title_' . $optin_id, $details['optin_title']); $optin_message = icl_translate('bloom', 'optin_message_' . $optin_id, $details['optin_message']); $email_text = icl_translate('bloom', 'email_text_' . $optin_id, $details['email_text']); $first_name_text = icl_translate('bloom', 'name_text_' . $optin_id, $details['name_text']); $single_name_text = icl_translate('bloom', 'single_name_text_' . $optin_id, $details['single_name_text']); $last_name_text = icl_translate('bloom', 'last_name_' . $optin_id, $details['last_name']); $button_text = icl_translate('bloom', 'button_text_' . $optin_id, $details['button_text']); $success_text = icl_translate('bloom', 'success_message_' . $optin_id, $details['success_message']); $footer_text = icl_translate('bloom', 'footer_text_' . $optin_id, $details['footer_text']); } else { $optin_title = $details['optin_title']; $optin_message = $details['optin_message']; $email_text = $details['email_text']; $first_name_text = $details['name_text']; $single_name_text = $details['single_name_text']; $last_name_text = $details['last_name']; $button_text = $details['button_text']; $success_text = $details['success_message']; $footer_text = $details['footer_text']; } $formatted_title = '<h2> </h2>' != $details['optin_title'] ? str_replace(' ', '', $optin_title) : ''; $formatted_message = '' != $details['optin_message'] ? $optin_message : ''; $formatted_footer = '' != $details['footer_text'] ? sprintf('<div class="et_bloom_form_footer"> <p>%1$s</p> </div>', stripslashes(esc_html($footer_text))) : ''; $is_single_name = isset($details['display_name']) && '1' == $details['display_name'] ? false : true; $output = sprintf(' <div class="et_bloom_form_container_wrapper clearfix"> <div class="et_bloom_header_outer"> <div class="et_bloom_form_header%1$s%13$s"> %2$s %3$s %4$s </div> </div> <div class="et_bloom_form_content%5$s%6$s%7$s%12$s"%11$s> %8$s <div class="et_bloom_success_container"> <span class="et_bloom_success_checkmark"></span> </div> <h2 class="et_bloom_success_message">%9$s</h2> %10$s </div> </div> <span class="et_bloom_close_button"></span>', ('right' == $details['image_orientation'] || 'left' == $details['image_orientation']) && 'widget' !== $details['optin_type'] ? sprintf(' split%1$s', 'right' == $details['image_orientation'] ? ' image_right' : '') : '', ('above' == $details['image_orientation'] || 'right' == $details['image_orientation'] || 'left' == $details['image_orientation']) && 'widget' !== $details['optin_type'] || 'above' == $details['image_orientation_widget'] && 'widget' == $details['optin_type'] ? sprintf('%1$s', empty($details['image_url']['id']) ? sprintf('<img src="%1$s" alt="%2$s" %3$s>', esc_attr($details['image_url']['url']), esc_attr(wp_strip_all_tags(html_entity_decode($formatted_title))), '' !== $image_class ? sprintf('class="%1$s"', esc_attr($image_class)) : '') : wp_get_attachment_image($details['image_url']['id'], 'bloom_image', false, array('class' => $image_class))) : '', '' !== $formatted_title || '' !== $formatted_message ? sprintf('<div class="et_bloom_form_text"> %1$s%2$s </div>', stripslashes(html_entity_decode($formatted_title, ENT_QUOTES, 'UTF-8')), stripslashes(html_entity_decode($formatted_message, ENT_QUOTES, 'UTF-8'))) : '', 'below' == $details['image_orientation'] && 'widget' !== $details['optin_type'] || isset($details['image_orientation_widget']) && 'below' == $details['image_orientation_widget'] && 'widget' == $details['optin_type'] ? sprintf('%1$s', empty($details['image_url']['id']) ? sprintf('<img src="%1$s" alt="%2$s" %3$s>', esc_attr($details['image_url']['url']), esc_attr(wp_strip_all_tags(html_entity_decode($formatted_title))), '' !== $image_class ? sprintf('class="%1$s"', esc_attr($image_class)) : '') : wp_get_attachment_image($details['image_url']['id'], 'bloom_image', false, array('class' => $image_class))) : '', 'no_name' == $details['name_fields'] && !ET_Bloom::is_only_name_support($details['email_provider']) || ET_Bloom::is_only_name_support($details['email_provider']) && $is_single_name ? ' et_bloom_1_field' : sprintf(' et_bloom_%1$s_fields', 'first_last_name' == $details['name_fields'] && !ET_Bloom::is_only_name_support($details['email_provider']) ? '3' : '2'), 'inline' == $details['field_orientation'] && 'bottom' == $details['form_orientation'] && 'widget' !== $details['optin_type'] ? ' et_bloom_bottom_inline' : '', 'stacked' == $details['field_orientation'] && 'bottom' == $details['form_orientation'] || 'widget' == $details['optin_type'] ? ' et_bloom_bottom_stacked' : '', 'custom_html' == $details['email_provider'] ? stripslashes(html_entity_decode($details['custom_html'])) : sprintf(' %1$s <form method="post" class="clearfix"> %3$s <p class="et_bloom_popup_input et_bloom_subscribe_email"> <input placeholder="%2$s"> </p> <button data-optin_id="%4$s" data-service="%5$s" data-list_id="%6$s" data-page_id="%7$s" data-account="%8$s" data-disable_dbl_optin="%11$s" class="et_bloom_submit_subscription%12$s"> <span class="et_bloom_subscribe_loader"></span> <span class="et_bloom_button_text et_bloom_button_text_color_%10$s">%9$s</span> </button> </form>', 'basic_edge' == $details['edge_style'] || '' == $details['edge_style'] ? '' : ET_Bloom::get_the_edge_code($details['edge_style'], 'widget' == $details['optin_type'] ? 'bottom' : $details['form_orientation']), '' != $email_text ? stripslashes(esc_attr($email_text)) : esc_html__('Email', 'bloom'), 'no_name' == $details['name_fields'] && !ET_Bloom::is_only_name_support($details['email_provider']) || ET_Bloom::is_only_name_support($details['email_provider']) && $is_single_name ? '' : sprintf('<p class="et_bloom_popup_input et_bloom_subscribe_name"> <input placeholder="%1$s%2$s" maxlength="50"> </p>%3$s', 'first_last_name' == $details['name_fields'] ? sprintf('%1$s', '' != $first_name_text ? stripslashes(esc_attr($first_name_text)) : esc_html__('First Name', 'bloom')) : '', 'first_last_name' != $details['name_fields'] ? sprintf('%1$s', '' != $single_name_text ? stripslashes(esc_attr($single_name_text)) : esc_html__('Name', 'bloom')) : '', 'first_last_name' == $details['name_fields'] && !ET_Bloom::is_only_name_support($details['email_provider']) ? sprintf(' <p class="et_bloom_popup_input et_bloom_subscribe_last"> <input placeholder="%1$s" maxlength="50"> </p>', '' != $last_name_text ? stripslashes(esc_attr($last_name_text)) : esc_html__('Last Name', 'bloom')) : ''), esc_attr($optin_id), esc_attr($details['email_provider']), esc_attr($details['email_list']), esc_attr($page_id), esc_attr($details['account_name']), '' != $button_text ? stripslashes(esc_html($button_text)) : esc_html__('SUBSCRIBE!', 'bloom'), isset($details['button_text_color']) ? esc_attr($details['button_text_color']) : '', isset($details['disable_dbl_optin']) && '1' === $details['disable_dbl_optin'] ? 'disable' : '', 'locked' === $details['optin_type'] ? ' et_bloom_submit_subscription_locked' : ''), '' != $success_text ? html_entity_decode(wp_kses(stripslashes($success_text), array('a' => array(), 'br' => array(), 'span' => array(), 'strong' => array()))) : esc_html__('You have Successfully Subscribed!', 'bloom'), $formatted_footer, 'custom_html' == $details['email_provider'] ? sprintf(' data-optin_id="%1$s" data-service="%2$s" data-list_id="%3$s" data-page_id="%4$s" data-account="%5$s"', esc_attr($optin_id), 'custom_form', 'custom_form', esc_attr($page_id), 'custom_form') : '', 'custom_html' == $details['email_provider'] ? ' et_bloom_custom_html_form' : '', isset($details['header_text_color']) ? sprintf(' et_bloom_header_text_%1$s', esc_attr($details['header_text_color'])) : ' et_bloom_header_text_dark'); return $output; }