Esempio n. 1
0
 /**
  * Deletes variation for    a call to action
  *
  * @param INT $landing_page_id id of call to action
  * @param INT $variation_id id of variation to delete
  *
  */
 public static function delete_variation($landing_page_id, $variation_id)
 {
     $variations = Landing_Pages_Variations::get_variations($landing_page_id);
     /* unset variation */
     if (($key = array_search($variation_id, $variations)) !== false) {
         unset($variations[$key]);
     }
     /* set next variation to be open */
     $current_variation_id = current($variations);
     $_SESSION['lp_ab_test_open_variation'] = $current_variation_id;
     $_GET['lp-variation-id'] = $current_variation_id;
     /* update variations */
     Landing_Pages_Variations::update_variations($landing_page_id, $variations);
     if ($variation_id > 0) {
         $suffix = '-' . $variation_id;
         $len = strlen($suffix);
     } else {
         $suffix = '';
         $len = strlen($suffix);
     }
     /*delete each meta value associated with variation */
     global $wpdb;
     $data = array();
     $wpdb->query("\n\t\t\t\tSELECT `meta_key`, `meta_value`\n\t\t\t\tFROM {$wpdb->postmeta}\n\t\t\t\tWHERE `post_id` = " . $landing_page_id . "\n\t\t\t");
     foreach ($wpdb->last_result as $k => $v) {
         $data[$v->meta_key] = $v->meta_value;
     }
     /*echo $len;exit; */
     foreach ($data as $key => $value) {
         if (substr($key, -$len) == $suffix) {
             delete_post_meta($landing_page_id, $key, $value);
         }
     }
 }
Esempio n. 2
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);
     }
 }