Example #1
0
 /**
  * How to display the widget on the screen.
  */
 function widget($args, $instance)
 {
     global $wp_query;
     $this_id = $wp_query->post->ID;
     $post = get_post($this_id);
     $this_type = $wp_query->post->post_type;
     if ($this_type == 'landing-page') {
         extract($args);
         $position = Landing_Pages_Variations::get_conversion_area_placement($wp_query->post->ID);
         if ($position == 'widget') {
             $title = apply_filters('widget_title', $instance['title']);
             /* Before widget (defined by themes). */
             echo $before_widget;
             /* Display the widget title if one was input (before and after defined by themes). */
             if ($title) {
                 echo $before_title . $title . $after_title;
             }
             echo "<div id='lp_container' class='inbound-conversion-sidebar'>";
             echo do_shortcode(lp_conversion_area($post, $content = null, $return = true, $doshortcode = false));
             echo "</div>";
             /* After widget (defined by themes). */
             echo $after_widget;
         }
     }
 }
Example #2
0
 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 
        }
    /**
     * Notice to tell people that variation A needs to be save first
     */
    public static function acf5_required()
    {
        global $post;
        $screen = get_current_screen();
        if (!isset($post) || $screen->id == 'landing-pages' || $screen->id == 'edit-landing-page' || $post->post_status != 'publish') {
            return;
        }
        $extension_data = lp_get_extension_data();
        $current_template = Landing_Pages_Variations::get_current_template($post->ID);
        if (defined('ACF_PRO') || !isset($extension_data[$current_template]['info']['data_type']) || $extension_data[$current_template]['info']['data_type'] != 'acf5') {
            return;
        }
        ?>

        <div class="error">
            <p>
                <?php 
        echo sprintf(__('This landing page template requires Inbound Pro Plugin (not available yet) or the %s Inbound Premium Template Support Extension%s to operate. Please download the best available option and activate it as a plugin to continue working with this template.', 'landing-pages'), '<a href="#linkhere">', '</a>');
        ?>
            </p>
        </div>
        <?php 
    }
 /**
  * Remove all base css from the current active wordpress theme in landing pages
  * currently removes all css from wp_head and re-enqueues the admin bar css.
  */
 public static function strip_styles()
 {
     if (is_admin() || 'landing-page' != get_post_type()) {
         return;
     }
     global $post;
     $template = Landing_Pages_Variations::get_current_template($post->ID);
     $my_theme = wp_get_theme($template);
     if ($my_theme->exists() || $template == 'default') {
         return;
     }
     global $wp_styles;
     $registered_scripts = $wp_styles->registered;
     $inbound_white_list = array();
     foreach ($registered_scripts as $handle) {
         if (preg_match("/\\/plugins\\/leads\\//", $handle->src)) {
             /*echo $handle->handle; */
             $inbound_white_list[] = $handle->handle;
         }
         if (preg_match("/\\/plugins\\/cta\\//", $handle->src)) {
             /*echo $handle->handle; */
             $inbound_white_list[] = $handle->handle;
         }
         if (preg_match("/\\/plugins\\/landing-pages\\//", $handle->src)) {
             /*echo $handle->handle; */
             $inbound_white_list[] = $handle->handle;
         }
     }
     $wp_styles->queue = $inbound_white_list;
     wp_enqueue_style('admin-bar');
 }
 /**
  * Save Landing Page
  */
 public static function save_landing_page($landing_page_id)
 {
     global $post;
     if (!isset($post) || $post->post_type != 'landing-page' || wp_is_post_revision($landing_page_id)) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     $variations = Landing_Pages_Variations::get_variations($landing_page_id);
     $variation_id = isset($_REQUEST['lp-variation-id']) ? $_REQUEST['lp-variation-id'] : '0';
     $_SESSION['lp_ab_test_open_variation'] = $variation_id;
     if (!in_array($variation_id, $variations)) {
         $variations[] = $variation_id;
     }
     Landing_Pages_Variations::update_variations($landing_page_id, $variations);
     /* save all post data */
     $ignore_list = array('acf', 'post_status', 'post_type', 'tax_input', 'post_author', 'user_ID', 'post_ID', 'landing-page-myeditor', 'catslist', 'post_title', 'samplepermalinknonce', 'autosavenonce', 'action', 'autosave', 'mm', 'jj', 'aa', 'hh', 'mn', 'ss', '_wp_http_referer', 'lp-variation-id', '_wpnonce', 'originalaction', 'original_post_status', 'referredby', '_wp_original_http_referer', 'meta-box-order-nonce', 'closedpostboxesnonce', 'hidden_post_status', 'hidden_post_password', 'hidden_post_visibility', 'visibility', 'post_password', 'hidden_mm', 'cur_mm', 'hidden_jj', 'cur_jj', 'hidden_aa', 'cur_aa', 'hidden_hh', 'cur_hh', 'hidden_mn', 'cur_mn', 'original_publish', 'save', 'newlanding_page_category', 'newlanding_page_category_parent', '_ajax_nonce-add-landing_page_category', 'lp_lp_custom_fields_nonce', 'post_mime_type', 'ID', 'comment_status', 'ping_status');
     foreach ($_REQUEST as $key => $value) {
         if (in_array($key, $ignore_list)) {
             continue;
         }
         if ($variation_id > 0 && !strstr($key, "-{$variation_id}")) {
             $key = $key . '-' . $variation_id;
         }
         update_post_meta($landing_page_id, $key, $value);
     }
     /* save conversion area */
     if (isset($_REQUEST['landing-page-myeditor'])) {
         $conversion_area = wpautop($_REQUEST['landing-page-myeditor']);
         $conversion_area_key = Landing_Pages_Variations::prepare_input_id('lp-conversion-area', $variation_id);
         update_post_meta($landing_page_id, $conversion_area_key, $conversion_area);
     }
 }
 /**
  *	Check if current post is a landing page using an ACF powered template
  *
  *	@filter acf/location/rule_match/template_id
  *
  *	@returns BOOL declaring if current page is a landing page with an ACF template loaded or not
  */
 public static function load_acf_on_template($allow, $rule, $args)
 {
     global $post;
     if (!isset($post) || $post->post_type != 'landing-page') {
         return $allow;
     }
     $template = Landing_Pages_Variations::get_current_template($args['post_id']);
     if ($template == $rule['value']) {
         return true;
     } else {
         return false;
     }
 }
        /**
         * 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>';
            */
        }
 /**
  * Listens for new lead creation events and if the lead converted on a landing page then capture the conversion
  * @param $data
  */
 public static function record_conversion($data)
 {
     if (!isset($data['page_id'])) {
         return;
     }
     $post = get_post($data['page_id']);
     if ($post) {
         $data['post_type'] = $post->post_type;
     }
     /* this filter is used by Inbound Pro to check if visitor's ip is on a not track list */
     $do_not_track = apply_filters('inbound_analytics_stop_track', false);
     if ($do_not_track) {
         return;
     }
     /* increment conversions for landing pages */
     if (isset($data['post_type']) && $data['post_type'] === 'landing-page') {
         $conversions = Landing_Pages_Variations::get_conversions($data['page_id'], $data['variation']);
         $conversions++;
         Landing_Pages_Variations::set_conversions_count($data['page_id'], $data['variation'], $conversions);
     } else {
         $conversions = Inbound_Content_Statistics::get_conversions_count($data['page_id']);
         $conversions++;
         Inbound_Content_Statistics::set_conversions_count($data['page_id'], $conversions);
     }
     return $data;
 }
 /**
  * Stores click data
  */
 public static function store_click($landing_page_id, $variation_id)
 {
     $conversions = Landing_Pages_Variations::get_conversions($landing_page_id, $variation_id);
     $conversions++;
     Landing_Pages_Variations::set_conversions_count($landing_page_id, $variation_id, $conversions);
 }
 /**
  * Discovers which alphabetic letter should be associated with a given cta's variation id.
  *
  * @param INT $landing_page_id id of call to action
  * @param INT $variation_id id of variation belonging to call to action
  *
  * @return STRING alphebit letter.
  */
 public static function vid_to_letter($landing_page_id, $variation_id)
 {
     $variations = Landing_Pages_Variations::get_variations($landing_page_id);
     $i = 0;
     foreach ($variations as $key => $variation) {
         if ($variation_id == $key) {
             break;
         }
         $i++;
     }
     $alphabet = array(__('A', 'landing-pages'), __('B', 'landing-pages'), __('C', 'landing-pages'), __('D', 'landing-pages'), __('E', 'landing-pages'), __('F', 'landing-pages'), __('G', 'landing-pages'), __('H', 'landing-pages'), __('I', 'landing-pages'), __('J', 'landing-pages'), __('K', 'landing-pages'), __('L', 'landing-pages'), __('M', 'landing-pages'), __('N', 'landing-pages'), __('O', 'landing-pages'), __('P', 'landing-pages'), __('Q', 'landing-pages'), __('R', 'landing-pages'), __('S', 'landing-pages'), __('T', 'landing-pages'), __('U', 'landing-pages'), __('V', 'landing-pages'), __('W', 'landing-pages'), __('X', 'landing-pages'), __('Y', 'landing-pages'), __('Z', 'landing-pages'));
     if (isset($alphabet[$i])) {
         return $alphabet[$i];
     }
 }