1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
/* Exit if accessed directly. */ |
4
|
|
|
if ( ! defined( 'ABSPATH' ) ) { exit; } |
5
|
|
|
|
6
|
|
|
if ( ! class_exists( 'TruliaWidgets' ) ) { |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* TruliaWidgets class. |
10
|
|
|
*/ |
11
|
|
|
class TruliaWidgets { |
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* __construct function. |
15
|
|
|
* |
16
|
|
|
* @access public |
17
|
|
|
* @return void |
|
|
|
|
18
|
|
|
*/ |
19
|
|
|
public function __construct() { |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* trulia_iframe_css function. |
25
|
|
|
* |
26
|
|
|
* @access public |
27
|
|
|
* @return void |
28
|
|
|
*/ |
29
|
|
|
public function trulia_iframe_css() { |
30
|
|
|
|
31
|
|
|
?> |
32
|
|
|
|
33
|
|
|
<style> |
34
|
|
|
.trulia-iframe { |
35
|
|
|
display:block; |
36
|
|
|
max-width:100%; |
37
|
|
|
} |
38
|
|
|
</style> |
39
|
|
|
|
40
|
|
|
<?php |
41
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Trulia Iframe ID Names. |
46
|
|
|
* |
47
|
|
|
* @access public |
48
|
|
|
* @param string $iframe_id (default: '') |
49
|
|
|
* @return void |
50
|
|
|
*/ |
51
|
|
|
public function trulia_iframe_id( $iframe_id = '' ) { |
52
|
|
|
|
53
|
|
|
if( '' !== $iframe_id ) { |
54
|
|
|
return sanitize_html_class( $iframe_id ) . '-iframe'; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Trulia Iframe Class Names. |
61
|
|
|
* |
62
|
|
|
* @access public |
63
|
|
|
* @param string $widget_name (default: '') |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
|
View Code Duplication |
public function trulia_iframe_class( $widget_name = '' ) { |
|
|
|
|
67
|
|
|
|
68
|
|
|
if( '' !== $widget_name ) { |
69
|
|
|
return 'trulia trulia-iframe trulia-' . sanitize_html_class( $widget_name ) . '-iframe'; |
70
|
|
|
} else { |
71
|
|
|
return 'trulia-iframe'; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* get_community_advice_widget function. |
78
|
|
|
* |
79
|
|
|
* @access public |
80
|
|
|
* @param string $iframe_id (default: '') |
81
|
|
|
* @param mixed $display_answers |
82
|
|
|
* @param mixed $title |
83
|
|
|
* @param string $email (default: '') |
84
|
|
|
* @return void |
85
|
|
|
*/ |
86
|
|
|
public function get_community_advice_widget( $iframe_id = '', $display_answers, $title, $email = '' ) { |
|
|
|
|
87
|
|
|
echo '<iframe id="'. $this->trulia_iframe_id( $iframe_id ) .'" class="'. $this->trulia_iframe_class( 'community-advice' ) .'" src="https://synd.trulia.com/tools/expert-community-advice/embedded?params%5Bwhose_answer%5D=¶ms%5Bdisplay_answers%5D=true¶ms%5Btitle%5D=Expert+Community+Advice¶ms%5Bcolor%5D=grey¶ms%5Bemail%5D=¶ms%5Buser_url%5D=¶ms%5Bwidth%5D=300¶ms%5Bheight%5D=350¶ms%5Bguid%5D=58237a792f772"></iframe>'; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* get_rent_buy_calc_widget function. |
92
|
|
|
* |
93
|
|
|
* @access public |
94
|
|
|
* @param string $iframe_id (default: '') |
95
|
|
|
* @param mixed $location |
96
|
|
|
* @param mixed $width |
97
|
|
|
* @param mixed $height |
98
|
|
|
* @param string $email (default: '') |
99
|
|
|
* @return void |
100
|
|
|
*/ |
101
|
|
|
public function get_rent_buy_calc_widget( $iframe_id = '', $location, $width, $height, $email = '' ) { |
|
|
|
|
102
|
|
|
echo '<iframe id="'. $this->trulia_iframe_id( $iframe_id ) .'" class="'. $this->trulia_iframe_class( 'rent-buy-calc' ) .'" src="https://synd.trulia.com/tools/rent-vs-buy-calculator/embedded?params%5Btool_metro_area%5D=31084¶ms%5Btitle%5D=Rent+vs.+Buy+Calculator¶ms%5Bcolor%5D=grey¶ms%5Bemail%5D=¶ms%5Buser_url%5D=¶ms%5Bwidth%5D=600¶ms%5Bheight%5D=300¶ms%5Bguid%5D=582379f9264e8"></iframe>'; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* get_rental_market_widget function. |
107
|
|
|
* |
108
|
|
|
* @access public |
109
|
|
|
* @param string $iframe_id (default: '') |
110
|
|
|
* @param mixed $location |
111
|
|
|
* @param mixed $width |
112
|
|
|
* @param mixed $height |
113
|
|
|
* @param string $email (default: '') |
114
|
|
|
* @return void |
115
|
|
|
*/ |
116
|
|
|
public function get_rental_market_widget( $iframe_id = '', $location, $width, $height, $email = '' ) { |
|
|
|
|
117
|
|
|
|
118
|
|
|
echo '<iframe id="'. $this->trulia_iframe_id( $iframe_id ) .'" class="'. $this->trulia_iframe_class( 'rental-market' ) .'" src="https://synd.trulia.com/tools/rental-market-monitor/embedded?params%5Blocation%5D=Los+Angeles%2C+CA¶ms%5BlocationId%5D=22637¶ms%5Bcolor%5D=grey¶ms%5Bemail%5D=¶ms%5Buser_url%5D=¶ms%5Btitle%5D=Rental+Market+Monitor¶ms%5Bwidth%5D=300¶ms%5Bheight%5D=250¶ms%5Bguid%5D=582379637cf2e"></iframe>'; |
119
|
|
|
|
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* get_map_search_widget function. |
125
|
|
|
* |
126
|
|
|
* @access public |
127
|
|
|
* @param string $iframe_id (default: '') |
128
|
|
|
* @param mixed $location |
129
|
|
|
* @param mixed $width |
130
|
|
|
* @param mixed $height |
131
|
|
|
* @param string $email (default: '') |
132
|
|
|
* @return void |
133
|
|
|
*/ |
134
|
|
|
public function get_map_search_widget( $iframe_id = '', $location, $width, $height, $email = '' ) { |
|
|
|
|
135
|
|
|
echo '<iframe id="'. $this->trulia_iframe_id( $iframe_id ) .'" class="'. $this->trulia_iframe_class( 'map-search' ) .'" src="https://synd.trulia.com/tools/map-search/embedded?params%5Blocation%5D=West+Hills%2C+CA¶ms%5BlocationId%5D=39307¶ms%5Bagent_id%5D=¶ms%5Bproperty_status%5D=for+sale¶ms%5Btitle%5D=Map+Search¶ms%5Bcolor%5D=grey¶ms%5Bemail%5D=¶ms%5Buser_url%5D=¶ms%5Bwidth%5D=600¶ms%5Bheight%5D=300¶ms%5Bguid%5D=582378f4c0432"></iframe>'; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* get_home_gallery_widget function. |
140
|
|
|
* |
141
|
|
|
* @access public |
142
|
|
|
* @param string $iframe_id (default: '') |
143
|
|
|
* @param mixed $location |
144
|
|
|
* @param mixed $width |
145
|
|
|
* @param mixed $height |
146
|
|
|
* @param string $email (default: '') |
147
|
|
|
* @return void |
148
|
|
|
*/ |
149
|
|
|
public function get_home_gallery_widget( $iframe_id = '', $location, $width, $height, $email = '' ) { |
|
|
|
|
150
|
|
|
echo '<iframe id="'. $this->trulia_iframe_id( $iframe_id ) .'" class="'. $this->trulia_iframe_class( 'home-gallery' ) .'" src="https://synd.trulia.com/tools/home-gallery/embedded?params%5Blocation%5D=Los+Angeles%2C+CA¶ms%5BlocationId%5D=22637¶ms%5Bmin_price%5D=¶ms%5Bmax_price%5D=¶ms%5Bnum_beds%5D=¶ms%5Bnum_baths%5D=¶ms%5Bagent_id%5D=¶ms%5Bspeed%5D=5000¶ms%5Btitle%5D=Home+Gallery¶ms%5Bcolor%5D=green¶ms%5Bemail%5D=¶ms%5Buser_url%5D=¶ms%5Bwidth%5D=300¶ms%5Bheight%5D=300¶ms%5Bguid%5D=582371b703b0d¶ms%5Bslides_per_page%5D=3&city=Los Angeles&state_code=CA"></iframe>'; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* get_home_showcase_widget function. |
155
|
|
|
* |
156
|
|
|
* @access public |
157
|
|
|
* @param string $iframe_id (default: '') |
158
|
|
|
* @param mixed $location |
159
|
|
|
* @param mixed $width |
160
|
|
|
* @param mixed $height |
161
|
|
|
* @param string $email (default: '') |
162
|
|
|
* @return void |
163
|
|
|
*/ |
164
|
|
|
public function get_home_showcase_widget( $iframe_id = '', $location, $width, $height, $email = '' ) { |
|
|
|
|
165
|
|
|
echo '<iframe id="'. $this->trulia_iframe_id( $iframe_id ) .'" class="'. $this->trulia_iframe_class( 'home-showcase' ) .'" src="https://synd.trulia.com/tools/home-showcase/embedded?params%5Blocation%5D=Los+Angeles%2C+CA¶ms%5BlocationId%5D=22637¶ms%5Bmin_price%5D=¶ms%5Bmax_price%5D=¶ms%5Bnum_beds%5D=¶ms%5Bnum_baths%5D=¶ms%5Bagent_id%5D=¶ms%5Bspeed%5D=5000¶ms%5Btitle%5D=My+Listings¶ms%5Bcolor%5D=grey¶ms%5Bemail%5D=¶ms%5Buser_url%5D=¶ms%5Bwidth%5D=300¶ms%5Bheight%5D=350¶ms%5Bguid%5D=582370ce64073"></iframe>'; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* get_homefinder_widget function. |
170
|
|
|
* |
171
|
|
|
* @access public |
172
|
|
|
* @param string $iframe_id (default: '') |
173
|
|
|
* @param mixed $location |
174
|
|
|
* @param mixed $width |
175
|
|
|
* @param mixed $height |
176
|
|
|
* @param string $email (default: '') |
177
|
|
|
* @return void |
178
|
|
|
*/ |
179
|
|
|
public function get_homefinder_widget( $iframe_id = '', $location, $width, $height, $email = '' ) { |
|
|
|
|
180
|
|
|
echo '<iframe id="'. $this->trulia_iframe_id( $iframe_id ) .'" class="'. $this->trulia_iframe_class( 'homefinder' ) .'" src="https://synd.trulia.com/tools/home-finder/embedded?params%5Blocation%5D=¶ms%5BlocationId%5D=¶ms%5Bcolor%5D=green¶ms%5Bemail%5D=¶ms%5Buser_url%5D=¶ms%5Btitle%5D=Home+Finder¶ms%5Bwidth%5D=300¶ms%5Bheight%5D=350¶ms%5Bguid%5D=58236f71d7732"></iframe>'; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* get_market_monitor_widget function. |
185
|
|
|
* |
186
|
|
|
* @access public |
187
|
|
|
* @param string $iframe_id (default: '') |
188
|
|
|
* @param mixed $location |
189
|
|
|
* @param mixed $width |
190
|
|
|
* @param mixed $height |
191
|
|
|
* @param string $email (default: '') |
192
|
|
|
* @return void |
193
|
|
|
*/ |
194
|
|
|
public function get_market_monitor_widget( $iframe_id = '', $location, $width, $height, $email = '' ) { |
|
|
|
|
195
|
|
|
|
196
|
|
|
echo '<iframe id="'. $this->trulia_iframe_id( $iframe_id ) .'" class="'. $this->trulia_iframe_class( 'market-monitor' ) .'" src="https://synd.trulia.com/tools/market-monitor/embedded?params%5Blocation%5D=Los+Angeles%2C+CA¶ms%5BlocationId%5D=22637¶ms%5Blisting_price_type%5D=average¶ms%5Bshow_inventory%5D=1¶ms%5Btitle%5D=Market+Monitor¶ms%5Bcolor%5D=grey¶ms%5Bemail%5D=¶ms%5Buser_url%5D=¶ms%5Bwidth%5D=300¶ms%5Bheight%5D=250¶ms%5Bguid%5D=58236e004595a"></iframe>'; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* get_affordability_calc_widget function. (https://www.trulia.com/tools/affordability-calculator/) |
201
|
|
|
* |
202
|
|
|
* @access public |
203
|
|
|
* @param mixed $color |
204
|
|
|
* @param mixed $title |
205
|
|
|
* @param mixed $email |
206
|
|
|
* @param mixed $width |
207
|
|
|
* @param mixed $height |
208
|
|
|
* @return void |
209
|
|
|
*/ |
210
|
|
|
public function get_affordability_calc_widget( $iframe_id = '', $color, $title, $width, $height, $email = '' ) { |
|
|
|
|
211
|
|
|
|
212
|
|
|
echo '<iframe id="'. $this->trulia_iframe_id( $iframe_id ) .'" class="'. $this->trulia_iframe_class( 'affordability-calc' ) .'" src="https://synd.trulia.com/tools/affordability-calculator/embedded?params%5Bcolor%5D=grey¶ms%5Bemail%5D=¶ms%5Buser_url%5D=¶ms%5Btitle%5D=Affordability+Calculator¶ms%5Bwidth%5D=600¶ms%5Bheight%5D=300¶ms%5Bguid%5D=58236d0b501ae"></iframe>'; |
213
|
|
|
|
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
} |
217
|
|
|
} |
218
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.