public static function generate_form_content($optin_id, $page_id, $pagename = '', $details = array()) { if (empty($details)) { $all_optins = RAD_Rapidology::get_rapidology_options(); $details = $all_optins[$optin_id]; } if (isset($_COOKIE['hubspotutk'])) { $hubspot_cookie = $_COOKIE['hubspotutk']; } else { $hubspot_cookie = ''; } //unsetting uneeded array elements $details['image_url'] = null; $hide_img_mobile_class = isset($details['hide_mobile']) && '1' == $details['hide_mobile'] ? 'rad_rapidology_hide_mobile' : ''; $image_animation_class = isset($details['image_animation']) ? esc_attr(' rad_rapidology_image_' . $details['image_animation']) : 'rad_rapidology_image_no_animation'; $image_class = $hide_img_mobile_class . $image_animation_class . ' rad_rapidology_image'; // Translate all strings if WPML is enabled if (function_exists('icl_translate')) { $optin_title = ''; $optin_message = icl_translate('rapidology', 'optin_message_' . $optin_id, $details['optin_message']); $email_text = icl_translate('rapidology', 'email_text_' . $optin_id, $details['email_text']); $first_name_text = ''; $single_name_text = ''; $last_name_text = ''; $button_text = icl_translate('rapidology', 'button_text_' . $optin_id, $details['button_text']); $success_text = icl_translate('rapidology', 'success_message_' . $optin_id, $details['success_message']); $footer_text = ''; } else { $optin_title = ''; $optin_message = $details['optin_message']; $email_text = $details['email_text']; $first_name_text = ''; $single_name_text = ''; $last_name_text = ''; $button_text = $details['button_text']; $success_text = $details['success_message']; $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="rad_rapidology_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(' %14$s <div class="rad_rapidology_rapidbar_form_container_wrapper clearfix"> <div class="rad_rapidology_rapidbar_header_outer"> <div class="rad_rapidology_rapidbar_form_header%13$s"> %3$s %4$s <div class="rad_rapidology_success_container"> <h2 class="rad_rapidology_success_message">%9$s</h2> </div> </div> </div> <div class="rad_rapidology_rapidbar_form_content%6$s%7$s%12$s"%11$s> %8$s %10$s </div> </div> %15$s', ('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'], 'rapidology_image', false, array('class' => $image_class))) : '', '' !== $formatted_message ? sprintf('<div class="rad_rapidology_form_text"> %1$s </div>', 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'], 'rapidology_image', false, array('class' => $image_class))) : '', 'no_name' == $details['name_fields'] && !RAD_Rapidology::is_only_name_support($details['email_provider']) || RAD_Rapidology::is_only_name_support($details['email_provider']) && $is_single_name ? ' rad_rapidology_1_field' : sprintf(' rad_rapidology_%1$s_fields', 'first_last_name' == $details['name_fields'] && !RAD_Rapidology::is_only_name_support($details['email_provider']) ? '3' : '2'), 'inline' == $details['field_orientation'] && 'bottom' == $details['form_orientation'] && 'widget' !== $details['optin_type'] ? ' rad_rapidology_bottom_inline' : '', 'stacked' == $details['field_orientation'] && 'bottom' == $details['form_orientation'] || 'widget' == $details['optin_type'] ? ' rad_rapidology_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="rad_rapidology_rapidbar_input rad_rapidology_subscribe_email %16$s"> <input placeholder="%2$s"> </p> <button data-optin_type="rapidbar" data-optin_id="%4$s" data-service="%5$s" data-list_id="%6$s" data-page_id="%7$s" data-post_name="%12$s" data-cookie="%13$s" data-account="%8$s" data-disable_dbl_optin="%11$s" data-redirect_url="%15$s%17$s" data-success_delay="%18$s" %19$s class="rapidbar_submit_button %14$s%20$s"> <span class="rad_rapidology_subscribe_loader"></span> <span class="rad_rapidology_button_text rad_rapidology_button_text_color_%10$s">%9$s</span> </button> </form>', 'basic_edge' == $details['edge_style'] || '' == $details['edge_style'] ? '' : RAD_Rapidology::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', 'rapidology'), 'no_name' == $details['name_fields'] && !RAD_Rapidology::is_only_name_support($details['email_provider']) || RAD_Rapidology::is_only_name_support($details['email_provider']) && $is_single_name ? '' : sprintf('<p class="rad_rapidology_rapidbar_input rad_rapidology_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', 'rapidology')) : '', 'first_last_name' != $details['name_fields'] ? sprintf('%1$s', '' != $single_name_text ? stripslashes(esc_attr($single_name_text)) : esc_html__('Name', 'rapidology')) : '', 'first_last_name' == $details['name_fields'] && !RAD_Rapidology::is_only_name_support($details['email_provider']) ? sprintf(' <p class="rad_rapidology_rapidbar_input rad_rapidology_subscribe_last"> <input placeholder="%1$s" maxlength="50"> </p>', '' != $last_name_text ? stripslashes(esc_attr($last_name_text)) : esc_html__('Last Name', 'rapidology')) : ''), esc_attr($optin_id), esc_attr($details['email_provider']), esc_attr($details['email_list']), esc_attr($page_id), isset($details['account_name']) ? $details['account_name'] : 'blank', '' != $button_text ? stripslashes(esc_html($button_text)) : esc_html__('SUBSCRIBE!', 'rapidology'), isset($details['button_text_color']) ? esc_attr($details['button_text_color']) : '', isset($details['disable_dbl_optin']) && '1' === $details['disable_dbl_optin'] ? 'disable' : '', esc_attr($pagename), esc_attr($hubspot_cookie), isset($details['enable_redirect_form']) && $details['enable_redirect_form'] == true ? 'rad_rapidology_redirect_page' : 'rad_rapidology_submit_subscription', isset($details['enable_redirect_form']) && $details['enable_redirect_form'] == true ? esc_url($details['redirect_url']) : '', isset($details['enable_redirect_form']) && $details['enable_redirect_form'] == true ? 'hidden_item' : '', isset($details['success_url']) ? esc_url($details['success_url']) : '', isset($details['success_load_delay']) ? esc_attr($details['success_load_delay']) : '', isset($details['rapidbar_popup']) && $details['rapidbar_popup'] != 'nopopup' ? sprintf('data-popup_id = %1$s', $details['rapidbar_popup']) : '', isset($details['display_as_link']) && $details['display_as_link'] == true ? ' btnaslink_' . $details['button_text_color'] . '' : ''), '' != $success_text ? stripslashes(esc_html($success_text)) : esc_html__('You have Successfully Subscribed!', 'rapidology'), $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'] ? ' rad_rapidology_custom_html_form' : '', isset($details['header_text_color']) ? sprintf(' rad_rapidology_header_text_%1$s', esc_attr($details['header_text_color'])) : ' rad_rapidology_header_text_dark', self::get_power_button($details['header_text_color']), isset($details['allow_dismiss']) && $details['allow_dismiss'] == '1' ? sprintf('<div class="close_ctr"><span class="rad_rapidology_close_button %1$s"></span></div>', esc_attr($details['header_text_color'])) : ''); return $output; }
/** * Creates Aweber account using the data saved to plugin's database. * @return object or false */ function get_aweber_account($name) { if (!class_exists('AWeberAPI')) { require_once get_template_directory() . '/includes/subscription/aweber/aweber_api.php'; } $options_array = RAD_Rapidology::get_rapidology_options(); $account = false; if (isset($options_array['accounts']['aweber'][$name])) { $consumer_key = $options_array['accounts']['aweber'][$name]['consumer_key']; $consumer_secret = $options_array['accounts']['aweber'][$name]['consumer_secret']; $access_key = $options_array['accounts']['aweber'][$name]['access_key']; $access_secret = $options_array['accounts']['aweber'][$name]['access_secret']; try { // Aweber requires curl extension to be enabled if (!function_exists('curl_init')) { return false; } $aweber = new AWeberAPI($consumer_key, $consumer_secret); if (!$aweber) { return false; } $account = $aweber->getAccount($access_key, $access_secret); } catch (Exception $exc) { return false; } } return $account; }
/** * Adds appropriate actions for Flyin, Popup, Below Content to wp_footer, * Adds custom_css function to wp_head * Adds trigger_bottom_mark to the_content filter for Flyin and Popup * Creates arrays with optins for for Flyin, Popup, Below Content to improve the performance during forms displaying */ function frontend_register_locations() { $options_array = RAD_Rapidology::get_rapidology_options(); if (!is_admin() && !empty($options_array)) { add_action('wp_head', array($this, 'set_custom_css')); $flyin_count = 0; $popup_count = 0; $below_count = 0; $after_comment = 0; $after_purchase = 0; $rapidbar_count = 0; foreach ($options_array as $optin_id => $details) { if ('accounts' !== $optin_id) { if (isset($details['optin_status']) && 'active' === $details['optin_status'] && empty($details['child_of'])) { switch ($details['optin_type']) { case 'flyin': if (0 === $flyin_count) { add_action('wp_footer', array($this, "display_flyin")); $flyin_count++; } if (0 === $after_comment && isset($details['comment_trigger']) && true == $details['comment_trigger']) { add_filter('comment_post_redirect', array($this, 'after_comment_trigger')); $after_comment++; } if (0 === $after_purchase && isset($details['purchase_trigger']) && true == $details['purchase_trigger']) { add_action('woocommerce_thankyou', array($this, 'add_purchase_trigger')); $after_purchase++; } $this->flyin_optins[$optin_id] = $details; break; case 'pop_up': if (0 === $popup_count) { add_action('wp_footer', array($this, "display_popup")); $popup_count++; } if (0 === $after_comment && isset($details['comment_trigger']) && true == $details['comment_trigger']) { add_filter('comment_post_redirect', array($this, 'after_comment_trigger')); $after_comment++; } if (0 === $after_purchase && isset($details['purchase_trigger']) && true == $details['purchase_trigger']) { add_action('woocommerce_thankyou', array($this, 'add_purchase_trigger')); $after_purchase++; } $this->popup_optins[$optin_id] = $details; break; case 'below_post': if (0 === $below_count) { add_filter('the_content', array($this, 'display_below_post'), 9999); add_action('woocommerce_after_single_product_summary', array($this, 'display_on_wc_page')); $below_count++; } $this->below_post_optins[$optin_id] = $details; break; case 'rapidbar': if (0 === $rapidbar_count) { add_action('wp_head', array($this, 'display_rapidbar'), 9999); $rapidbar_count++; } $this->rapidbar_optins[$optin_id] = $details; break; } } } } if (0 < $flyin_count || 0 < $popup_count) { add_filter('the_content', array($this, 'trigger_bottom_mark'), 9999); } } }