Code Duplication    Length = 117-118 lines in 2 locations

modules/homes-com/widgets/class-featured-listings-widget.php 1 location

@@ 16-133 (lines=118) @@
13
 *
14
 * @extends WP_Widget
15
 */
16
class HomesFeaturedListingsWidget extends WP_Widget {
17
18
	/**
19
	 * __construct function.
20
	 *
21
	 * @access public
22
	 * @return void
23
	 */
24
	public function __construct() {
25
26
		parent::__construct(
27
			'homes_featured_listings',
28
			__( 'Homes Featured Listings', 're-pro' ),
29
			array(
30
				'description' => __( 'Display featured listings from Homes.com', 're-pro' ),
31
				'classname'   => 're-pro re-pro-widget homes-widget homes-featured-listings',
32
				'customize_selective_refresh' => true,
33
			)
34
		);
35
	}
36
37
	/**
38
	 * Widget function.
39
	 *
40
	 * @access public
41
	 * @param mixed $args Arguments.
42
	 * @param mixed $instance Instance.
43
	 */
44
	public function widget( $args, $instance ) {
45
46
		$iframe_id = ! empty( $args['widget_id'] ) ? $args['widget_id'] : '';
47
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
48
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
49
		$color = ! empty( $instance['color'] ) ? $instance['color'] : '';
50
		$status = ! empty( $instance['status'] ) ? $instance['status'] : '';
51
52
		echo $args['before_widget'];
53
54
		echo $args['before_title'] . esc_attr( $title ) . $args['after_title'];
55
56
		$homes_widgets = new HomesWidgets();
57
58
		$homes_widgets->get_featured_listings( $iframe_id, $location, $color, $status );
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
			'location' => '',
76
			'color' => '0054a0',
77
			'status' => 'SALE',
78
		) );
79
80
		// Retrieve an existing value from the database.
81
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
82
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
83
		$color = ! empty( $instance['color'] ) ? $instance['color'] : '';
84
		$status = ! empty( $instance['status'] ) ? $instance['status'] : '';
85
86
		// Title.
87
		echo '<p>';
88
		echo '	<label for="' . $this->get_field_id( 'title' ) . '" class="title-label">' . __( 'Tile:', 're-pro' ) . '</label>';
89
		echo '	<input id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" value="' . $title  . '" class="widefat">';
90
		echo '</p>';
91
92
		// Location.
93
		echo '<p>';
94
		echo '	<label for="' . $this->get_field_id( 'location' ) . '" class="title-label">' . __( 'Location:', 're-pro' ) . '</label>';
95
		echo '	<input id="' . $this->get_field_id( 'location' ) . '" name="' . $this->get_field_name( 'location' ) . '" value="' . $location . '" class="widefat">';
96
		echo '</p>';
97
98
		// Text Color
99
		echo '<p>';
100
		echo '	<label for="' . $this->get_field_id( 'color' ) . '" class="title-label">' . __( 'Button Color:', 're-pro' ) . '</label>';
101
		echo '	<input id="' . $this->get_field_id( 'color' ) . '" name="' . $this->get_field_name( 'color' ) . '" value="' . $color  . '" class="widefat">';
102
		echo '</p>';
103
104
		// Listing Status
105
		echo '<p>';
106
		echo '	<label for="' . $this->get_field_id( 'status' ) . '" class="title-label">' . __( 'Listing Status:', 're-pro' ) . '</label>';
107
		echo '	<br />';
108
		echo '	<input id="' . $this->get_field_id( 'status' ) . '" type="radio" name="' . $this->get_field_name( 'status' ) . '" value="SALE"' . checked( $status, 'SALE', false ) . '>For Sale<br />' . "\n";
109
		echo '	<input id="' . $this->get_field_id( 'status' ) . '" type="radio" name="' . $this->get_field_name( 'status' ) . '" value="RENT"' . checked( $status, 'RENT', false ) . '>For Rent<br />' . "\n";
110
		echo '</p>';
111
112
	}
113
114
	/**
115
	 * Update Widget Instance.
116
	 *
117
	 * @access public
118
	 * @param mixed $new_instance New Instance.
119
	 * @param mixed $old_instance Old Instance.
120
	 * @return $instance
121
	 */
122
	public function update( $new_instance, $old_instance ) {
123
124
		$instance = $old_instance;
125
126
		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
127
		$instance['location'] = ! empty( $new_instance['location'] ) ? strip_tags( $new_instance['location'] ) : '';
128
		$instance['color'] = ! empty( $new_instance['color'] ) ? strip_tags( $new_instance['color'] ) : '';
129
		$instance['status'] = ! empty( $new_instance['status'] ) ? strip_tags( $new_instance['status'] ) : '';
130
131
		return $instance;
132
	}
133
}
134
135
/**
136
 * Register Homes.com Featured Listings Widget.

modules/homes-com/widgets/class-tall-search-widget.php 1 location

@@ 16-132 (lines=117) @@
13
 *
14
 * @extends WP_Widget
15
 */
16
class HomesTallSearchWidget extends WP_Widget {
17
18
	/**
19
	 * __construct function.
20
	 *
21
	 * @access public
22
	 * @return void
23
	 */
24
	public function __construct() {
25
26
		parent::__construct(
27
			'homes_tall_search',
28
			__( 'Homes Real Estate Search - Tall', 're-pro' ),
29
			array(
30
				'description' => __( 'Display a tall search box from Homes.com', 're-pro' ),
31
				'classname'   => 're-pro re-pro-widget homes-widget homes-tall-search',
32
				'customize_selective_refresh' => true,
33
			)
34
		);
35
	}
36
37
	/**
38
	 * Widget function.
39
	 *
40
	 * @access public
41
	 * @param mixed $args Arguments.
42
	 * @param mixed $instance Instance.
43
	 */
44
	public function widget( $args, $instance ) {
45
46
		$iframe_id = ! empty( $args['widget_id'] ) ? $args['widget_id'] : '';
47
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
48
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
49
		$color = ! empty( $instance['color'] ) ? $instance['color'] : '';
50
		$status = ! empty( $instance['status'] ) ? $instance['status'] : '';
51
52
		echo $args['before_widget'];
53
54
		echo $args['before_title'] . esc_attr( $title ) . $args['after_title'];
55
56
		$homes_widgets = new HomesWidgets();
57
58
		$homes_widgets->get_tall_search( $iframe_id, $location, $color, $status );
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
			'location' => '',
76
			'color' => '0054a0',
77
			'status' => 'FOR SALE',
78
		) );
79
80
		// Retrieve an existing value from the database.
81
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
82
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
83
		$color = ! empty( $instance['color'] ) ? $instance['color'] : '';
84
		$status = ! empty( $instance['status'] ) ? $instance['status'] : '';
85
86
		// Title.
87
		echo '<p>';
88
		echo '	<label for="' . $this->get_field_id( 'title' ) . '" class="title-label">' . __( 'Tile:', 're-pro' ) . '</label>';
89
		echo '	<input id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" value="' . $title  . '" class="widefat">';
90
		echo '</p>';
91
92
		// Location.
93
		echo '<p>';
94
		echo '	<label for="' . $this->get_field_id( 'location' ) . '" class="title-label">' . __( 'Location:', 're-pro' ) . '</label>';
95
		echo '	<input id="' . $this->get_field_id( 'location' ) . '" name="' . $this->get_field_name( 'location' ) . '" value="' . $location . '" class="widefat">';
96
		echo '</p>';
97
98
		// Color.
99
		echo '<p>';
100
		echo '	<label for="' . $this->get_field_id( 'color' ) . '" class="title-label">' . __( 'Color:', 're-pro' ) . '</label>';
101
		echo '	<input id="' . $this->get_field_id( 'color' ) . '" name="' . $this->get_field_name( 'color' ) . '" value="' . $color  . '" class="widefat">';
102
		echo '</p>';
103
104
		// Listing Status.
105
		echo '<p>';
106
		echo '	<label for="' . $this->get_field_id( 'status' ) . '" class="title-label">' . __( 'Search Types:', 're-pro' ) . '</label>';
107
		echo '	<br />';
108
		echo '	<input id="' . $this->get_field_id( 'status' ) . '" type="radio" name="' . $this->get_field_name( 'status' ) . '" value="FOR SALE"' . checked( $status, 'FOR SALE', false ) . '>For Sale<br />' . "\n";
109
		echo '	<input id="' . $this->get_field_id( 'status' ) . '" type="radio" name="' . $this->get_field_name( 'status' ) . '" value="FOR RENT"' . checked( $status, 'FOR RENT', false ) . '>For Rent<br />' . "\n";
110
		echo '</p>';
111
	}
112
113
	/**
114
	 * Update Widget Instance.
115
	 *
116
	 * @access public
117
	 * @param mixed $new_instance New Instance.
118
	 * @param mixed $old_instance Old Instance.
119
	 * @return $instance
120
	 */
121
	public function update( $new_instance, $old_instance ) {
122
123
		$instance = $old_instance;
124
125
		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
126
		$instance['location'] = ! empty( $new_instance['location'] ) ? strip_tags( $new_instance['location'] ) : '';
127
		$instance['color'] = ! empty( $new_instance['color'] ) ? strip_tags( $new_instance['color'] ) : '';
128
		$instance['status'] = ! empty( $new_instance['status'] ) ? strip_tags( $new_instance['status'] ) : '';
129
130
		return $instance;
131
	}
132
}
133
134
/**
135
 * Register Homes.com Featured Listings Widget.