1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101:
<?php
add_action('widgets_init', 'lp_load_widgets');
function lp_load_widgets() {
register_widget('LP_Widget_Conversion_Area');
}
class LP_Widget_Conversion_Area extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'class_LP_Widget_Conversion_Area', 'description' => __('Use this widget on your landing page sidebar. This sidebar replaces the normal sidebar while using your default theme as a template, or other inactive themes as landing page templates.', 'inbound-pro'));
$control_ops = array('width' => 300, 'height' => 350, 'id_base' => 'id_lp_conversion_area_widget');
parent::__construct('id_lp_conversion_area_widget', __('Landing Pages: Conversion Area Widget', 'landing-pages'), $widget_ops, $control_ops);
}
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']);
echo $before_widget;
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>";
echo $after_widget;
}
}
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
function form($instance) {
$defaults = array();
$instance = wp_parse_args((array)$instance, $defaults); ?>
<!-- Widget Title: Text Input -->
<p>
<?php _e("This box will render the landing page conversion area on the 'default' template.", 'landing-pages'); ?>
</p>
<?php
}
}