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); }
/** * Loads preview iframe. Currently disabled. Plans to update @DavidWells */ public static function load_preview_iframe() { $variation_id = Landing_Pages_Variations::get_current_variation_id(); $landing_page_id = $_GET['post_id']; $variations = Landing_Pages_Variations::get_variations($landing_page_id); ?> <link rel="stylesheet" href="<?php echo LANDINGPAGES_URLPATH . 'assets/css/customizer-ab-testing.css'; ?> "/> <style type="text/css"> #variation-list { position: absolute; top: 0px; left: 0px; padding-left: 5px; } #variation-list h3 { text-decoration: none; border-bottom: none; } #variation-list div { display: inline-block; } #current_variation_id, #current-post-id { display: none !important; } </style> <script type="text/javascript"> jQuery(document).ready(function ($) { var current_page = jQuery("#current_variation_id").text(); /* reload the iframe preview page (for option toggles) */ jQuery('.variation-lp').on('click', function (event) { variation_is = jQuery(this).attr("id"); var original_url = jQuery(parent.document).find("#TB_iframeContent").attr("src"); var current_id = jQuery("#current-post-id").text(); someURL = original_url; splitURL = someURL.split('?'); someURL = splitURL[0]; new_url = someURL + "?lp-variation-id=" + variation_is + "&iframe_window=on&post_id=" + current_id; jQuery(parent.document).find("#TB_iframeContent").attr("src", new_url); }); }); </script> <?php }
/** * Display additional documentaiton metabox */ public static function display_additional_resources() { global $post; $variation_id = Landing_Pages_Variations::get_current_variation_id(); $salt = md5($post->ID . AUTH_KEY); ?> <div> <table style='width:100%'> <tr> <td style='width:22%'> <?php _e('Conversion Shortcode', 'landing-pages'); ?> </td> <td> <input type='text' style='width:95%;display:inline;' readonly='readonly' value="[landing-page-conversion id='<?php echo $post->ID; ?> ' vid='<?php echo $variation_id; ?> ']"> <div class="lp_tooltip" title="<?php _e('Instead of depending on Inbound Forms or tracked clicks for conversion tracking, enter this shortcode into your final destination page to manually increment this variation\'s conversion count', 'landing-page'); ?> " ><i class="fa fa-question-circle"></i></div> </td> </tr> <tr> <td> <?php _e('Conversion Callback URL', 'landing-pages'); ?> </td> <td> <input type='text' style='width:95%;display:inline;' readonly='readonly' value="<?php echo add_query_arg(array('postback' => 'true', 'event' => 'lp_conversion', 'id' => $post->ID, 'vid' => $variation_id, 'salt' => $salt), site_url()); ?> "> <div class="lp_tooltip" title="<?php _e('If you would like to use a thrid party event to record a conversion you can use this cusomized callback URL.', 'landing-page'); ?> " ><i class="fa fa-question-circle"></i></div> </td> </tr> </table> </div> <?php }
/** * Loads preview iframe. Currently disabled. Plans to update @DavidWells */ public static function load_preview_iframe() { $variation_id = Landing_Pages_Variations::get_current_variation_id(); $landing_page_id = $_GET['post_id']; $variations = Landing_Pages_Variations::get_variations($landing_page_id); ?> <link rel="stylesheet" href="<?php echo LANDINGPAGES_URLPATH . 'assets/css/customizer-ab-testing.css'; ?> "/> <style type="text/css"> #variation-list { position: absolute; top: 0px; left: 0px; padding-left: 5px; } #variation-list h3 { text-decoration: none; border-bottom: none; } #variation-list div { display: inline-block; } #current_variation_id, #current-post-id { display: none !important; } </style> <script type="text/javascript"> jQuery(document).ready(function ($) { var current_page = jQuery("#current_variation_id").text(); /* reload the iframe preview page (for option toggles) */ jQuery('.variation-lp').on('click', function (event) { variation_is = jQuery(this).attr("id"); var original_url = jQuery(parent.document).find("#TB_iframeContent").attr("src"); var current_id = jQuery("#current-post-id").text(); someURL = original_url; splitURL = someURL.split('?'); someURL = splitURL[0]; new_url = someURL + "?lp-variation-id=" + variation_is + "&iframe_window=on&post_id=" + current_id; jQuery(parent.document).find("#TB_iframeContent").attr("src", new_url); }); }); </script> <?php /* if ($variations[0] === "") { echo '<div id="variation-list" class="no-abtests"><h3>' . __('No A/B Tests running for this page', 'landing-pages') . '</h3>'; } else { echo '<div id="variation-list"><h3>' . __('Variations', 'landing-pages') . ':</h3>'; echo '<div id="current_variation_id">' . $variation_id . '</div>'; } foreach ($variations as $key => $val) { $current_view = ($val == $variation_id) ? 'current-variation-view' : ''; echo "<div class='variation-lp " . $current_view . "' id=" . $val . ">"; echo Landing_Pages_Variations::vid_to_letter( $landing_page_id , $key); /* echo $val; number echo "</div>"; } echo "<span id='current-post-id'>$landing_page_id</span>"; echo '</div>'; */ }
/** * Display additional documentaiton metabox */ public static function display_additional_resources() { global $post; $variation_id = Landing_Pages_Variations::get_current_variation_id(); ?> <div> <table style='width:100%'> <tr> <td> <?php _e('Conversion Shortcode', 'landing-pages'); ?> </td> <td> <input type='text' style='width:95%;display:inline;' readonly='readonly' value="[landing-page-conversion id='<?php echo $post->ID; ?> ' vid='<?php echo $variation_id; ?> ']"> <div class="lp_tooltip" title="<?php _e('Instead of depending on Inbound Forms or tracked clicks for conversion tracking, enter this shortcode into your final destination page to manually increment this variation\'s conversion count', 'landing-page'); ?> " ><i class="fa fa-question-circle"></i></div> </td> </tr> </table> </div> <?php }
/** * Appends current variation id onto a URL * * @param link STRING URL that param will be appended onto * * * @return STRING modified URL. */ public static function append_variation_id_to_url($link) { global $post; if (!isset($post) || $post->post_type != 'landing-pages') { return $link; } $current_variation_id = Landing_Pages_Variations::get_current_variation_id(); $link = add_query_arg(array('inbvid' => $current_variation_id), $link); return $link; }