1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* Zillow Badges (http://www.zillow.com/webtools/badges/) |
4
|
|
|
* |
5
|
|
|
* @package idxFORZA |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Zillow_Badges class. |
10
|
|
|
* |
11
|
|
|
* @extends WP_Widget |
12
|
|
|
*/ |
13
|
|
|
class Zillow_Badges extends WP_Widget { |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* __construct function. |
17
|
|
|
* |
18
|
|
|
* @access public |
19
|
|
|
* @return void |
|
|
|
|
20
|
|
|
*/ |
21
|
|
|
public function __construct() { |
22
|
|
|
|
23
|
|
|
parent::__construct( |
24
|
|
|
'zillow-badges', |
25
|
|
|
__( 'Zillow Badge', 're-pro' ), |
26
|
|
|
array( |
27
|
|
|
'description' => __( 'Display a Zillow Badge which links to an agent profile page.', 're-pro' ), |
28
|
|
|
'classname' => 'widget widget-zillow-badge', |
29
|
|
|
) |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The zillow_badges function. |
36
|
|
|
* |
37
|
|
|
* @access public |
38
|
|
|
* @return Array of Zillow Badges |
39
|
|
|
*/ |
40
|
|
|
public function zillow_badges() { |
41
|
|
|
|
42
|
|
|
return array( |
43
|
|
|
/* Premier Agent. */ |
44
|
|
|
array( |
45
|
|
|
'id' => 'premier-agent', |
46
|
|
|
'name' => __( 'Zillow Premier Agent', 're-pro' ), |
47
|
|
|
'alt' => __( 'Zillow Premier Agent', 're-pro' ), |
48
|
|
|
'title' => __( 'Zillow Premier Agent', 're-pro' ), |
49
|
|
|
'class' => 'zillow-badge', |
50
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/premier-agent.png', |
51
|
|
|
'width' => 100, |
52
|
|
|
'height' => 74, |
53
|
|
|
), |
54
|
|
|
/* Featured .*/ |
55
|
|
|
array( |
56
|
|
|
'id' => 'feature-badge-sm', |
57
|
|
|
'name' => __( 'Featured on Zillow - Small', 're-pro' ), |
58
|
|
|
'alt' => __( 'Featured on Zillow', 're-pro' ), |
59
|
|
|
'title' => __( 'Featured on Zillow', 're-pro' ), |
60
|
|
|
'class' => 'zillow-badge', |
61
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/feature_badge_sm.png', |
62
|
|
|
'width' => 100, |
63
|
|
|
'height' => 74, |
64
|
|
|
), |
65
|
|
|
array( |
66
|
|
|
'id' => 'feature-badge-lg', |
67
|
|
|
'name' => __( 'Featured on Zillow - Large', 're-pro' ), |
68
|
|
|
'alt' => __( 'Featured on Zillow', 're-pro' ), |
69
|
|
|
'title' => __( 'Featured on Zillow', 're-pro' ), |
70
|
|
|
'class' => 'zillow-badge', |
71
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/feature_badge_lg.png', |
72
|
|
|
'width' => 100, |
73
|
|
|
'height' => 74, |
74
|
|
|
), |
75
|
|
|
/* View My Profile. */ |
76
|
|
|
array( |
77
|
|
|
'id' => 'view-my-profile', |
78
|
|
|
'name' => __( 'View my Profile', 're-pro' ), |
79
|
|
|
'alt' => __( 'View my Profile', 're-pro' ), |
80
|
|
|
'title' => __( 'View my Profile', 're-pro' ), |
81
|
|
|
'class' => 'zillow-badge', |
82
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/bdg_profile.gif', |
83
|
|
|
'width' => 160, |
84
|
|
|
'height' => 40, |
85
|
|
|
), |
86
|
|
|
/* Feature My Listings - 160 x 40. */ |
87
|
|
|
array( |
88
|
|
|
'id' => 'my-listing-bllg', |
89
|
|
|
'name' => __( 'Feature My Listings 1', 're-pro' ), |
90
|
|
|
'alt' => __( 'I feature my listings on Zillow', 're-pro' ), |
91
|
|
|
'title' => __( 'I feature my listings on Zillow', 're-pro' ), |
92
|
|
|
'class' => 'zillow-badge', |
93
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-my-listing_bllg.gif', |
94
|
|
|
'width' => 160, |
95
|
|
|
'height' => 40, |
96
|
|
|
), |
97
|
|
|
array( |
98
|
|
|
'id' => 'my-listing-trlg', |
99
|
|
|
'name' => __( 'Feature My Listings 2', 're-pro' ), |
100
|
|
|
'alt' => __( 'I feature my listings on Zillow', 're-pro' ), |
101
|
|
|
'title' => __( 'I feature my listings on Zillow', 're-pro' ), |
102
|
|
|
'class' => 'zillow-badge', |
103
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-my-listing_trlg.gif', |
104
|
|
|
'width' => 160, |
105
|
|
|
'height' => 40, |
106
|
|
|
), |
107
|
|
|
array( |
108
|
|
|
'id' => 'my-listing-grlg', |
109
|
|
|
'name' => __( 'Feature My Listings 3', 're-pro' ), |
110
|
|
|
'alt' => __( 'I feature my listings on Zillow', 're-pro' ), |
111
|
|
|
'title' => __( 'I feature my listings on Zillow', 're-pro' ), |
112
|
|
|
'class' => 'zillow-badge', |
113
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-my-listing_grlg.gif', |
114
|
|
|
'width' => 160, |
115
|
|
|
'height' => 40, |
116
|
|
|
), |
117
|
|
|
/* ZILLOW ADDICT - 160 x 40 */ |
118
|
|
|
array( |
119
|
|
|
'id' => 'addict-bllg', |
120
|
|
|
'name' => __( 'Zillow Addict 1 (160X40)', 're-pro' ), |
121
|
|
|
'alt' => __( 'Zillow Addict', 're-pro' ), |
122
|
|
|
'title' => __( 'Zillow Addict', 're-pro' ), |
123
|
|
|
'class' => 'zillow-badge', |
124
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-addict_bllg.gif', |
125
|
|
|
'width' => 160, |
126
|
|
|
'height' => 40, |
127
|
|
|
), |
128
|
|
|
array( |
129
|
|
|
'id' => 'addict-trlg', |
130
|
|
|
'name' => __( 'Zillow Addict 2 (160X40)', 're-pro' ), |
131
|
|
|
'alt' => __( 'Zillow Addict', 're-pro' ), |
132
|
|
|
'title' => __( 'Zillow Addict', 're-pro' ), |
133
|
|
|
'class' => 'zillow-badge', |
134
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-addict_trlg.png', |
135
|
|
|
'width' => 160, |
136
|
|
|
'height' => 40, |
137
|
|
|
), |
138
|
|
|
array( |
139
|
|
|
'id' => 'addict-grlg', |
140
|
|
|
'name' => __( 'Zillow Addict 3 (160X40)', 're-pro' ), |
141
|
|
|
'alt' => __( 'Zillow Addict', 're-pro' ), |
142
|
|
|
'title' => __( 'Zillow Addict', 're-pro' ), |
143
|
|
|
'class' => 'zillow-badge', |
144
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-addict_grlg.gif', |
145
|
|
|
'width' => 160, |
146
|
|
|
'height' => 40, |
147
|
|
|
), |
148
|
|
|
/* ZILLOW ADDICT - 100 x 40 */ |
149
|
|
|
array( |
150
|
|
|
'id' => 'addict-blsm', |
151
|
|
|
'name' => __( 'Zillow Addict 1 (100X40)', 're-pro' ), |
152
|
|
|
'alt' => __( 'Zillow Addict', 're-pro' ), |
153
|
|
|
'title' => __( 'Zillow Addict', 're-pro' ), |
154
|
|
|
'class' => 'zillow-badge', |
155
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-addict_blsm.gif', |
156
|
|
|
'width' => 100, |
157
|
|
|
'height' => 40, |
158
|
|
|
), |
159
|
|
|
array( |
160
|
|
|
'id' => 'addict-trsm', |
161
|
|
|
'name' => __( 'Zillow Addict 2 (100X40)', 're-pro' ), |
162
|
|
|
'alt' => __( 'Zillow Addict', 're-pro' ), |
163
|
|
|
'title' => __( 'Zillow Addict', 're-pro' ), |
164
|
|
|
'class' => 'zillow-badge', |
165
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-addict_trsm.png', |
166
|
|
|
'width' => 100, |
167
|
|
|
'height' => 40, |
168
|
|
|
), |
169
|
|
|
array( |
170
|
|
|
'id' => 'addict-grsm', |
171
|
|
|
'name' => __( 'Zillow Addict 3 (100X40)', 're-pro' ), |
172
|
|
|
'alt' => __( 'Zillow Addict', 're-pro' ), |
173
|
|
|
'title' => __( 'Zillow Addict', 're-pro' ), |
174
|
|
|
'class' => 'zillow-badge', |
175
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-addict_grsm.gif', |
176
|
|
|
'width' => 100, |
177
|
|
|
'height' => 40, |
178
|
|
|
), |
179
|
|
|
/* REAL ESTATE FANATIC - 160 x 40 */ |
180
|
|
|
array( |
181
|
|
|
'id' => 'fanatic-bllg', |
182
|
|
|
'name' => __( 'Real Estate Fanatic 1 (160X40)', 're-pro' ), |
183
|
|
|
'alt' => __( 'Real Estate Fanatic', 're-pro' ), |
184
|
|
|
'title' => __( 'Real Estate Fanatic', 're-pro' ), |
185
|
|
|
'class' => 'zillow-badge', |
186
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-fanatic_bllg.gif', |
187
|
|
|
'width' => 160, |
188
|
|
|
'height' => 40, |
189
|
|
|
), |
190
|
|
|
array( |
191
|
|
|
'id' => 'fanatic-trlg', |
192
|
|
|
'name' => __( 'Real Estate Fanatic 2 (160X40)', 're-pro' ), |
193
|
|
|
'alt' => __( 'Real Estate Fanatic', 're-pro' ), |
194
|
|
|
'title' => __( 'Real Estate Fanatic', 're-pro' ), |
195
|
|
|
'class' => 'zillow-badge', |
196
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-fanatic_trlg.gif', |
197
|
|
|
'width' => 160, |
198
|
|
|
'height' => 40, |
199
|
|
|
), |
200
|
|
|
array( |
201
|
|
|
'id' => 'fanatic-grlg', |
202
|
|
|
'name' => __( 'Real Estate Fanatic 3 (160X40)', 're-pro' ), |
203
|
|
|
'alt' => __( 'Real Estate Fanatic', 're-pro' ), |
204
|
|
|
'title' => __( 'Real Estate Fanatic', 're-pro' ), |
205
|
|
|
'class' => 'zillow-badge', |
206
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-fanatic_grlg.gif', |
207
|
|
|
'width' => 160, |
208
|
|
|
'height' => 40, |
209
|
|
|
), |
210
|
|
|
/* REAL ESTATE FANATIC - 120X40 */ |
211
|
|
|
array( |
212
|
|
|
'id' => 'fanatic-blsm', |
213
|
|
|
'name' => __( 'Real Estate Fanatic 1 (120X40)', 're-pro' ), |
214
|
|
|
'alt' => __( 'Real Estate Fanatic', 're-pro' ), |
215
|
|
|
'title' => __( 'Real Estate Fanatic', 're-pro' ), |
216
|
|
|
'class' => 'zillow-badge', |
217
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-fanatic_blsm.gif', |
218
|
|
|
'width' => 120, |
219
|
|
|
'height' => 40, |
220
|
|
|
), |
221
|
|
|
array( |
222
|
|
|
'id' => 'fanatic-trsm', |
223
|
|
|
'name' => __( 'Real Estate Fanatic 2 (120X40)', 're-pro' ), |
224
|
|
|
'alt' => __( 'Real Estate Fanatic', 're-pro' ), |
225
|
|
|
'title' => __( 'Real Estate Fanatic', 're-pro' ), |
226
|
|
|
'class' => 'zillow-badge', |
227
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-fanatic_trsm.gif', |
228
|
|
|
'width' => 120, |
229
|
|
|
'height' => 40, |
230
|
|
|
), |
231
|
|
|
array( |
232
|
|
|
'id' => 'fanatic-grsm', |
233
|
|
|
'name' => __( 'Real Estate Fanatic 3 (120X40)', 're-pro' ), |
234
|
|
|
'alt' => __( 'Real Estate Fanatic', 're-pro' ), |
235
|
|
|
'title' => __( 'Real Estate Fanatic', 're-pro' ), |
236
|
|
|
'class' => 'zillow-badge', |
237
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/zillow-fanatic_grsm.gif', |
238
|
|
|
'width' => 120, |
239
|
|
|
'height' => 40, |
240
|
|
|
), |
241
|
|
|
/* Dig Influencer */ |
242
|
|
|
array( |
243
|
|
|
'id' => 'dig-square-influencer', |
244
|
|
|
'name' => __( 'Dig Influencer Square', 're-pro' ), |
245
|
|
|
'alt' => __( 'Dig Influencer', 're-pro' ), |
246
|
|
|
'title' => __( 'Dig Influencer', 're-pro' ), |
247
|
|
|
'class' => 'zillow-badge', |
248
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/square-influencer.png', |
249
|
|
|
'width' => 72, |
250
|
|
|
'height' => 72, |
251
|
|
|
), |
252
|
|
|
array( |
253
|
|
|
'id' => 'dig-rectangle-influencer', |
254
|
|
|
'name' => __( 'Dig Rectangle Influencer', 're-pro' ), |
255
|
|
|
'alt' => __( 'Dig Influencer', 're-pro' ), |
256
|
|
|
'title' => __( 'Dig Influencer', 're-pro' ), |
257
|
|
|
'class' => 'zillow-badge', |
258
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/rectangle-influencer.png', |
259
|
|
|
'width' => 109, |
260
|
|
|
'height' => 35, |
261
|
|
|
), |
262
|
|
|
array( |
263
|
|
|
'id' => 'dig-square-pro', |
264
|
|
|
'name' => __( 'Dig Square Pro', 're-pro' ), |
265
|
|
|
'alt' => __( 'Dig Influencer', 're-pro' ), |
266
|
|
|
'title' => __( 'Dig Influencer', 're-pro' ), |
267
|
|
|
'class' => 'zillow-badge', |
268
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/square-pro.png', |
269
|
|
|
'width' => 72, |
270
|
|
|
'height' => 72, |
271
|
|
|
), |
272
|
|
|
array( |
273
|
|
|
'id' => 'dig-rectangle-pro', |
274
|
|
|
'name' => __( 'Dig Rectangle Pro', 're-pro' ), |
275
|
|
|
'alt' => __( 'Dig Influencer', 're-pro' ), |
276
|
|
|
'title' => __( 'Dig Influencer', 're-pro' ), |
277
|
|
|
'class' => 'zillow-badge', |
278
|
|
|
'url' => 'https://www.zillowstatic.com/static/images/badges/rectangle-pro.png', |
279
|
|
|
'width' => 109, |
280
|
|
|
'height' => 35, |
281
|
|
|
), |
282
|
|
|
); |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* Widget function. |
288
|
|
|
* |
289
|
|
|
* @access public |
290
|
|
|
* @param mixed $args Arguments. |
291
|
|
|
* @param mixed $instance Instance. |
292
|
|
|
* @return void |
293
|
|
|
*/ |
294
|
|
|
public function widget( $args, $instance ) { |
295
|
|
|
|
296
|
|
|
// Retrieve any existing value from the database. |
297
|
|
|
$title = ! empty( $instance['title'] ) ? $instance['title'] : ''; |
298
|
|
|
$zid = ! empty( $instance['zid'] ) ? $instance['zid'] : ''; |
299
|
|
|
$badge_name = ! empty( $instance['badge_name'] ) ? $instance['badge_name'] : ''; |
300
|
|
|
$badge_alignment = ! empty( $instance['badge_alignment'] ) ? $instance['badge_alignment'] : ''; |
301
|
|
|
|
302
|
|
|
$zillow_badges = $this->zillow_badges(); |
303
|
|
|
|
304
|
|
|
echo $args['before_widget']; |
305
|
|
|
|
306
|
|
|
echo $args['before_title'] . esc_attr( $title ) . $args['after_title'] ; |
307
|
|
|
|
308
|
|
|
foreach ( $zillow_badges as $zillow_badge ) { |
309
|
|
|
if ( $badge_name === $zillow_badge['id'] ) { |
310
|
|
|
|
311
|
|
|
echo '<a href="https://www.zillow.com/profile/'. $zid .'" ><img id="zillow-'. esc_attr( $zillow_badge['id'] ) .'-badge" class="'. sanitize_html_class( $zillow_badge['class'] ) . ' ' . sanitize_html_class( $badge_alignment ) .'" src="' . esc_url( apply_filters( 'jetpack_photon_url', $zillow_badge['url'] ) ) . '" alt="'. esc_attr( $zillow_badge['alt'] ) . '" height="'. esc_attr( $zillow_badge['height'] ) .'" width="'. esc_attr( $zillow_badge['width'] ) .'" title="'. esc_attr( $zillow_badge['alt'] ) .'" /></a>'; |
312
|
|
|
|
313
|
|
|
} |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
echo $args['after_widget']; |
317
|
|
|
|
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Form function. |
322
|
|
|
* |
323
|
|
|
* @access public |
324
|
|
|
* @param mixed $instance Instance. |
325
|
|
|
* @return void |
326
|
|
|
*/ |
327
|
|
|
public function form( $instance ) { |
328
|
|
|
|
329
|
|
|
// Set default values. |
330
|
|
|
$instance = wp_parse_args( (array) $instance, array( |
331
|
|
|
'title' => '', |
332
|
|
|
'zid' => '', |
333
|
|
|
'badge_name' => '', |
334
|
|
|
'badge_alignment' => '', |
335
|
|
|
)); |
336
|
|
|
|
337
|
|
|
// Retrieve an existing value from the database. |
338
|
|
|
$title = ! empty( $instance['title'] ) ? $instance['title'] : ''; |
339
|
|
|
$zid = ! empty( $instance['zid'] ) ? $instance['zid'] : ''; |
340
|
|
|
$badge_name = ! empty( $instance['badge_name'] ) ? $instance['badge_name'] : ''; |
341
|
|
|
$badge_alignment = ! empty( $instance['badge_alignment'] ) ? $instance['badge_alignment'] : ''; |
342
|
|
|
|
343
|
|
|
$zillow_badges = $this->zillow_badges(); |
344
|
|
|
|
345
|
|
|
// Form fields. |
346
|
|
|
echo '<p>'; |
347
|
|
|
echo ' <label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '" class="title_label">' . esc_attr( 'Title', 're-pro' ) . '</label>'; |
348
|
|
|
echo ' <input type="text" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" class="widefat" placeholder="' . esc_attr__( 'Find me on Zillow', 're-pro' ) . '" value="' . esc_attr( $title ) . '">'; |
349
|
|
|
echo ' <span class="description">' . esc_attr( 'Add a title to your zillow badge.', 're-pro' ) . '</span>'; |
350
|
|
|
echo '</p>'; |
351
|
|
|
|
352
|
|
|
echo '<p>'; |
353
|
|
|
echo ' <label for="' . esc_attr( $this->get_field_id( 'zid' ) ) . '" class="zid_label">' . esc_attr( 'Zillow User ID', 're-pro' ) . '</label>'; |
354
|
|
|
echo ' <input type="text" id="' . esc_attr( $this->get_field_id( 'zid' ) ) . '" name="' . esc_attr( $this->get_field_name( 'zid' ) ) . '" class="widefat" placeholder="' . esc_attr__( 'ZID', 're-pro' ) . '" value="' . esc_attr( $zid ) . '">'; |
355
|
|
|
echo ' <span class="description">' . esc_attr( 'Please provide your Zillow User ID.', 're-pro' ) . '</span>'; |
356
|
|
|
echo '</p>'; |
357
|
|
|
|
358
|
|
|
echo '<p>'; |
359
|
|
|
echo ' <label for="' . esc_attr( $this->get_field_id( 'badge_name' ) ) . '" class="badge_name_label">' . esc_attr( 'Badge Type', 're-pro' ) . '</label><br />'; |
360
|
|
|
echo ' <select id="' . esc_attr( $this->get_field_id( 'badge_name' ) ) . '" name="' . esc_attr( $this->get_field_name( 'badge_name' ) ) . '" class="widefat">'; |
361
|
|
|
echo ' <option value="" '. selected( $badge_name, '', false ) .'>'. esc_attr( 'Choose', 're-pro' ) .'</option>'; |
362
|
|
|
foreach ( $zillow_badges as $zillow_badge ) { |
363
|
|
|
echo '<option value="'. esc_attr( $zillow_badge['id'] ) .'" ' . selected( $badge_name, $zillow_badge['id'], false ) . '> ' . esc_attr( $zillow_badge['name'] ) . '</option>'; |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
echo '</select>'; |
367
|
|
|
echo '<span class="description">' . __( 'Choose a badge type from the dropdown. Click Save to preview the badge. Full list of badges can be found on <a href="http://www.zillow.com/webtools/badges/" target="_blank" rel="nofollow">Zillow</a>.', 're-pro' ) . '</span>'; |
368
|
|
|
echo '</p>'; |
369
|
|
|
|
370
|
|
|
echo '<p>'; |
371
|
|
|
echo ' <label for="' . esc_attr( $this->get_field_id( 'badge_alignment' ) ) . '" class="badge_alignment_label">' . esc_attr_e( 'Badge Alignment', 're-pro' ) . '</label>'; |
372
|
|
|
echo ' <select id="' . esc_attr( $this->get_field_id( 'badge_alignment' ) ) . '" name="' . esc_attr( $this->get_field_name( 'badge_alignment' ) ) . '" class="widefat">'; |
373
|
|
|
echo ' <option value="alignleft" ' . selected( $badge_alignment, 'alignleft', false ) . '> ' . esc_attr( 'Left', 're-pro' ) . '</option>'; |
374
|
|
|
echo ' <option value="aligncenter" ' . selected( $badge_alignment, 'aligncenter', false ) . '> ' . esc_attr( 'Center', 're-pro' ) . '</option>'; |
375
|
|
|
echo ' <option value="alignright" ' . selected( $badge_alignment, 'alignright', false ) . '> ' . esc_attr( 'Right', 're-pro' ) . '</option>'; |
376
|
|
|
echo ' </select>'; |
377
|
|
|
echo ' <span class="description">' . esc_attr( 'Choose how to align your badge within the widget space.', 're-pro' ) . '</span>'; |
378
|
|
|
echo '</p>'; |
379
|
|
|
|
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* Update function. |
384
|
|
|
* |
385
|
|
|
* @access public |
386
|
|
|
* @param mixed $new_instance New instance. |
387
|
|
|
* @param mixed $old_instance Old Instance. |
388
|
|
|
* @return $instance Instance. |
|
|
|
|
389
|
|
|
*/ |
390
|
|
|
public function update( $new_instance, $old_instance ) { |
391
|
|
|
|
392
|
|
|
$instance = $old_instance; |
393
|
|
|
|
394
|
|
|
$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : ''; |
395
|
|
|
$instance['badge_name'] = ! empty( $new_instance['badge_name'] ) ? strip_tags( $new_instance['badge_name'] ) : ''; |
396
|
|
|
$instance['badge_alignment'] = ! empty( $new_instance['badge_alignment'] ) ? strip_tags( $new_instance['badge_alignment'] ) : ''; |
397
|
|
|
|
398
|
|
|
$instance['zid'] = ! empty( $new_instance['zid'] ) ? strip_tags( $new_instance['zid'] ) : ''; |
399
|
|
|
|
400
|
|
|
return $instance; |
401
|
|
|
|
402
|
|
|
} |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* register_zillow_badge_widgets function. |
407
|
|
|
* |
408
|
|
|
* @access public |
409
|
|
|
* @return void |
410
|
|
|
*/ |
411
|
|
|
function register_zillow_badge_widgets() { |
412
|
|
|
|
413
|
|
|
register_widget( 'Zillow_Badges' ); |
414
|
|
|
} |
415
|
|
|
add_action( 'widgets_init', 'register_zillow_badge_widgets' ); |
416
|
|
|
|
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.