/**
         * 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 
        }
        /**
         * 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>';
            */
        }
Ejemplo n.º 3
0
 /**
  * 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);
     }
 }
Ejemplo n.º 4
0
 /**
  * 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];
     }
 }