/** * 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; } } }
/** * 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 = "<div id='lp_container' class='{$wrapper_class}'>" . $conversion_area . "</div>"; 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; }