function lp_ab_testing_add_tabs() { global $post; $post_type_is = get_post_type($post->ID); $permalink = get_permalink($post->ID); // Only show lp tabs on landing pages post types (for now) if ($post_type_is === "landing-page") { $current_variation_id = lp_ab_testing_get_current_variation_id(); if (isset($_GET['new_meta_key']) && is_numeric($_GET['new_meta_key'])) { $current_variation_id = $_GET['new_meta_key']; } echo "<input type='hidden' id='open_variation' value='{$current_variation_id}'>"; $variations = get_post_meta($post->ID, 'lp-ab-variations', true); $array_variations = explode(',', $variations); $variations = array_filter($array_variations, 'is_numeric'); sort($array_variations, SORT_NUMERIC); $lid = end($array_variations); $new_variation_id = $lid + 1; if ($current_variation_id > 0 || isset($_GET['new-variation'])) { $first_class = 'inactive'; } else { $first_class = 'active'; } echo '<h2 class="nav-tab-wrapper a_b_tabs">'; echo '<a href="?post=' . $post->ID . '&lp-variation-id=0&action=edit" class="lp-ab-tab nav-tab nav-tab-special-' . $first_class . '" id="tabs-0">A</a>'; $var_id_marker = 1; foreach ($array_variations as $i => $vid) { if ($vid != 0) { $letter = lp_ab_key_to_letter($vid); //alert (variation.new_variation); if ($current_variation_id == $vid && !isset($_GET['new-variation'])) { $cur_class = 'active'; } else { $cur_class = 'inactive'; } echo '<a href="?post=' . $post->ID . '&lp-variation-id=' . $vid . '&action=edit" class="lp-nav-tab nav-tab nav-tab-special-' . $cur_class . '" id="tabs-add-variation">' . $letter . '</a>'; } } if (!isset($_GET['new-variation'])) { echo '<a href="?post=' . $post->ID . '&lp-variation-id=' . $new_variation_id . '&action=edit&new-variation=1" class="lp-nav-tab nav-tab nav-tab-special-inactive nav-tab-add-new-variation" id="tabs-add-variation">Add New Variation</a>'; } else { $variation_count = count($array_variations); $letter = lp_ab_key_to_letter($variation_count); echo '<a href="?post=' . $post->ID . '&lp-variation-id=' . $new_variation_id . '&action=edit" class="lp-nav-tab nav-tab nav-tab-special-active" id="tabs-add-variation">' . $letter . '</a>'; } $edit_link = isset($_GET['lp-variation-id']) ? '?lp-variation-id=' . $_GET['lp-variation-id'] . '' : '?lp-variation-id=0'; $post_link = get_permalink($post->ID); $post_link = preg_replace('/\\?.*/', '', $post_link); echo "<a rel='" . $post_link . "' id='launch-visual-editer' class='button-primary new-save-lp-frontend' href='{$post_link}{$edit_link}&template-customize=on'>Launch Visual Editor</a>"; echo '</h2>'; } }
static function localize_lead_data() { global $post; $post_id = null; $id_check = false; $page_tracking = 'on'; $search_tracking = 'on'; $comment_tracking = 'on'; $post_type = isset($post) ? get_post_type($post) : null; $current_page = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; $ip_address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0.0'; $lead_id = isset($_COOKIE['wp_lead_id']) ? $_COOKIE['wp_lead_id'] : false; $lead_email = isset($_COOKIE['wp_lead_email']) ? $_COOKIE['wp_lead_email'] : false; $lead_uid = isset($_COOKIE['wp_lead_uid']) ? $_COOKIE['wp_lead_uid'] : false; $custom_map_values = array(); $custom_map_values = apply_filters('inboundnow_custom_map_values_filter', $custom_map_values); /* Get correct post ID */ global $wp_query; $current_page_id = $wp_query->get_queried_object_id(); $post_id = $current_page_id; $id_check = $post_id != null ? true : false; if (!is_archive() && !$id_check) { $post_id = isset($post) ? $post->ID : false; $id_check = $post_id != null ? true : false; } if (!$id_check) { $post_id = wpl_url_to_postid($current_page); $id_check = $post_id != null ? true : false; } if (!$id_check) { $post_id = wp_leads_get_page_final_id(); $id_check = $post_id != null ? true : false; } /* If page tracking on */ $lead_page_view_tracking = get_option('wpl-main-page-view-tracking', 1); $lead_search_tracking = get_option('wpl-main-search-tracking', 1); $lead_comment_tracking = get_option('wpl-main-comment-tracking', 1); if (!$lead_search_tracking) { $search_tracking = 'off'; } if (!$lead_comment_tracking) { $comment_tracking = 'off'; } if (!$lead_page_view_tracking) { $page_tracking = 'off'; } /* Localize lead data */ $lead_data_array = array(); $lead_data_array['lead_id'] = $lead_id ? $lead_id : null; $lead_data_array['lead_email'] = $lead_email ? $lead_email : null; $lead_data_array['lead_uid'] = $lead_uid ? $lead_uid : null; $time = current_time('timestamp', 0); /* Current wordpress time from settings */ $wordpress_date_time = date("Y/m/d G:i:s", $time); $inbound_track_include = get_option('wpl-main-tracking-ids'); $inbound_track_exclude = get_option('wpl-main-exclude-tracking-ids'); /* get variation id */ if (class_exists('Landing_Pages_Variations')) { $variation = Landing_Pages_Variations::get_current_variation_id(); } else { if (function_exists('lp_ab_testing_get_current_variation_id')) { $variation = lp_ab_testing_get_current_variation_id(); } } $variation = isset($variation) ? $variation : 0; $inbound_localized_data = array('post_id' => $post_id, 'variation_id' => $variation, 'ip_address' => $ip_address, 'wp_lead_data' => $lead_data_array, 'admin_url' => admin_url('admin-ajax.php'), 'track_time' => $wordpress_date_time, 'post_type' => $post_type, 'page_tracking' => $page_tracking, 'search_tracking' => $search_tracking, 'comment_tracking' => $comment_tracking, 'custom_mapping' => $custom_map_values, 'inbound_track_exclude' => $inbound_track_exclude, 'inbound_track_include' => $inbound_track_include, 'is_admin' => current_user_can('manage_options')); return apply_filters('inbound_analytics_localized_data', $inbound_localized_data); }
function lp_ab_testing_alter_content_area($content) { global $post; if (!isset($post) || $post->post_type != 'landing-page') { return $content; } $variation_id = lp_ab_testing_get_current_variation_id(); if ($variation_id > 0) { $content = do_shortcode(get_post_meta($post->ID, 'content-' . $variation_id, true)); } return $content; }