Code Duplication    Length = 92-93 lines in 2 locations

modules/zillow/widgets/class-affordability-calc-widget.php 1 location

@@ 17-109 (lines=93) @@
14
 *
15
 * @extends WP_Widget
16
 */
17
class ZillowAffordabilityCalcWidget extends WP_Widget {
18
19
20
	/**
21
	 * __construct function.
22
	 *
23
	 * @access public
24
	 * @return void
25
	 */
26
	public function __construct() {
27
28
		parent::__construct(
29
			'zillow_affordability_calc_widget',
30
			__( 'Zillow Affordability Calculator', 're-pro' ),
31
			array(
32
				'description' => __( 'Display an Affordability Calculator from Zillow.', 're-pro' ),
33
				'classname'   => 're-pro re-pro-widget zillow-widget zillow-widget-affordability-calculator',
34
				'customize_selective_refresh' => true,
35
			)
36
		);
37
	}
38
39
	/**
40
	 * Widget function.
41
	 *
42
	 * @access public
43
	 * @param mixed $args Arguments.
44
	 * @param mixed $instance Instance.
45
	 * @return void
46
	 */
47
	public function widget( $args, $instance ) {
48
49
		$iframe_id = ! empty( $args['widget_id'] ) ? $args['widget_id'] : '';
50
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
51
52
		echo $args['before_widget'];
53
54
		echo $args['before_title'] . esc_attr( $title ) . $args['after_title'];
55
56
		$zillow_widgets = new ZillowWidgets();
57
58
		return $zillow_widgets->get_affordability_calc_widget( $iframe_id );
59
60
61
		echo $args['after_widget'];
62
	}
63
64
	/**
65
	 * Form function.
66
	 *
67
	 * @access public
68
	 * @param mixed $instance Instance.
69
	 * @return void
70
	 */
71
	public function form( $instance ) {
72
73
		// Set default values.
74
		$instance = wp_parse_args( (array) $instance, array(
75
			'title' => '',
76
			'screenname' => '',
77
			'region' => '',
78
			'textcolor' => '000000',
79
			'zuid' => '',
80
		));
81
82
		// Retrieve an existing value from the database.
83
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
84
85
		// Title.
86
		echo '<p>';
87
		echo '	<label for="' . $this->get_field_id( 'title' ) . '" class="title-label">' . __( 'Tile:', 're-pro' ) . '</label>';
88
		echo '	<input id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" value="' . $title  . '" class="widefat">';
89
		echo '</p>';
90
91
	}
92
93
	/**
94
	 * Update Widget Instance.
95
	 *
96
	 * @access public
97
	 * @param mixed $new_instance New Instance.
98
	 * @param mixed $old_instance Old Instance.
99
	 * @return $instance
100
	 */
101
	public function update( $new_instance, $old_instance ) {
102
103
		$instance = $old_instance;
104
105
		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
106
107
		return $instance;
108
	}
109
}
110
111
/**
112
 * Register Zillow Affordability Calculator Widget.

modules/zillow/widgets/class-monthlypay-calc-widget.php 1 location

@@ 17-108 (lines=92) @@
14
 *
15
 * @extends WP_Widget
16
 */
17
class ZillowMonthlyPaymentCalcWidget extends WP_Widget {
18
19
20
	/**
21
	 * __construct function.
22
	 *
23
	 * @access public
24
	 * @return void
25
	 */
26
	public function __construct() {
27
28
		parent::__construct(
29
			'zillow_monthly_paycalc_widget',
30
			__( 'Zillow Monthly Payment Calculator', 're-pro' ),
31
			array(
32
				'description' => __( 'Display a Monthly Payment Calculator from Zillow.', 're-pro' ),
33
				'classname'   => 're-pro re-pro-widget zillow-widget zillow-widget-monthly-payment-calculator',
34
				'customize_selective_refresh' => true,
35
			)
36
		);
37
	}
38
39
	/**
40
	 * Widget function.
41
	 *
42
	 * @access public
43
	 * @param mixed $args Arguments.
44
	 * @param mixed $instance Instance.
45
	 * @return void
46
	 */
47
	public function widget( $args, $instance ) {
48
49
		$iframe_id = ! empty( $args['widget_id'] ) ? $args['widget_id'] : '';
50
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
51
52
		echo $args['before_widget'];
53
54
		echo $args['before_title'] . esc_attr( $title ) . $args['after_title'];
55
56
		$zillow_widgets = new ZillowWidgets();
57
58
		return $zillow_widgets->get_monthlypay_calc_widget( $iframe_id );
59
60
		echo $args['after_widget'];
61
	}
62
63
	/**
64
	 * Form function.
65
	 *
66
	 * @access public
67
	 * @param mixed $instance Instance.
68
	 * @return void
69
	 */
70
	public function form( $instance ) {
71
72
		// Set default values.
73
		$instance = wp_parse_args( (array) $instance, array(
74
			'title' => '',
75
			'screenname' => '',
76
			'region' => '',
77
			'textcolor' => '000000',
78
			'zuid' => '',
79
		));
80
81
		// Retrieve an existing value from the database.
82
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
83
84
		// Title.
85
		echo '<p>';
86
		echo '	<label for="' . $this->get_field_id( 'title' ) . '" class="title-label">' . __( 'Tile:', 're-pro' ) . '</label>';
87
		echo '	<input id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" value="' . $title  . '" class="widefat">';
88
		echo '</p>';
89
90
	}
91
92
	/**
93
	 * Update Widget Instance.
94
	 *
95
	 * @access public
96
	 * @param mixed $new_instance New Instance.
97
	 * @param mixed $old_instance Old Instance.
98
	 * @return $instance
99
	 */
100
	public function update( $new_instance, $old_instance ) {
101
102
		$instance = $old_instance;
103
104
		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
105
106
		return $instance;
107
	}
108
}
109
110
/**
111
 * Register Zillow Monthly Pay Calc Widget.