post_type != 'landing-page' || is_admin()) || $id != $post->ID ) {
return $content;
}
return lp_main_headline($post, null, true);
}
/**
* Displays landing page content
* @param $content
* @return string
*/
public static function display_landing_page_content($content) {
global $post;
if (!isset($post) || $post->post_type != 'landing-page') {
return $content;
}
$content = Landing_Pages_Variations::get_post_content( $post->ID );
$content = do_shortcode( $content );
if (!defined('LANDING_PAGES_WPAUTOP') || LANDING_PAGES_WPAUTOP === TRUE) {
$content = wpautop($content);
}
return $content;
}
/**
* display conversion area
*/
public static function display_conversion_area($content) {
if ('landing-page' != get_post_type() || is_admin()) {
return $content;
}
global $post;
remove_action('the_content', array( __CLASS__ , 'display_conversion_area' ) , 20 );
$template = Landing_Pages_Variations::get_current_template( $post->ID );
$my_theme = wp_get_theme($template);
if ( !$my_theme->exists() && $template != 'default') {
return $content;
}
$wrapper_class = "";
$position = Landing_Pages_Variations::get_conversion_area_placement( $post->ID );
$conversion_area = lp_conversion_area(null, null, true, true);
$conversion_area = "
" . $conversion_area . "
";
if ($position == 'top') {
$content = $conversion_area . $content;
} else if ($position == 'bottom') {
$content = $content . $conversion_area;
} else if ($position == 'widget') {
$content = $content;
} else {
$conversion_area = str_replace("id='lp_container'", "id='lp_container' class='lp_form_$position' style='float:$position'", $conversion_area);
$content = $conversion_area . $content;
}
return $content;
}
/**
* Detects if landing page & issues the correct template
*/
public static function switch_template( $template ) {
global $wp_query, $post, $query_string;
if (!isset($post) || $post->post_type != "landing-page" || !is_singular("landing-page")) {
return $template;
}
if (post_password_required()) {
$password = apply_filters('landing-pages/password-template' , get_the_password_form());
/* This is for developers who'd like to create their own custom password protection template isntead of using the bland one */
if (file_exists($password)) {
return $password;
} else {
echo $password;
exit;
}
}
/* nextgen gallery support */
if (!defined('NGG_DISABLE_FILTER_THE_CONTENT')) {
define( 'NGG_DISABLE_FILTER_THE_CONTENT' , true );
}
$selected_template = Landing_Pages_Variations::get_current_template( $post->ID );
if (!isset($selected_template) || $selected_template === 'default' ) {
return $template;
}
/* check if inactive theme */
$my_theme = wp_get_theme( $selected_template );
if ($my_theme->exists()) {
return $template;
}
/* check if core template first */
if (file_exists(LANDINGPAGES_PATH . 'templates/' . $selected_template . '/index.php')) {
return LANDINGPAGES_PATH . 'templates/' . $selected_template . '/index.php';
}
/* next check if it is an uploaded template */
else if (file_exists(LANDINGPAGES_UPLOADS_PATH . $selected_template . '/index.php')) {
return LANDINGPAGES_UPLOADS_PATH . $selected_template . '/index.php';
}
/* next check if it is included with a WordPress theme */
else if (file_exists(LANDINGPAGES_THEME_TEMPLATES_PATH . $selected_template . '/index.php')) {
return LANDINGPAGES_THEME_TEMPLATES_PATH . $selected_template . '/index.php';
}
return $template;
}
/**
* load custom CSS & JS
*/
public static function load_custom_js_css() {
global $post;
if ( !isset($post) || 'landing-page' != $post->post_type) {
return;
}
$custom_css_name = Landing_Pages_Variations::prepare_input_id('lp-custom-css');
$custom_js_name =Landing_Pages_Variations::prepare_input_id('lp-custom-js');
$custom_css = Landing_Pages_Variations::get_custom_css( $post->ID );
$custom_js = Landing_Pages_Variations::get_custom_js( $post->ID );
echo "";
if (!stristr($custom_css, '';
} else {
echo $custom_css;
}
if (!stristr($custom_js, '';
} else if (!stristr($custom_js, '';
} else {
echo $custom_js;
}
}
/**
*
* [lp_conversion_area] shortcode support
*
*/
public static function process_conversion_area_shortcode($atts, $content = null) {
extract(shortcode_atts(array('id' => '', 'align' => '' /*'style' => ''*/
), $atts));
$conversion_area = lp_conversion_area($post = null, $content = null, $return = true, $doshortcode = true, $rebuild_attributes = true);
return $conversion_area;
}
/**
*
* [landing-page-conversion] shortcode support
*
*/
public static function process_conversion_shortcode($atts, $content = null) {
extract(shortcode_atts(array(
'id' => '',
'vid' => '0'
), $atts));
/* check do not track flag */
$do_not_track = apply_filters('inbound_analytics_stop_track' , false );
if ( $do_not_track || isset($_SESSION['landing_page_conversions']) && in_array( $id , $_SESSION['landing_page_conversions'] ) ) {
return;
}
Landing_Pages_Variations::record_conversion($id , $vid);
$_SESSION['landing_page_conversions'][] = $id;
}
/**
* Use postback URL to record conversion for landing pages
*/
public static function process_postback_conversion($atts, $content = null) {
if ( !isset($_GET['postback']) ) {
return;
}
if ( !isset($_GET['event']) || $_GET['event'] != 'lp_conversion' ) {
return;
}
$id = $_GET['id'];
$vid = $_GET['vid'];
$salt = md5( $id . AUTH_KEY );
if ( $_GET['salt'] != $salt ) {
return;
}
Landing_Pages_Variations::record_conversion($id , $vid);
_e('success','landing-pages');
exit;
}
/**
* Hides navigation menu on default landing page tempaltes
* @param string $args
* @return string
*/
public static function hide_nav_menu($args = '') {
global $post;
if ( !isset($post) || $post->post_type != 'landing-page') {
return $args;
}
$template_name = Landing_Pages_Variations::get_current_template( $post->ID );
if ($template_name != 'default') {
return $args;
}
$nav_status = get_post_meta($post->ID, 'default-lp_hide_nav', true);
if ($nav_status != 'off' ) {
return $args;
}
if (isset($args['container_class'])) {
$current_class = " " . $args['container_class'];
}
$args['container_class'] = "custom_landing_page_nav{$current_class}";
$args['echo'] = false;
return $args;
}
/**
* Utility method for loading popular 3rd party assets into Landing Page
*/
public static function load_misc_plugin_support() {
/* WP Featherlight */
if (class_exists('WP_Featherlight_Scripts')) {
$wpfl = new WP_Featherlight_Scripts(plugin_dir_url( 'wp-featherlight' ) , '');
$wpfl->load_css();
}
/* easy way for 3rd parties to hook into */
do_action('load_misc_plugin_support');
}
/**
* 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() || !is_singular('landing-page')) {
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');
}
}
new Landing_Pages_Template_Switcher;
/**
* Echos or returns main headline
* @param OBJECT $post
* @param STRING $headline depreciated
* @param bool $return
*/
function lp_main_headline($post = null, $headline = null, $return = false) {
if (!isset($post)) {
global $post;
}
$main_headline = Landing_Pages_Variations::get_main_headline( $post->ID );
if (!$return) {
echo $main_headline;
} else {
return $main_headline;
}
}
/**
* Display conversion area for default template
* @param OBJECT $post
* @param STRING $content
* @param bool $return
* @param bool $doshortcode
* @return null
*/
function lp_conversion_area($post = null, $content = null, $return = false, $doshortcode = true) {
if (!isset($post)) {
global $post;
}
$content = Landing_Pages_Variations::get_conversion_area( $post->ID );
$wrapper_class = lp_discover_important_wrappers($content);
if ($doshortcode) {
$content = do_shortcode($content);
}
$content = apply_filters('lp_conversion_area_post', $content, $post);
if (!$return) {
$content = str_replace('