/** * Display column data * @param $columns * @return array */ public static function display_columns($column) { global $post; if ($post->post_type != 'landing-page') { return; } switch ($column) { case 'ID': echo $post->ID; break; case 'thumbnail-lander': $template = get_post_meta($post->ID, 'lp-selected-template', true); $permalink = get_permalink($post->ID); $datetime = the_modified_date('YmjH', null, null, false); $permalink = $permalink = $permalink . '?dt=' . $datetime; if (in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) { if (file_exists(LANDINGPAGES_UPLOADS_PATH . $template . '/thumbnail.png')) { $thumbnail = LANDINGPAGES_UPLOADS_URLPATH . $template . '/thumbnail.png'; } else { if (file_exists(LANDINGPAGES_UPLOADS_PATH . $template . '/thumbnail.jpg')) { $thumbnail = LANDINGPAGES_UPLOADS_URLPATH . $template . '/thumbnail.jpg'; } else { $thumbnail = LANDINGPAGES_URLPATH . 'templates/' . $template . '/thumbnail.png'; } } } else { $thumbnail = 'http://s.wordpress.com/mshots/v1/' . urlencode(esc_url($permalink)) . '?w=140'; } echo "<a title='" . __('Click to Preview this variation', 'landing-pages') . "' class='thickbox' href='" . $permalink . "?lp-variation-id=0&iframe_window=on&post_id=" . $post->ID . "&TB_iframe=true&width=640&height=703' target='_blank'><img src='" . $thumbnail . "' style='width:155px;height:110px;' title='Click to Preview'></a>"; break; case "stats": self::show_stats(); break; case "impressions": echo self::show_aggregated_stats("impressions"); break; case "actions": echo self::show_aggregated_stats("actions"); break; case "cr": echo self::show_aggregated_stats("cr") . "%"; break; case "template": $template_used = Landing_Pages_Variations::get_current_template($post->ID); echo $template_used; break; } }
/** * 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'); }
/** * Display template preview metabox */ public static function display_template_preview_metabox() { global $post; $template = Landing_Pages_Variations::get_current_template($post->ID); $permalink = Landing_Pages_Variations::get_variation_permalink($post->ID); $datetime = the_modified_date('YmjH', null, null, false); $permalink = add_query_arg(array('dt' => $datetime, 'dont_save' => true), $permalink); ?> <style type="text/css"> <?php /* hide featured image slot if not default template */ if ($template != 'default') { echo '#postimagediv {display:none;}'; } ?> #lp-thumbnail-sidebar-preview { background: transparent !important; } #lp-thumbnail-sidebar-preview .handlediv, #lp-thumbnail-sidebar-preview .hndle { display: none !important; } #lp-thumbnail-sidebar-preview .inside { padding: 0px !important; border: none !important; margin-top: -33px !important; margin-bottom: -10px; overflow:hidden; } #lp-thumbnail-sidebar-preview .zoomer-wrapper { vertical-align: top; margin-top:33px !important; } #lp-thumbnail-sidebar-preview iframe#zoomer { margin-top: -30px; } </style> <?php if (isset($_GET['new-variation'])) { return; } if (isset($_GET['inbound-editor']) && $_GET['inbound-editor'] !== true) { return; } // default echo "<iframe src='{$permalink}' id='zoomer'></iframe>"; }
/** * 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; } }
/** * Returns conversion area placement * @param $landing_page_id * @param null $variation_id */ public static function get_conversion_area_placement($landing_page_id, $variation_id = null) { $template = Landing_Pages_Variations::get_current_template($landing_page_id); return Landing_Pages_Variations::get_setting_value($template . '-conversion-area-placement', $landing_page_id, $variation_id); }