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-agents.php

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

629 lines 18.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSight agent functions
4 *
5 * @package WPSight \ Functions
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * wpsight_agent_roles()
15 *
16 * Define custom user roles for agents:
17 *
18 * - Listing Admin
19 * - Listing Agent
20 * - Listing Subscriber
21 *
22 * Capabilities for listings are created in
23 * /includes/class-wpsight-post-types.php with
24 * capability_type 'listing' and map_meta_cap true.
25 *
26 * [cap] => stdClass Object
27 * (
28 * [edit_post] => edit_listing
29 * [read_post] => read_listing
30 * [delete_post] => delete_listing
31 * [edit_posts] => edit_listings
32 * [edit_others_posts] => edit_others_listings
33 * [publish_posts] => publish_listings
34 * [read_private_posts] => read_private_listings
35 * [delete_posts] => delete_listings
36 * [delete_private_posts] => delete_private_listings
37 * [delete_published_posts] => delete_published_listings
38 * [delete_others_posts] => delete_others_listings
39 * [edit_private_posts] => edit_private_listings
40 * [edit_published_posts] => edit_published_listings
41 * [create_posts] => edit_listings
42 * )
43 *
44 * @uses WPSight_Agents::agent_roles()
45 * @return array $roles Array of roles to be used by add_role() in /includes/class-wpsight-install.php
46 *
47 * @since 1.0.0
48 */
49 function wpsight_agent_roles() {
50 return WPSight_Agents::agent_roles();
51 }
52
53 /**
54 * wpsight_listing_agent_image()
55 *
56 * Echo wpsight_get_listing_agent_image()
57 *
58 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
59 * @param string|array $size Size of the image (WordPress sizes or custom width and height in array)
60 * @uses wpsight_get_listing_agent_image()
61 *
62 * @since 1.0.0
63 */
64 function wpsight_listing_agent_image( $post = null, $size = array( 75, 75 ) ) {
65 echo wp_kses( wpsight_get_listing_agent_image( $post, $size ), wpsight_get_img_html() );
66 }
67
68 /**
69 * wpsight_get_listing_agent_image()
70 *
71 * Return HTML image tag of the agent image of
72 * the current or a specific listing.
73 *
74 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
75 * @param string|array $size Size of the image (WordPress sizes or custom width and height in array)
76 * @uses WPSight_Agents::wpsight_get_listing_agent_image()
77 * @return string|bool $agent_image HTML image tag of the listing agent image or false
78 *
79 * @since 1.0.0
80 */
81 function wpsight_get_listing_agent_image( $post = null, $size = array( 75, 75 ) ) {
82 return WPSight_Agents::get_listing_agent_image( $post, $size ) ;
83 }
84
85 /**
86 * wpsight_agent_image()
87 *
88 * Echo wpsight_get_agent_image()
89 *
90 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
91 * @param string|array $size Size of the image (WordPress sizes or custom width and height in array)
92 * @uses wpsight_get_agent_image()
93 *
94 * @since 1.0.0
95 */
96 function wpsight_agent_image( $user_id, $size = array( 75, 75 ) ) {
97 echo wp_kses( wpsight_get_agent_image( $user_id, $size ), wpsight_get_img_html() );
98 }
99
100 /**
101 * wpsight_get_agent_image()
102 *
103 * Return HTML image tag of the agent image of
104 * the current or a specific listing.
105 *
106 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
107 * @param string|array $size Size of the image (WordPress sizes or custom width and height in array)
108 * @uses WPSight_Agents::wpsight_get_listing_agent_image()
109 * @return string|bool $agent_image HTML image tag of the listing agent image or false
110 *
111 * @since 1.0.0
112 */
113 function wpsight_get_agent_image( $user_id, $size = array( 75, 75 ) ) {
114 return WPSight_Agents::get_agent_image( $user_id, $size ) ;
115 }
116
117 /**
118 * wpsight_listing_agent_name()
119 *
120 * Echo wpsight_get_listing_agent_name()
121 *
122 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
123 * @uses wpsight_get_listing_agent_name()
124 *
125 * @since 1.0.0
126 */
127 function wpsight_listing_agent_name( $post = null ) {
128 echo esc_html( wpsight_get_listing_agent_name( $post ) );
129 }
130
131 /**
132 * wpsight_get_listing_agent_name()
133 *
134 * Return agent name of the
135 * current or a specific listing.
136 *
137 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
138 * @uses WPSight_Agents::get_listing_agent_name()
139 * @return string|bool $agent_name Agent name of the listing agent or false
140 *
141 * @since 1.0.0
142 */
143 function wpsight_get_listing_agent_name( $post = null ) {
144 return WPSight_Agents::get_listing_agent_name( $post );
145 }
146
147 /**
148 * wpsight_agent_name()
149 *
150 * Echo wpsight_get_agent_name()
151 *
152 * @param integer $user_id User ID of corresponding agent (required)
153 * @param string $name The name type to be returned (defaults to display_name)
154 * @uses wpsight_get_agent_name()
155 *
156 * @since 1.0.0
157 */
158 function wpsight_agent_name( $user_id, $name = 'display_name' ) {
159 echo esc_html( wpsight_get_agent_name( $user_id, $name ) );
160 }
161
162 /**
163 * wpsight_get_agent_name()
164 *
165 * Return name of a specific agent.
166 *
167 * @param integer $user_id User ID of corresponding agent (required)
168 * @param string $name The name type to be returned (defaults to display_name)
169 * @uses WPSight_Agents::get_listing_agent_name()
170 * @return string|bool $agent_name Agent name or false
171 *
172 * @since 1.0.0
173 */
174 function wpsight_get_agent_name( $user_id, $name = 'display_name' ) {
175 return WPSight_Agents::get_agent_name( $user_id, $name );
176 }
177
178 /**
179 * wpsight_listing_agent_company()
180 *
181 * Echo wpsight_get_listing_agent_company()
182 *
183 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
184 * @uses wpsight_get_listing_agent_company()
185 *
186 * @since 1.0.0
187 */
188 function wpsight_listing_agent_company( $post = null ) {
189 echo esc_html( wpsight_get_listing_agent_company( $post ) );
190 }
191
192 /**
193 * wpsight_get_listing_agent_company()
194 *
195 * Return agent company of the
196 * current or a specific listing.
197 *
198 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
199 * @uses WPSight_Agents::get_listing_agent_company()
200 * @return string|bool $agent_company Agent company of the listing agent or false
201 *
202 * @since 1.0.0
203 */
204 function wpsight_get_listing_agent_company( $post = null ) {
205 return WPSight_Agents::get_listing_agent_company( $post );
206 }
207
208 /**
209 * wpsight_agent_company()
210 *
211 * Echo wpsight_get_agent_company()
212 *
213 * @param integer $user_id User ID of corresponding agent (required)
214 * @uses wpsight_get_agent_company()
215 *
216 * @since 1.0.0
217 */
218 function wpsight_agent_company( $user_id ) {
219 echo esc_html( wpsight_get_agent_company( $user_id ) );
220 }
221
222 /**
223 * wpsight_get_agent_company()
224 *
225 * Return name of a specific agent.
226 *
227 * @param integer $user_id User ID of corresponding agent (required)
228 * @uses WPSight_Agents::get_agent_company()
229 * @return string|bool $agent_company Agent company or false
230 *
231 * @since 1.0.0
232 */
233 function wpsight_get_agent_company( $user_id ) {
234 return WPSight_Agents::get_agent_company( $user_id );
235 }
236
237 /**
238 * wpsight_listing_agent_description()
239 *
240 * Echo wpsight_get_listing_agent_description()
241 *
242 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
243 * @uses wpsight_get_listing_agent_description()
244 *
245 * @since 1.0.0
246 */
247 function wpsight_listing_agent_description( $post = null ) {
248 echo wp_kses( wpsight_get_listing_agent_description( $post ), wp_kses_allowed_html( 'post' ) );
249 }
250
251 /**
252 * wpsight_get_listing_agent_description()
253 *
254 * Return agent description of the
255 * current or a specific listing.
256 *
257 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
258 * @uses WPSight_Agents::get_listing_agent_description()
259 * @return string|bool $agent_description Agent description of the listing agent or false
260 *
261 * @since 1.0.0
262 */
263 function wpsight_get_listing_agent_description( $post = null ) {
264 return WPSight_Agents::get_listing_agent_description( $post );
265 }
266
267 /**
268 * wpsight_agent_description()
269 *
270 * Echo wpsight_get_agent_description()
271 *
272 * @param integer $user_id User ID of corresponding agent (required)
273 * @uses wpsight_get_agent_description()
274 *
275 * @since 1.0.0
276 */
277 function wpsight_agent_description( $user_id ) {
278 echo wp_kses( wpsight_get_agent_description( $user_id ), wp_kses_allowed_html( 'post' ) );
279 }
280
281 /**
282 * wpsight_get_agent_description()
283 *
284 * Return description of a specific agent.
285 *
286 * @param integer $user_id User ID of corresponding agent (required)
287 * @uses WPSight_Agents::get_agent_description()
288 * @return string|bool $agent_description Agent description or false
289 *
290 * @since 1.0.0
291 */
292 function wpsight_get_agent_description( $user_id ) {
293 return WPSight_Agents::get_agent_description( $user_id );
294 }
295
296 /**
297 * wpsight_listing_agent_website()
298 *
299 * Echo wpsight_get_listing_agent_website()
300 *
301 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
302 * @uses wpsight_get_listing_agent_website()
303 *
304 * @since 1.0.0
305 */
306 function wpsight_listing_agent_website( $post = null ) {
307 echo esc_url( wpsight_get_listing_agent_website( $post ) );
308 }
309
310 /**
311 * wpsight_get_listing_agent_website()
312 *
313 * Return agent website of the
314 * current or a specific listing.
315 *
316 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
317 * @uses WPSight_Agents::get_listing_agent_website
318 * @return string|bool $agent_website Agent website of the listing agent or false
319 *
320 * @since 1.0.0
321 */
322 function wpsight_get_listing_agent_website( $post = null ) {
323 return WPSight_Agents::get_listing_agent_website( $post );
324 }
325
326 /**
327 * wpsight_agent_website()
328 *
329 * Echo wpsight_get_agent_website()
330 *
331 * @param integer $user_id User ID of corresponding agent (required)
332 * @uses wpsight_get_agent_website()
333 *
334 * @since 1.0.0
335 */
336 function wpsight_agent_website( $user_id ) {
337 echo esc_url( wpsight_get_agent_website( $user_id ) );
338 }
339
340 /**
341 * wpsight_get_agent_website()
342 *
343 * Return website of a specific agent.
344 *
345 * @param integer $user_id User ID of corresponding agent (required)
346 * @uses WPSight_Agents::get_agent_website
347 * @return string|bool $agent_website Agent website or false
348 *
349 * @since 1.0.0
350 */
351 function wpsight_get_agent_website( $user_id ) {
352 return WPSight_Agents::get_agent_website( $user_id );
353 }
354
355 /**
356 * wpsight_listing_agent_phone()
357 *
358 * Echo wpsight_get_listing_agent_phone()
359 *
360 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
361 * @uses wpsight_get_listing_agent_phone()
362 *
363 * @since 1.0.0
364 */
365 function wpsight_listing_agent_phone( $post = null ) {
366 echo esc_html( wpsight_get_listing_agent_phone( $post ) );
367 }
368
369 /**
370 * wpsight_get_listing_agent_phone()
371 *
372 * Return agent phone of the
373 * current or a specific listing.
374 *
375 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
376 * @uses WPSight_Agents::get_listing_agent_phone
377 * @return string|bool $agent_phone Agent phone of the listing agent or false
378 *
379 * @since 1.0.0
380 */
381 function wpsight_get_listing_agent_phone( $post = null ) {
382 return WPSight_Agents::get_listing_agent_phone( $post );
383 }
384
385 /**
386 * wpsight_agent_phone()
387 *
388 * Echo wpsight_get_agent_phone()
389 *
390 * @param integer $user_id User ID of corresponding agent (required)
391 * @uses wpsight_get_agent_phone()
392 *
393 * @since 1.0.0
394 */
395 function wpsight_agent_phone( $user_id ) {
396 echo esc_html( wpsight_get_agent_phone( $user_id ) );
397 }
398
399 /**
400 * wpsight_get_agent_phone()
401 *
402 * Return phone of a specific agent.
403 *
404 * @param integer $user_id User ID of corresponding agent (required)
405 * @uses WPSight_Agents::get_agent_phone
406 * @return string|bool $agent_phone Agent phone or false
407 *
408 * @since 1.0.0
409 */
410 function wpsight_get_agent_phone( $user_id ) {
411 return WPSight_Agents::get_agent_phone( $user_id );
412 }
413
414 /**
415 * wpsight_listing_agent_twitter()
416 *
417 * Echo wpsight_get_listing_agent_twitter()
418 *
419 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
420 * @param string $return Return X (Twitter) user or URL (defaults to 'user' - can be 'url')
421 * @uses wpsight_get_listing_agent_twitter()
422 *
423 * @since 1.0.0
424 */
425 function wpsight_listing_agent_twitter( $post = null, $return = 'user' ) {
426 echo esc_url( wpsight_get_listing_agent_twitter( $post, $return ) );
427 }
428
429 /**
430 * wpsight_get_listing_agent_twitter()
431 *
432 * Return agent twitter of the
433 * current or a specific listing.
434 *
435 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
436 * @param string $return Return Twitter user or URL (defaults to 'user' - can be 'url')
437 * @uses WPSight_Agents::get_listing_agent_twitter()
438 * @return string|bool $agent_twitter Agent twitter of the listing agent or false
439 *
440 * @since 1.0.0
441 */
442 function wpsight_get_listing_agent_twitter( $post = null, $return = 'user' ) {
443 return WPSight_Agents::get_listing_agent_twitter( $post, $return );
444 }
445
446 /**
447 * wpsight_agent_twitter()
448 *
449 * Echo wpsight_get_agent_twitter()
450 *
451 * @param integer $user_id User ID of corresponding agent (required)
452 * @param string $return Return Twitter user or URL (defaults to 'user' - can be 'url')
453 * @uses wpsight_get_agent_twitter()
454 *
455 * @since 1.0.0
456 */
457 function wpsight_agent_twitter( $user_id, $return = 'user' ) {
458 echo esc_url( wpsight_get_agent_twitter( $user_id, $return ) );
459 }
460
461 /**
462 * wpsight_get_agent_twitter()
463 *
464 * Return twitter of a specific agent.
465 *
466 * @param integer $user_id User ID of corresponding agent (required)
467 * @param string $return Return Twitter user or URL (defaults to 'user' - can be 'url')
468 * @uses WPSight_Agents::get_agent_twitter()
469 * @return string|bool $agent_twitter Agent twitter or false
470 *
471 * @since 1.0.0
472 */
473 function wpsight_get_agent_twitter( $user_id, $return = 'user' ) {
474 return WPSight_Agents::get_agent_twitter( $user_id, $return );
475 }
476
477 /**
478 * wpsight_listing_agent_facebook()
479 *
480 * Echo wpsight_get_listing_agent_facebook()
481 *
482 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
483 * @param string $return Return Facebook user or URL (defaults to 'user' - can be 'url')
484 * @uses wpsight_get_listing_agent_facebook()
485 *
486 * @since 1.0.0
487 */
488 function wpsight_listing_agent_facebook( $post = null, $return = 'user' ) {
489 echo esc_url( wpsight_get_listing_agent_facebook( $post, $return ) );
490 }
491
492 /**
493 * wpsight_get_listing_agent_facebook()
494 *
495 * Return agent facebook of the
496 * current or a specific listing.
497 *
498 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
499 * @param string $return Return Twitter user or URL (defaults to 'user' - can be 'url')
500 * @uses WPSight_Agents::get_listing_agent_facebook()
501 * @return string|bool $agent_facebook Agent facebook of the listing agent or false
502 *
503 * @since 1.0.0
504 */
505 function wpsight_get_listing_agent_facebook( $post = null, $return = 'user' ) {
506 return WPSight_Agents::get_listing_agent_facebook( $post, $return );
507 }
508
509 /**
510 * wpsight_agent_facebook()
511 *
512 * Echo wpsight_get_agent_facebook()
513 *
514 * @param integer $user_id User ID of corresponding agent (required)
515 * @param string $return Return Facebook user or URL (defaults to 'user' - can be 'url')
516 * @uses wpsight_get_agent_facebook()
517 *
518 * @since 1.0.0
519 */
520 function wpsight_agent_facebook( $user_id, $return = 'user' ) {
521 echo esc_url( wpsight_get_agent_facebook( $user_id, $return ) );
522 }
523
524 /**
525 * wpsight_get_agent_facebook()
526 *
527 * Return facebook of a specific agent.
528 *
529 * @param integer $user_id User ID of corresponding agent (required)
530 * @param string $return Return Facebook user or URL (defaults to 'user' - can be 'url')
531 * @uses WPSight_Agents::get_agent_facebook
532 * @return string|bool $agent_facebook Agent facebook or false
533 *
534 * @since 1.0.0
535 */
536 function wpsight_get_agent_facebook( $user_id, $return = 'user' ) {
537 return WPSight_Agents::get_agent_facebook( $user_id, $return );
538 }
539
540 /**
541 * wpsight_listing_agent_archive()
542 *
543 * Echo wpsight_get_listing_agent_archive()
544 *
545 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
546 * @param integer $user_id User ID of the corresponding agent (defaults to post_author)
547 * @uses wpsight_get_listing_agent_archive()
548 *
549 * @since 1.0.0
550 */
551 function wpsight_listing_agent_archive( $post = null, $user_id = false ) {
552 echo esc_url( wpsight_get_listing_agent_archive( $post, $user_id ) );
553 }
554
555 /**
556 * wpsight_get_listing_agent_archive()
557 *
558 * Get listing agent archive by adding
559 * "listings=1" to get_author_posts_url().
560 *
561 * @param integer|object $post Post ID or object of specific listing (defaults to null = current listing)
562 * @param integer $user_id User ID of the corresponding agent (defaults to post_author)
563 * @uses WPSight_Agents::get_listing_agent_archive()
564 * @return string $agent_archive Author posts URL with additional query arg "listing=1"
565 *
566 * @since 1.0.0
567 */
568 function wpsight_get_listing_agent_archive( $post = null, $user_id = false ) {
569 return WPSight_Agents::get_listing_agent_archive( $post, $user_id );
570 }
571
572 /**
573 * wpsight_agent_archive()
574 *
575 * Echo wpsight_get_agent_archive()
576 *
577 * @param integer $user_id User ID of corresponding agent (required)
578 * @uses wpsight_get_agent_archive()
579 *
580 * @since 1.0.0
581 */
582 function wpsight_agent_archive( $user_id ) {
583 echo esc_url( wpsight_get_agent_archive( $user_id ) );
584 }
585
586 /**
587 * wpsight_get_agent_archive()
588 *
589 * Get archive link of a specific agent.
590 *
591 * @param integer $user_id User ID of corresponding agent (required)
592 * @uses WPSight_Agents::get_agent_archive()
593 * @return string $agent_archive Author posts URL with additional query arg "listings=1"
594 *
595 * @since 1.0.0
596 */
597 function wpsight_get_agent_archive( $user_id ) {
598 return WPSight_Agents::get_agent_archive( $user_id );
599 }
600
601 /**
602 * Helper function to get posts
603 * by user and post type
604 *
605 * @param integer $user_id User ID (defaults to current user)
606 * @param string $post_type Post type (defaults to post)
607 * @uses WPSight_Agents::get_user_posts_by_type()
608 *
609 * @since 1.0.0
610 */
611 function wpsight_get_user_posts_by_type( $user_id = false, $post_type = 'post' ) {
612 return WPSight_Agents::get_user_posts_by_type( $user_id, $post_type );
613 }
614
615 /**
616 * wpsight_profile_contact_fields()
617 *
618 * Return user contact fields
619 *
620 * @uses WPSight_Agents::profile_contact_fields()
621 * @return array $fields Array of contact fields
622 *
623 * @since 1.0.0
624 */
625
626 function wpsight_profile_contact_fields() {
627 return WPSight_Agents::profile_contact_fields();
628 }
629