PluginProbe
WPCasa – Real Estate for WordPress / trunk
WPCasa – Real Estate for WordPress vtrunk
1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.1.1 trunk 1.2.0 1.2.1 1.2.10 1.2.10.1 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.2.9.1 1.2.9.2 1.3.0 All 31 releases
wpcasa / functions / wpsight-general.php

wpsight-general.php in WPCasa – Real Estate for WordPress trunk, at functions/wpsight-general.php

520 lines 10.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSight general functions
4 *
5 * @package WPSight \ Functions
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * wpsight_details()
15 *
16 * Function that defines the array
17 * of standard listing details (beds, baths etc.)
18 *
19 * @uses WPSight_General::details()
20 * @return array
21 *
22 * @since 1.0.0
23 */
24
25 function wpsight_details() {
26 return WPSight_General::details();
27 }
28
29 /**
30 * wpsight_get_detail()
31 *
32 * Get specific listing detail.
33 *
34 * @param string $detail Key of the detail to return
35 * @param bool $return Only return specific element of detail array
36 * @uses WPSight_General::get_detail()
37 * @return array|string|bool
38 *
39 * @since 1.0.0
40 */
41 function wpsight_get_detail( $detail, $return = false ) {
42 return WPSight_General::get_detail( $detail, $return );
43 }
44
45 /**
46 * wpsight_get_detail_by_query_var()
47 *
48 * Get specific detail by it's query var key
49 * in the wpsight_details() array.
50 *
51 * @param string $query_var query_var key
52 * @uses WPSight_General::get_detail()
53 * @return string Key of the detail array element
54 *
55 * @since 1.0.0
56 */
57 function wpsight_get_detail_by_query_var( $query_var ) {
58 return WPSight_General::get_detail( $query_var );
59 }
60
61 /**
62 * wpsight_get_query_var_by_detail()
63 *
64 * Get specific detail by it's query var key
65 * in the wpsight_details() array.
66 *
67 * @param string $query_var query_var key
68 * @uses WPSight_General::get_query_var_by_detail()
69 * @return string Key of the detail array element
70 *
71 * @since 1.0.0
72 */
73 function wpsight_get_query_var_by_detail( $detail ) {
74 return WPSight_General::get_query_var_by_detail( $detail );
75 }
76
77 /**
78 * wpsight_offers()
79 *
80 * Function that defines the array
81 * of available listing offers (sale, rent etc.)
82 *
83 * @uses WPSight_General::offers()
84 * @return array
85 *
86 * @since 1.0.0
87 */
88 function wpsight_offers() {
89 return WPSight_General::offers();
90 }
91
92 /**
93 * wpsight_get_offer()
94 *
95 * Get specific offer.
96 *
97 * @param string $offer Key of the offer to return
98 * @uses WPSight_General::get_offer()
99 * @return string|bool Label of the offer or false if offer does not exist
100 *
101 * @since 1.0.0
102 */
103 function wpsight_get_offer( $offer ) {
104 return WPSight_General::get_offer( $offer );
105 }
106
107 /**
108 * wpsight_offer()
109 *
110 * Echo wpsight_get_offer()
111 *
112 * @param string $offer Key of the offer to return
113 * @uses wpsight_get_offer()
114 *
115 * @since 1.0.0
116 */
117 function wpsight_offer( $offer ) {
118 echo esc_html( wpsight_get_offer( $offer ) );
119 }
120
121 /**
122 * wpsight_offer_color()
123 *
124 * Echo wpsight_get_offer_color()
125 *
126 * @param string $offer Key of the offer to return
127 * @uses wpsight_get_offer_color()
128 *
129 * @since 1.0.0
130 */
131 function wpsight_offer_color( $offer ) {
132 echo esc_html( wpsight_get_offer_color( $offer ) );
133 }
134
135 /**
136 * wpsight_get_offer_color()
137 *
138 * Get specific offer color used for labels etc.
139 *
140 * @param string $offer Key of the offer to return
141 * @uses WPSight_General::get_offer_color()
142 * @return string|bool Color of the offer or false if offer does not exist
143 *
144 * @since 1.0.0
145 */
146 function wpsight_get_offer_color( $offer ) {
147 return WPSight_General::get_offer_color( $offer );
148 }
149
150 /**
151 * wpsight_rental_periods()
152 *
153 * Function that defines the array
154 * of available rental periods (monthly etc.)
155 *
156 * @uses WPSight_General::rental_periods()
157 * @return array
158 *
159 * @since 1.0.0
160 */
161 function wpsight_rental_periods() {
162 return WPSight_General::rental_periods();
163 }
164
165 /**
166 * wpsight_get_rental_period()
167 *
168 * Get specific rental period.
169 *
170 * @param string $period Key of the period to return
171 * @uses WPSight_General::get_rental_period()
172 * @return string|bool Label of the period or false if period does not exist
173 *
174 * @since 1.0.0
175 */
176 function wpsight_get_rental_period( $period ) {
177 return WPSight_General::get_rental_period( $period );
178 }
179
180 /**
181 * wpsight_rental_period()
182 *
183 * Echo wpsight_get_rental_period()
184 *
185 * @param string $period Key of the period to return
186 * @uses wpsight_get_rental_period()
187 *
188 * @since 1.0.0
189 */
190 function wpsight_rental_period( $period ) {
191 echo esc_html( wpsight_get_rental_period( $period ) );
192 }
193
194 /**
195 * wpsight_measurements()
196 *
197 * Function that defines the array
198 * of available measurement units (m2, etc.)
199 *
200 * @uses WPSight_General::measurements()
201 * @return array
202 *
203 * @since 1.0.0
204 */
205 function wpsight_measurements() {
206 return WPSight_General::measurements();
207 }
208
209 /**
210 * wpsight_get_measurement()
211 *
212 * Get specific measurement unit.
213 *
214 * @param string $measurement Key of the measurement to return
215 * @uses WPSight_General::get_measurement()
216 * @return string|bool Label of the measurement or false if unit does not exist
217 *
218 * @since 1.0.0
219 */
220 function wpsight_get_measurement( $measurement ) {
221 return WPSight_General::get_measurement( $measurement );
222 }
223
224 /**
225 * wpsight_measurement()
226 *
227 * Echo wpsight_get_measurement()
228 *
229 * @param string $measurement Key of the measurement to return
230 * @uses wpsight_get_measurement()
231 *
232 * @since 1.0.0
233 */
234 function wpsight_measurement( $measurement ) {
235 echo esc_html( wpsight_get_measurement( $measurement ) );
236 }
237
238 /**
239 * wpsight_date_formats()
240 *
241 * Function that defines the array
242 * of available date formats.
243 *
244 * @uses return WPSight_General::date_formats()
245 * @return array
246 *
247 * @since 1.0.0
248 */
249 function wpsight_date_formats( $date_i18n = false ) {
250 return WPSight_General::date_formats( $date_i18n );
251 }
252
253 /**
254 * wpsight_statuses()
255 *
256 * Function that defines the array
257 * of available post statuses
258 *
259 * @uses WPSight_General::statuses()
260 * @return array
261 *
262 * @since 1.0.0
263 */
264 function wpsight_statuses() {
265 return WPSight_General::statuses();
266 }
267
268 /**
269 * wpsight_get_status()
270 *
271 * Get specific listing status
272 *
273 * @param string $status Key of the corresponding status
274 * @param string $field Field of the status (default: label)
275 * @uses WPSight_General::get_status()
276 * @return array
277 *
278 * @since 1.0.0
279 */
280 function wpsight_get_status( $status, $field = 'label' ) {
281 return WPSight_General::get_status( $status, $field );
282 }
283
284 /**
285 * wpsight_currencies()
286 *
287 * Function that defines the array
288 * of available currencies (USD, EUR etc.)
289 *
290 * @uses WPSight_General::currencies()
291 * @return array
292 *
293 * @since 1.0.0
294 */
295 function wpsight_currencies() {
296 return WPSight_General::currencies();
297 }
298
299 /**
300 * wpsight_get_currency_abbr()
301 *
302 * Get 3-letter currency abbreviation.
303 *
304 * @param string $currency 3-letter code of specific currency
305 * @uses WPSight_General::get_currency_abbr()
306 * @return string 3-letter currency code
307 *
308 * @since 1.0.0
309 */
310 function wpsight_get_currency_abbr( $currency = '' ) {
311 return WPSight_General::get_currency_abbr( $currency );
312 }
313
314 /**
315 * wpsight_get_currency()
316 *
317 * Get currency entity.
318 *
319 * @param string $currency 3-letter code of specific currency
320 * @uses WPSight_General::get_currency()
321 * @return string Currency entity or 3-letter code
322 *
323 * @since 1.0.0
324 */
325 function wpsight_get_currency( $currency = '' ) {
326 return WPSight_General::get_currency( $currency );
327 }
328
329 /**
330 * wpsight_currency()
331 *
332 * Echo wpsight_get_currency().
333 *
334 * @param string $currency 3-letter code of specific currency
335 * @uses wpsight_get_currency()
336 * @return string Currency entity or 3-letter code
337 *
338 * @since 1.0.0
339 */
340 function wpsight_currency( $currency = '' ) {
341 echo esc_html( wpsight_get_currency( $currency ) );
342 }
343
344 /**
345 * wpsight_spaces()
346 *
347 * Function that defines the array
348 * of available widget spaces.
349 *
350 * @uses WPSight_General::spaces()
351 * @return array
352 *
353 * @since 1.0.0
354 */
355 function wpsight_spaces() {
356 return WPSight_General::spaces();
357 }
358
359 /**
360 * listing_query_vars()
361 *
362 * Return all custom query vars for listings
363 *
364 * @uses WPSight_General::listing_query_vars()
365 * @return array
366 *
367 * @since 1.0.0
368 */
369 function wpsight_listing_query_vars() {
370 return WPSight_General::listing_query_vars();
371 }
372
373 /**
374 * wpsight_allowed_html_tags()
375 *
376 * Return allowed tags with its attributes
377 *
378 * @return array Allowed tags and its attributes
379 *
380 */
381 function wpsight_allowed_html_tags() {
382
383 $wpsight_tags = wp_kses_allowed_html( 'post' );
384 // iframe
385 $wpsight_tags['iframe'] = array(
386 'src' => array(),
387 'height' => array(),
388 'width' => array(),
389 'frameborder' => array(),
390 'allowfullscreen' => array(),
391 );
392 $wpsight_tags['form'] = array(
393 'class' => true,
394 'id' => true,
395 'action' => true,
396 'accept' => true,
397 'accept-charset' => true,
398 'enctype' => true,
399 'method' => true,
400 'name' => true,
401 'target' => true,
402 );
403 // form fields - input
404 $wpsight_tags['input'] = array(
405 'class' => array(),
406 'id' => array(),
407 'name' => array(),
408 'value' => array(),
409 'type' => array(),
410 'title' => array(),
411 'placeholder' => array(),
412 'checked' => array(),
413 );
414 // select
415 $wpsight_tags['select'] = array(
416 'class' => array(),
417 'id' => array(),
418 'name' => array(),
419 'value' => array(),
420 'type' => array(),
421 );
422 // select options
423 $wpsight_tags['option'] = array(
424 'class' => array(),
425 'id' => array(),
426 'selected' => array(),
427 'value' => array(),
428 'data-default' => array()
429 );
430 // style
431 $wpsight_tags['style'] = array(
432 'types' => array(),
433 );
434
435 return apply_filters( 'wpsight_allowed_html_tags', $wpsight_tags );
436 }
437
438 /**
439 * wpsight_get_img_html()
440 *
441 * Return allowed tags and attributes with for <img>
442 *
443 * @return array Allowed tags and its attributes
444 *
445 */
446 function wpsight_get_img_html() {
447 $img_html = array(
448 'img' => array(
449 'title' => array(),
450 'src' => array(),
451 'alt' => array(),
452 'width' => array(),
453 'height' => array(),
454 )
455 );
456 return $img_html;
457 }
458
459 /**
460 * wpsight_get_listing_html()
461 *
462 * Return allowed tags and attributes with for listing template
463 *
464 * @return array Allowed tags and its attributes
465 *
466 * @since 1.2.9.2
467 */
468 function wpsight_get_listing_html() {
469
470 $listing_html = array(
471 'img' => array(
472 'title' => array(),
473 'src' => array(),
474 'alt' => array(),
475 'width' => array(),
476 'height' => array(),
477 'class' => array(),
478 'style' => array(),
479 'decoding' => array(),
480 'data-mh' => array(),
481 ),
482 'div' => array(
483 'class' => array(),
484 'style' => array(),
485 ),
486 'span' => array(
487 'class' => array(),
488 'style' => array()
489 )
490 );
491
492 return $listing_html;
493
494 }
495
496 /**
497 * wpsight_get_listing_details_html()
498 *
499 * Return allowed tags and attributes with for details list
500 *
501 * @return array Allowed tags and its attributes
502 *
503 */
504 function wpsight_get_listing_details_html() {
505 $listing_details_html = array(
506 'span' => array(
507 'class' => array(),
508 ),
509 'i' => array(
510 'class' => array()
511 ),
512 'a' => array(
513 'class' => array(),
514 'rel' => array(),
515 'href' => array()
516 )
517 );
518 return $listing_details_html;
519 }
520