Code Duplication    Length = 124-124 lines in 2 locations

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

@@ 16-139 (lines=124) @@
13
 *
14
 * @extends WP_Widget
15
 */
16
class HomesSearchWidget 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_search',
28
			__( 'Homes Search', 're-pro' ),
29
			array(
30
				'description' => __( 'Display a search box from Homes.com', 're-pro' ),
31
				'classname'   => 're-pro re-pro-widget homes-widget homes-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
		$sale = ! empty( $instance['sale'] ) ? $instance['sale'] : '';
51
		$rent = ! empty( $instance['rent'] ) ? $instance['rent'] : '';
52
53
		echo $args['before_widget'];
54
55
		echo $args['before_title'] . esc_attr( $title ) . $args['after_title'];
56
57
		$homes_widgets = new HomesWidgets();
58
59
		$homes_widgets->get_search( $iframe_id, $location, $color, $sale, $rent );
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
			'location' => '',
77
			'color' => '0054a0',
78
			'sale' => 1,
79
			'rent' => 1,
80
		) );
81
82
		// Retrieve an existing value from the database.
83
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
84
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
85
		$color = ! empty( $instance['color'] ) ? $instance['color'] : '';
86
		$sale = ! empty( $instance['sale'] ) ? $instance['sale'] : '';
87
		$rent = ! empty( $instance['rent'] ) ? $instance['rent'] : '';
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' ) . '" name="' . $this->get_field_name( 'location' ) . '" value="' . $location . '" class="widefat">';
99
		echo '</p>';
100
101
		// Color.
102
		echo '<p>';
103
		echo '	<label for="' . $this->get_field_id( 'color' ) . '" class="title-label">' . __( 'Color:', 're-pro' ) . '</label>';
104
		echo '	<input id="' . $this->get_field_id( 'color' ) . '" name="' . $this->get_field_name( 'color' ) . '" value="' . $color  . '" class="widefat">';
105
		echo '</p>';
106
107
		// Search Types.
108
		echo '<p>';
109
		echo '<label for="search-type" class="search_type_label">' . __( 'Search Types:', 're-pro' ) . '</label>';
110
		echo '<br />';
111
		echo '<input value="1" type="checkbox"' . checked( $sale, 1, false ) . 'id="' . $this->get_field_id( 'sale' ) . '" name="' . $this->get_field_name( 'sale' )  . '" />';
112
		echo '<label for="' . $this->get_field_id( 'sale' ) . '">For Sale</label>';
113
		echo '<br />';
114
		echo '<input value="1" type="checkbox"' . checked( $rent, 1, false ) . 'id="' . $this->get_field_id( 'rent' ) . '" name="' . $this->get_field_name( 'rent' ) . '" />';
115
		echo '<label for="' . $this->get_field_id( 'rent' ) . '">For Rent</label>';
116
		echo '</p>';
117
	}
118
119
	/**
120
	 * Update Widget Instance.
121
	 *
122
	 * @access public
123
	 * @param mixed $new_instance New Instance.
124
	 * @param mixed $old_instance Old Instance.
125
	 * @return $instance
126
	 */
127
	public function update( $new_instance, $old_instance ) {
128
129
		$instance = $old_instance;
130
131
		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
132
		$instance['location'] = ! empty( $new_instance['location'] ) ? strip_tags( $new_instance['location'] ) : '';
133
		$instance['color'] = ! empty( $new_instance['color'] ) ? strip_tags( $new_instance['color'] ) : '';
134
		$instance['sale'] = ! empty( $new_instance['sale'] ) ? strip_tags( $new_instance['sale'] ) : '';
135
		$instance['rent'] = ! empty( $new_instance['rent'] ) ? strip_tags( $new_instance['rent'] ) : '';
136
137
		return $instance;
138
	}
139
}
140
141
/**
142
 * Register Homes.com Featured Listings Widget.

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

@@ 16-139 (lines=124) @@
13
 *
14
 * @extends WP_Widget
15
 */
16
class HomesSimpleSearchWidget 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_simple_search',
28
			__( 'Homes Real Estate Search', 're-pro' ),
29
			array(
30
				'description' => __( 'Display a simple search box from Homes.com', 're-pro' ),
31
				'classname'   => 're-pro re-pro-widget homes-widget homes-simple-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
		$sale = ! empty( $instance['sale'] ) ? $instance['sale'] : '';
51
		$rent = ! empty( $instance['rent'] ) ? $instance['rent'] : '';
52
53
		echo $args['before_widget'];
54
55
		echo $args['before_title'] . esc_attr( $title ) . $args['after_title'];
56
57
		$homes_widgets = new HomesWidgets();
58
59
		$homes_widgets->get_simple_search( $iframe_id, $location, $color, $sale, $rent );
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
			'location' => '',
77
			'color' => '0054a0',
78
			'sale' => 1,
79
			'rent' => 1,
80
		) );
81
82
		// Retrieve an existing value from the database.
83
		$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
84
		$location = ! empty( $instance['location'] ) ? $instance['location'] : '';
85
		$color = ! empty( $instance['color'] ) ? $instance['color'] : '';
86
		$sale = ! empty( $instance['sale'] ) ? $instance['sale'] : '';
87
		$rent = ! empty( $instance['rent'] ) ? $instance['rent'] : '';
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' ) . '" name="' . $this->get_field_name( 'location' ) . '" value="' . $location . '" class="widefat">';
99
		echo '</p>';
100
101
		// Color.
102
		echo '<p>';
103
		echo '	<label for="' . $this->get_field_id( 'color' ) . '" class="title-label">' . __( 'Color:', 're-pro' ) . '</label>';
104
		echo '	<input id="' . $this->get_field_id( 'color' ) . '" name="' . $this->get_field_name( 'color' ) . '" value="' . $color  . '" class="widefat">';
105
		echo '</p>';
106
107
		// Search Types.
108
		echo '<p>';
109
		echo '<label for="search-type" class="search_type_label">' . __( 'Search Types:', 're-pro' ) . '</label>';
110
		echo '<br />';
111
		echo '<input value="1" type="checkbox"' . checked( $sale, 1, false ) . 'id="' . $this->get_field_id( 'sale' ) . '" name="' . $this->get_field_name( 'sale' )  . '" />';
112
		echo '<label for="' . $this->get_field_id( 'sale' ) . '">For Sale</label>';
113
		echo '<br />';
114
		echo '<input value="1" type="checkbox"' . checked( $rent, 1, false ) . 'id="' . $this->get_field_id( 'rent' ) . '" name="' . $this->get_field_name( 'rent' ) . '" />';
115
		echo '<label for="' . $this->get_field_id( 'rent' ) . '">For Rent</label>';
116
		echo '</p>';
117
	}
118
119
	/**
120
	 * Update Widget Instance.
121
	 *
122
	 * @access public
123
	 * @param mixed $new_instance New Instance.
124
	 * @param mixed $old_instance Old Instance.
125
	 * @return $instance
126
	 */
127
	public function update( $new_instance, $old_instance ) {
128
129
		$instance = $old_instance;
130
131
		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
132
		$instance['location'] = ! empty( $new_instance['location'] ) ? strip_tags( $new_instance['location'] ) : '';
133
		$instance['color'] = ! empty( $new_instance['color'] ) ? strip_tags( $new_instance['color'] ) : '';
134
		$instance['sale'] = ! empty( $new_instance['sale'] ) ? strip_tags( $new_instance['sale'] ) : '';
135
		$instance['rent'] = ! empty( $new_instance['rent'] ) ? strip_tags( $new_instance['rent'] ) : '';
136
137
		return $instance;
138
	}
139
}
140
141
/**
142
 * Register Homes.com Featured Listings Widget.