Code Duplication    Length = 105-106 lines in 2 locations

modules/zillow/widgets/class-expensive-homes-widget.php 1 location

@@ 17-121 (lines=105) @@
14
 *
15
 * @extends WP_Widget
16
 */
17
class ZillowExpensiveHomesWidget 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_expensive_homes_widget',
30
			__( 'Zillow Most Expensive Homes', 're-pro' ),
31
			array(
32
				'description' => __( 'Display the most expensive homes from Zillow.', 're-pro' ),
33
				'classname'   => 're-pro re-pro-widget zillow-widget zillow-widget-expensive-homes',
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
		$type = ! empty( $instance['type'] ) ? $instance['type'] : '';
52
		$size = ! empty( $instance['size'] ) ? $instance['size'] : '';
53
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
54
55
		echo $args['before_widget'];
56
57
		echo $args['before_title'] . esc_attr( $title ) . $args['after_title'];
58
59
60
		$zillow_widgets = new ZillowWidgets();
61
62
		$zillow_widgets->get_expensive_homes_widget( $iframe_id, $location, 'iframe', 'wide' );
63
64
		echo $args['after_widget'];
65
	}
66
67
	/**
68
	 * Form function.
69
	 *
70
	 * @access public
71
	 * @param mixed $instance Instance.
72
	 * @return void
73
	 */
74
	public function form( $instance ) {
75
76
		// Set default values.
77
		$instance = wp_parse_args( (array) $instance, array(
78
			'title' => '',
79
			'type' => 'iframe',
80
			'size' => 'wide',
81
			'location' => 'El Segundo, CA',
82
		));
83
84
		// Retrieve an existing value from the database.
85
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
86
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
87
88
		// Title.
89
		echo '<p>';
90
		echo '	<label for="' . $this->get_field_id( 'title' ) . '" class="title-label">' . __( 'Tile:', 're-pro' ) . '</label>';
91
		echo '	<input id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" value="' . $title  . '" class="widefat">';
92
		echo '</p>';
93
94
		// Location.
95
		echo '<p>';
96
		echo '	<label for="' . $this->get_field_id( 'location' ) . '" class="title-label">' . __( 'Location:', 're-pro' ) . '</label>';
97
		echo '	<input id="' . $this->get_field_id( 'location' ) . '" placeholder="El Segundo, CA" name="' . $this->get_field_name( 'location' ) . '" value="' . $location  . '" class="widefat">';
98
		echo '</p>';
99
100
	}
101
102
	/**
103
	 * Update Widget Instance.
104
	 *
105
	 * @access public
106
	 * @param mixed $new_instance New Instance.
107
	 * @param mixed $old_instance Old Instance.
108
	 * @return $instance
109
	 */
110
	public function update( $new_instance, $old_instance ) {
111
112
		$instance = $old_instance;
113
114
		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
115
		$instance['type'] = ! empty( $new_instance['type'] ) ? strip_tags( $new_instance['type'] ) : '';
116
		$instance['size'] = ! empty( $new_instance['size'] ) ? strip_tags( $new_instance['size'] ) : '';
117
		$instance['location'] = ! empty( $new_instance['location'] ) ? strip_tags( $new_instance['location'] ) : '';
118
119
		return $instance;
120
	}
121
}
122
123
/**
124
 * Register Zillow Affordability Calculator Widget.

modules/zillow/widgets/class-newest-homes-widget.php 1 location

@@ 17-122 (lines=106) @@
14
 *
15
 * @extends WP_Widget
16
 */
17
class ZillowNewestHomesWidget 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_newest_forsale_homes_widget',
30
			__( 'Zillow Newest For Sale Homes', 're-pro' ),
31
			array(
32
				'description' => __( 'Display the most recent for sale homes from Zillow.', 're-pro' ),
33
				'classname'   => 're-pro re-pro-widget zillow-widget zillow-widget-newest-homes',
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
		$type = ! empty( $instance['type'] ) ? $instance['type'] : '';
52
		$size = ! empty( $instance['size'] ) ? $instance['size'] : '';
53
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
54
55
		echo $args['before_widget'];
56
57
		echo $args['before_title'] . esc_attr( $title ) . $args['after_title'];
58
59
60
		$zillow_widgets = new ZillowWidgets();
61
62
		$zillow_widgets->get_newest_forsale_homes_widget( $iframe_id, $location, 'iframe', 'wide' );
63
64
65
		echo $args['after_widget'];
66
	}
67
68
	/**
69
	 * Form function.
70
	 *
71
	 * @access public
72
	 * @param mixed $instance Instance.
73
	 * @return void
74
	 */
75
	public function form( $instance ) {
76
77
		// Set default values.
78
		$instance = wp_parse_args( (array) $instance, array(
79
			'title' => '',
80
			'type' => 'iframe',
81
			'size' => 'wide',
82
			'location' => 'El Segundo, CA',
83
		));
84
85
		// Retrieve an existing value from the database.
86
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
87
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
88
89
		// Title.
90
		echo '<p>';
91
		echo '	<label for="' . $this->get_field_id( 'title' ) . '" class="title-label">' . __( 'Tile:', 're-pro' ) . '</label>';
92
		echo '	<input id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" value="' . $title  . '" class="widefat">';
93
		echo '</p>';
94
95
		// Location.
96
		echo '<p>';
97
		echo '	<label for="' . $this->get_field_id( 'location' ) . '" class="title-label">' . __( 'Location:', 're-pro' ) . '</label>';
98
		echo '	<input id="' . $this->get_field_id( 'location' ) . '" placeholder="El Segundo, CA" name="' . $this->get_field_name( 'location' ) . '" value="' . $location  . '" class="widefat">';
99
		echo '</p>';
100
101
	}
102
103
	/**
104
	 * Update Widget Instance.
105
	 *
106
	 * @access public
107
	 * @param mixed $new_instance New Instance.
108
	 * @param mixed $old_instance Old Instance.
109
	 * @return $instance
110
	 */
111
	public function update( $new_instance, $old_instance ) {
112
113
		$instance = $old_instance;
114
115
		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
116
		$instance['type'] = ! empty( $new_instance['type'] ) ? strip_tags( $new_instance['type'] ) : '';
117
		$instance['size'] = ! empty( $new_instance['size'] ) ? strip_tags( $new_instance['size'] ) : '';
118
		$instance['location'] = ! empty( $new_instance['location'] ) ? strip_tags( $new_instance['location'] ) : '';
119
120
		return $instance;
121
	}
122
}
123
124
/**
125
 * Register Zillow Affordability Calculator Widget.