-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimply-rets-shortcode.php
873 lines (750 loc) · 41.2 KB
/
simply-rets-shortcode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
<?php
/*
*
* simply-rets-api-helper.php - Copyright (C) 2014-2015 SimplyRETS
* This file provides a class that has functions for retrieving and parsing
* data from the remote retsd api.
*
*/
/* Code starts here */
add_action('init', array('SrShortcodes', 'sr_residential_btn') );
class SrShortcodes {
/**
* Short code kitchen sink button registration
*/
public static function sr_residential_btn() {
if ( current_user_can('edit_posts') && current_user_can('edit_pages') ) {
add_filter('mce_external_plugins', array('SrShortcodes', 'sr_res_add_plugin') );
add_filter('mce_buttons', array('SrShortcodes', 'sr_register_res_button') );
}
}
public static function sr_register_res_button($buttons) {
array_push($buttons, "simplyRets");
return $buttons;
}
public static function sr_res_add_plugin($plugin_array) {
$plugin_array['simplyRets'] = plugins_url( 'assets/js/simply-rets-shortcodes.js', __FILE__ );
return $plugin_array;
}
public static function sr_int_map_search($atts) {
if(!is_array($atts)) $atts = array();
/** Private Parameters (shortcode attributes) */
$vendor = isset($atts['vendor']) ? $atts['vendor'] : '';
$brokers = isset($atts['brokers']) ? $atts['brokers'] : '';
$agent = isset($atts['agent']) ? $atts['agent'] : '';
$limit = isset($atts['limit']) ? $atts['limit'] : '';
$type_att = isset($atts['type']) ? $atts['type'] : '';
$content = "";
$search_form = "";
$gmaps_key = get_option('sr_google_api_key', '');
$idx_img = get_option('sr_thumbnail_idx_image');
$office_on_thumbnails = get_option('sr_office_on_thumbnails', false);
$agent_on_thumbnails = get_option('sr_agent_on_thumbnails', false);
$map_markup = "<div id='sr-map-search'
data-api-key='{$gmaps_key}'
data-idx-img='{$idx_img}'
data-office-on-thumbnails='{$office_on_thumbnails}'
data-agent-on-thumbnails='{$agent_on_thumbnails}'
data-limit='{$limit}'
data-vendor='{$vendor}'></div>";
$list_markup = !empty($atts['list_view'])
? "<div class=\"sr-map-search-list-view\"></div>"
: "";
$MLS_text = SrUtils::mkMLSText();
if(!empty($atts['search_form'])) {
$single_vendor = SrUtils::isSingleVendor();
$allVendors = get_option('sr_adv_search_meta_vendors', array());
$vendor = (empty($vendor) && $single_vendor == true && !empty($allVendors[0]))
? $allVendors[0]
: $vendor;
$prop_types = get_option("sr_adv_search_meta_types_$vendor"
, array("Residential", "Condominium", "Rental"));
$type_options = "";
foreach($prop_types as $key=>$type) {
if( $type == $type_att) {
$type_options .= "<option value='$type' selected />$type</option>";
} else {
$type_options .= "<option value='$type' />$type</option>";
}
}
$search_form = <<<HTML
<div class="sr-int-map-search-wrapper">
<div id="sr-search-wrapper">
<!-- <h3>Search Listings</h3> -->
<div class="sr-minmax-filters">
<form method="get" class="uk-grid-small sr-search sr-map-search-form" uk-grid>
<input type="hidden" name="sr-listings" value="sr-search">
<div class="uk-inline uk-width-1-1@s">
<span class="uk-form-icon" uk-icon="icon: search" style="width: 74px;"></span>
<input class="uk-input"
name="sr_keywords"
type="text"
placeholder="Subdivision, Zipcode, $MLS_text Area, $MLS_text Number, or Market Area"
/>
</div>
<div class="uk-inline uk-width-1-5@s">
<button class="uk-button uk-button-default uk-width-1-1 property-search-page-form-dropdown-buttons" type="button">Price<span uk-icon="icon: triangle-down"></span></button>
<div uk-dropdown="mode: click;" class="property-search-dropdown">
<h3>Price Range</h3>
<div class="uk-grid-small" uk-grid>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-minprice">
<input class="uk-input uk-width-1-2@s" name="sr_minprice" step="1000" min="0" type="number" placeholder="Min" />
</div>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-maxprice">
<input class="uk-input" name="sr_maxprice" step="1000" min="0" type="number" placeholder="Max" />
</div>
</div>
<input class="submit button btn uk-button uk-button-primary" type="submit" value="Update" style="width: 100%;">
</div>
</div>
<div class="uk-inline uk-width-1-5@s">
<button class="uk-button uk-button-default uk-width-1-1 property-search-page-form-dropdown-buttons" type="button">Beds<span uk-icon="icon: triangle-down"></span></button>
<div uk-dropdown="mode: click;" class="property-search-dropdown">
<h3>Beds</h3>
<div class="uk-grid-small" uk-grid>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-minbeds">
<input class="uk-input uk-width-1-2@s" name="sr_minbeds" step="1000" min="0" type="number" placeholder="Min" />
</div>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-maxbeds">
<input class="uk-input" name="sr_maxbeds" step="1000" min="0" type="number" placeholder="Max" />
</div>
</div>
<input class="submit button btn uk-button uk-button-primary" type="submit" value="Update" style="width: 100%;">
</div>
</div>
<div class="uk-inline uk-width-1-5@s">
<button class="uk-button uk-button-default uk-width-1-1 property-search-page-form-dropdown-buttons" type="button">Baths<span uk-icon="icon: triangle-down"></span></button>
<div uk-dropdown="mode: click;" class="property-search-dropdown">
<h3>Baths</h3>
<div class="uk-grid-small" uk-grid>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-minbaths">
<input class="uk-input" name="sr_minbaths" min="0" type="number" placeholder="Min" />
</div>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-maxbaths">
<input class="uk-input" name="sr_maxbaths" min="0" type="number" placeholder="Max" />
</div>
</div>
<input class="submit button btn uk-button uk-button-primary" type="submit" value="Update" style="width: 100%;">
</div>
</div>
<div class="uk-inline uk-width-1-5@s">
<div class="uk-width-1-1" uk-form-custom="target: true">
<div class="sr-search-field uk-width-1-1" id="sr-search-ptype">
<select class="property-search-page-type-select uk-width-1-1" name="sr_ptype">
<option selected="true" disabled="disabled" value="">Type</option>
$type_options;
</select>
</div>
</div>
</div>
<div class="uk-inline uk-width-1-5@s">
<input class="submit button btn uk-button uk-button-primary" type="submit" value="Update" style="margin-top: 0; width: 100%;">
</div>
<input type="hidden" name="sr_vendor" value="$vendor" />
<input type="hidden" name="sr_brokers" value="$brokers" />
<input type="hidden" name="sr_agent" value="$agent" />
<input type="hidden" name="limit" value="$limit" />
<div>
<div class="sr-sort-wrapper">
<label for="sr_sort">Sort by: </label>
<select class="select" name="sr_sort">
<option value="">Sort Options</option>
<option value="-listprice"> Price - High to Low</option>
<option value="listprice"> Price - Low to High</option>
<option value="-listdate"> List Date - New to Old</option>
<option value="listdate"> List date - Old to New</option>
</select>
</div>
</div>
</div>
<!-- <div class="sr-search-field" id="sr-search-ptype">
<select name="sr_ptype">
<option value="">Property Type</option>
$type_options;
</select>
</div> -->
<!-- <div class="sr-minmax-filters">
<div class="sr-search-field" id="sr-search-minprice">
<input name="sr_minprice" step="1000" min="0" type="number" placeholder="Min Price.." />
</div>
<div class="sr-search-field" id="sr-search-maxprice">
<input name="sr_maxprice" step="1000" min="0" type="number" placeholder="Max Price.." />
</div>
<div class="sr-search-field" id="sr-search-minbeds">
<input name="sr_minbeds" min="0" type="number" placeholder="Min Beds.." />
</div>
<div class="sr-search-field" id="sr-search-maxbeds">
<input name="sr_maxbeds" min="0" type="number" placeholder="Max Beds.." />
</div>
<div class="sr-search-field" id="sr-search-minbaths">
<input name="sr_minbaths" min="0" type="number" placeholder="Min Baths.." />
</div>
<div class="sr-search-field" id="sr-search-maxbaths">
<input name="sr_maxbaths" min="0" type="number" placeholder="Max Baths.." />
</div>
</div> -->
<!-- <p style="margin-bottom:5px">
<span><small><i>
</i></small></span>
To make a search, set your parameters
above and/or draw a section on the map.
</p> -->
</form>
</div>
</div>
HTML;
}
$content .= $map_markup;
$content .= $search_form;
$content .= $list_markup;
return $content;
}
/**
* [sr_residential] - Residential Listings Shortcode
*
* Show all residential listings with the ability to filter by mlsid
* to show a single listing.
* ie, [sr_residential mlsid="12345"]
*/
public function sr_residential_shortcode( $atts ) {
global $wp_query;
/**
* Check if `mlsId` was supplied. If so, just query that.
*/
if(!empty($atts['mlsid'])) {
$qs = '/' . $atts['mlsid'];
if(array_key_exists('vendor', $atts) && !empty($atts['vendor'])) {
$qs .= "?vendor={$atts['vendor']}";
}
$listings_content = SimplyRetsApiHelper::retrieveRetsListings($qs);
return $listings_content;
}
if(!is_array($atts)) {
$listing_params = array();
} else {
$listing_params = $atts;
}
/**
* The below parameters currently support multiple values via
* a semicolon delimeter. Eg, status="Active; Closed"
*
* Before we send them, build a proper query string that the API
* can understand. Eg, status=Active&status=Closed
*/
if( !isset($listing_params['neighborhoods'])
&& !isset($listing_params['postalcodes'])
&& !isset($listing_params['counties'])
&& !isset($listing_params['cities'])
&& !isset($listing_params['agent'])
&& !isset($listing_params['type'])
&& !isset($listing_params['status'])
&& !isset($listing_params['q'])
)
{
$listings_content = SimplyRetsApiHelper::retrieveRetsListings( $listing_params, $atts );
return $listings_content;
} else {
/**
* Neighborhoods filter is being used - check for multiple values and build query accordingly
*/
if( isset( $listing_params['neighborhoods'] ) && !empty( $listing_params['neighborhoods'] ) ) {
$neighborhoods = explode( ';', $listing_params['neighborhoods'] );
foreach( $neighborhoods as $key => $neighborhood ) {
$neighborhood = trim( $neighborhood );
$neighborhoods_string .= "neighborhoods=$neighborhood&";
}
$neighborhoods_string = str_replace(' ', '%20', $neighborhoods_string );
}
if( isset( $listing_params['cities'] ) && !empty( $listing_params['cities'] ) ) {
$cities = explode( ';', $listing_params['cities'] );
foreach( $cities as $key => $city ) {
$city = trim( $city );
$cities_string .= "cities=$city&";
}
$cities_string = str_replace(' ', '%20', $cities_string );
}
if( isset( $listing_params['agent'] ) && !empty( $listing_params['agent'] ) ) {
$agents = explode( ';', $listing_params['agent'] );
foreach( $agents as $key => $agent ) {
$agent = trim( $agent );
$agents_string .= "agent=$agent&";
}
$agents_string = str_replace(' ', '%20', $agents_string );
}
if( isset( $listing_params['type'] ) && !empty( $listing_params['type'] ) ) {
$ptypes = explode( ';', $listing_params['type'] );
foreach($ptypes as $key => $ptype) {
$ptype = trim($ptype);
$ptypes_string .= "type=$ptype&";
}
$ptypes_string = str_replace(' ', '%20', $ptypes_string );
}
if( isset( $listing_params['postalcodes'] ) && !empty( $listing_params['postalcodes'] ) ) {
$postalcodes = explode( ';', $listing_params['postalcodes'] );
foreach( $postalcodes as $key => $postalcode ) {
$postalcode = trim( $postalcode );
$postalcodes_string .= "postalCodes=$postalcode&";
}
$postalcodes_string = str_replace(' ', '%20', $postalcodes_string );
}
if( isset( $listing_params['counties'] ) && !empty( $listing_params['counties'] ) ) {
$counties = explode( ';', $listing_params['counties'] );
foreach( $counties as $key => $county ) {
$county = trim( $county );
$counties_string .= "counties=$county&";
}
$counties_string = str_replace(' ', '%20', $counties_string );
}
if( isset( $listing_params['q'] ) && !empty( $listing_params['q'] ) ) {
$keywords = explode( ';', $listing_params['q'] );
foreach( $keywords as $key => $keyword ) {
$kw = trim($keyword);
$q_string .= "q=$kw&";
}
$q_string = str_replace(' ', '%20', $q_string );
}
/**
* Multiple statuses
*/
if( isset( $listing_params['status'] ) && !empty( $listing_params['status'] ) ) {
$statuses = explode( ';', $listing_params['status'] );
foreach( $statuses as $key => $stat) {
$stat = trim($stat);
$statuses_string .= "status=$stat&";
}
$statuses_string = str_replace(' ', '%20', $statuses_string );
}
/**
* Build a regular query string for everything else
*/
foreach( $listing_params as $key => $value ) {
// Skip params that support multiple
if( $key !== 'postalcodes'
&& $key !== 'counties'
&& $key !== 'neighborhoods'
&& $key !== 'cities'
&& $key !== 'agent'
&& $key !== 'type'
&& $key !== 'status'
&& $key !== 'q'
) {
$params_string .= $key . "=" . $value . "&";
}
}
/**
* Final query string
*/
$qs = '?';
$qs .= $neighborhoods_string;
$qs .= $cities_string;
$qs .= $postalcodes_string;
$qs .= $counties_string;
$qs .= $params_string;
$qs .= $agents_string;
$qs .= $ptypes_string;
$qs .= $statuses_string;
$qs .= $q_string;
$listings_content = SimplyRetsApiHelper::retrieveRetsListings( $qs, $atts );
return $listings_content;
}
$listings_content = SimplyRetsApiHelper::retrieveRetsListings( $listing_params, $atts );
return $listings_content;
}
/**
* Open Houses Shortcode - [sr_openhouses]
*
* this is pulling condos and obviously needs to be pulling open houses
*/
public static function sr_openhouses_shortcode() {
$listing_params = array(
"type" => "cnd"
);
$listings_content = SimplyRetsApiHelper::retrieveRetsListings( $listing_params );
$listings_content = "Sorry we could not find any open houses that match your search.";
return $listings_content;
}
/**
* Search Form Shortcode - [sr_search_form]
*
* Can be used to insert a search form into any page or post. The shortcode takes
* optional parameters to have default searches:
* ie, [sr_search_form q="city"] or [sr_search_form minprice="500000"]
*/
public static function sr_search_form_shortcode( $atts ) {
ob_start();
$home_url = get_home_url();
$singleVendor = SrUtils::isSingleVendor();
$MLS_text = SrUtils::mkMLSText();
if( !is_array($atts) ) {
$atts = array();
}
$availableVendors = get_option('sr_adv_search_meta_vendors', array());
/** Configuration Parameters (shortcode attributes) */
$vendor = isset($atts['vendor']) ? $atts['vendor'] : '';
$brokers = isset($atts['brokers']) ? $atts['brokers'] : '';
$agent = isset($atts['agent']) ? $atts['agent'] : '';
$water = isset($atts['water']) ? $atts['water'] : '';
$limit = isset($atts['limit']) ? $atts['limit'] : '';
$config_type = isset($atts['type']) ? $atts['type'] : '';
$counties = isset($atts['counties']) ? $atts['counties'] : '';
$postalCodes = isset($atts['postalcodes']) ? $atts['postalcodes'] : '';
$neighborhoods = isset($atts['neighborhoods']) ? $atts['neighborhoods'] : '';
$cities = isset($atts['cities']) ? $atts['cities'] : '';
if($config_type === '') {
$config_type = isset($_GET['sr_ptype']) ? $_GET['sr_ptype'] : '';
}
if(empty($vendor) && $singleVendor === true) {
$vendor = $availableVendors[0];
}
$vendorOptions = "_$vendor";
/** User Facing Parameters */
$minbeds = array_key_exists('minbeds', $atts) ? $atts['minbeds'] : '';
$maxbeds = array_key_exists('maxbeds', $atts) ? $atts['maxbeds'] : '';
$minbaths = array_key_exists('minbaths', $atts) ? $atts['minbaths'] : '';
$maxbaths = array_key_exists('maxbaths', $atts) ? $atts['maxbaths'] : '';
$minprice = array_key_exists('minprice', $atts) ? $atts['minprice'] : '';
$maxprice = array_key_exists('maxprice', $atts) ? $atts['maxprice'] : '';
$keywords = array_key_exists('q', $atts) ? $atts['q'] : '';
$sort = array_key_exists('sort', $atts) ? $atts['sort'] : '';
/** Advanced Search Parameters */
$adv_status = array_key_exists('status', $atts) ? $atts['status'] : '';
$lotsize = array_key_exists('lotsize', $atts) ? $atts['lotsize'] : '';
$area = array_key_exists('area', $atts) ? $atts['area'] : '';
$adv_features = isset($_GET['sr_features']) ? $_GET['sr_features'] : array();
$adv_neighborhoods = isset($_GET['sr_neighborhoods']) ? $_GET['sr_neighborhoods'] : array();
/*
* Get the initial values for `cities`. If a query parameter
is set, use-that, otherwise check for a 'cities' attribute
on the [sr_search_form] short-code
*/
$adv_cities = isset($_GET['sr_cities']) ? $_GET['sr_cities'] : array();
if (empty($adv_cities) && array_key_exists('cities', $atts)) {
$adv_cities = explode(";", $atts['cities']);
}
$sort_price_hl = ($sort == "-listprice") ? "selected" : '';
$sort_price_lh = ($sort == "listprice") ? "selected" : '';
$sort_date_hl = ($sort == "-listdate") ? "selected" : '';
$sort_date_lh = ($sort == "listdate") ? "selected" : '';
/**
* Advanced Search Form.
* Used by [sr_search_form advanced='true']
*
* We populate the options used in the form by the meta data received from retsd daily.
*
* price range, *city, *neighborhood (location), * type (condo, townhome, residential),
* *amenities (int/ext), *status (active, pending, sold), area.
*/
$type_options = '';
$status_options = "";
$available_property_types = get_option("sr_adv_search_meta_types_$vendor", array());
$default_type_option = '<option value="">Property Type</option>';
if( empty( $available_property_types ) ) {
$available_property_types = array("Residential", "Condominium", "Rental" );
}
if((is_array($config_type) == TRUE) && isset($_GET['sr_ptype'])) {
$type_string = join(';', $config_type);
$default_type_option = "<option value='$type_string' selected>Property Type</option>";
foreach($available_property_types as $key=>$value) {
$type_options .= "<option value='$value' />$value</option>";
}
} elseif(strpos($config_type, ";") !== FALSE) {
$default_type_option = "<option value='$config_type' selected>Property Type</option>";
foreach($available_property_types as $key=>$value) {
$type_options .= "<option value='$value' />$value</option>";
}
} else {
foreach($available_property_types as $key=>$value) {
if( $value == $config_type ) {
$type_options .= "<option value='$value' selected />$value</option>";
} else {
$type_options .= "<option value='$value' />$value</option>";
}
}
}
$city_options = "";
$adv_search_cities = get_option("sr_adv_search_meta_city_$vendor", array());
sort($adv_search_cities);
foreach( (array)$adv_search_cities as $key=>$city ) {
$checked = in_array($city, (array)$adv_cities) ? 'selected="selected"' : '';
$city_options .= "<option value='$city' $checked>$city</option>";
}
$adv_search_status = get_option("sr_adv_search_meta_status_$vendor", array());
foreach( (array)$adv_search_status as $key=>$status) {
if( $status == $adv_status ) {
$status_options .= "<option value='$status' selected />$status</option>";
} else {
$status_options .= "<option value='$status' />$status</option>";
}
}
$location_options = "";
$adv_search_neighborhoods= get_option("sr_adv_search_meta_neighborhoods_$vendor", array());
sort( $adv_search_neighborhoods );
foreach( (array)$adv_search_neighborhoods as $key=>$neighborhood) {
$checked = in_array($neighborhood, (array)$adv_neighborhoods) ? 'selected="selected"' : '';
$location_options .= "<option value='$neighborhood' $checked>$neighborhood</option>";
}
$features_options = "";
$adv_search_features = get_option("sr_adv_search_meta_features_$vendor", array());
sort( $adv_search_features );
foreach( (array)$adv_search_features as $key=>$feature) {
$checked = in_array($feature, (array)$adv_features) ? 'checked="checked"' : '';
$features_options .= "<li class='sr-adv-search-option'>"
."<label><input name='sr_features[]' type='checkbox' value='$feature' $checked />$feature</label></li>";
}
// currently unused
// $adv_search_counties = get_option( 'sr_adv_search_meta_county' );
// foreach( $adv_search_counties as $key=>$county) {
// $county_options .= "<option value='$county' />$county</option>";
// }
// currently unused
// $adv_search_amenities = get_option( 'sr_adv_search_option_amenities' );
// foreach( $adv_search_amenities as $key=>$amenity) {
// $amenity_options .= "<li class='sr-adv-search-option'>"
// ."<label><input name='sr_features[]' type='checkbox' value='$amenity' />$amenity</label></li>";
// }
if( array_key_exists('advanced', $atts) && $atts['advanced'] == 'true' || $atts['advanced'] == 'True' ) {
?>
<div class="sr-adv-search-wrap">
<form method="get" class="sr-search" action="<?php echo $home_url; ?>">
<input type="hidden" name="sr-listings" value="sr-search">
<input type="hidden" name="advanced" value="true">
<h2>Advanced Listings Search</h2>
<div class="sr-adv-search-minmax sr-adv-search-part">
<div class="sr-adv-search-col1">
<!-- Keyword / Property Type -->
<div class="sr-minmax-filters">
<div class="sr-search-field" id="sr-search-keywords">
<input name="sr_keywords"
type="text"
placeholder="Subdivision, Zipcode, <?php echo $MLS_text ?> Area, <?php echo $MLS_text ?> Number, or Market Area"
value="<?php echo $keywords ?>" />
</div>
<div class="sr-search-field" id="sr-search-ptype">
<select name="sr_ptype">
<?php echo $default_type_option; ?>
<?php echo $type_options; ?>
</select>
</div>
</div>
</div>
<div class="sr-minmax-filters">
<div class="sr-adv-search-col2 sr-adv-search-price">
<label><strong>Price Range</strong></label>
<input step="1000" min="0" type="number" name="sr_minprice" placeholder="10000" value="<?php echo $minprice; ?>"/>
<input step="1000" min="0" type="number" name="sr_maxprice" placeholder="1000000" value="<?php echo $maxprice; ?>"/>
</div>
<div class="sr-adv-search-col4">
<label for="sr-adv-minprice"><strong>Bedrooms</strong></label>
<select name="sr_minbeds" id="sr-adv-minbeds">
<option value="<?php echo $minbeds; ?>"><?php echo $minbeds; ?>+</option>
<option value="1">1+</option>
<option value="2">2+</option>
<option value="3">3+</option>
<option value="4">4+</option>
<option value="5">5+</option>
<option value="6">6+</option>
<option value="7">7+</option>
<option value="8">8+</option>
</select>
</div>
<div class="sr-adv-search-col4">
<label><strong>Bathrooms</strong></label>
<select name="sr_minbaths" id="sr-adv-minbaths">
<option value="<?php echo $minbaths; ?>"><?php echo $minbaths; ?>+</option>
<option value="1">1+</option>
<option value="2">2+</option>
<option value="3">3+</option>
<option value="4">4+</option>
<option value="5">5+</option>
<option value="6">6+</option>
<option value="7">7+</option>
<option value="8">8+</option>
</select>
</div>
</div>
<div class="sr-minmax-filters">
<div class="sr-adv-search-col2">
<label><strong>Status</strong></label>
<select name="status" id="sr-adv-search-status">
<option value="">All</option>
<?php echo $status_options; ?>
</select>
</div>
<div class="sr-adv-search-col4">
<label for="sr-adv-lotsize"><strong>Lot Size</strong></label>
<input type="number" name="sr_lotsize" placeholder="3500" value="<?php echo $lotsize; ?>"/>
</div>
<div class="sr-adv-search-col4">
<label><strong>Area (SqFt)</strong></label>
<input type="number" name="sr_area" value="<?php echo $area; ?>" placeholder="1500" />
</div>
</div>
<div class="sr-minmax-filters">
<div class="sr-adv-search-col2">
<label><strong>Cities</strong></label>
<select name='sr_cities[]' multiple>
<?php echo $city_options ?>
</select>
</div>
<div class="sr-adv-search-col2">
<label><strong>Locations</strong></label>
<select name="sr_neighborhoods[]" multiple>
<?php echo $location_options ?>
</select>
</div>
</div>
<div class="sr-minmax-filters">
<div class="sr-adv-search-amenities-wrapper">
<label><strong>Features</strong></label>
<div class="sr-adv-search-amenities-wrapper-inner">
<?php echo $features_options; ?>
</div>
</div>
</div>
</div>
<input type="hidden" name="water" value="<?php echo $water; ?>" />
<input type="hidden" name="sr_vendor" value="<?php echo $vendor; ?>" />
<input type="hidden" name="sr_brokers" value="<?php echo $brokers; ?>" />
<input type="hidden" name="sr_agent" value="<?php echo $agent; ?>" />
<input type="hidden" name="sr_counties" value="<?php echo $counties; ?>" />
<input type="hidden" name="limit" value="<?php echo $limit; ?>" />
<input type="hidden" name="sr_postalCodes" value="<?php echo $postalCodes; ?>" />
<div>
<button class="btn button submit btn-submit" style="display:inline-block;">Search</button>
<div class="sr-sort-wrapper">
<label for="sr_sort">Sort by: </label>
<select name="sr_sort">
<option value="-listprice" <?php echo $sort_price_hl ?>> Price - High to Low</option>
<option value="listprice" <?php echo $sort_price_lh ?>> Price - Low to High</option>
<option value="-listdate" <?php echo $sort_date_hl ?> > List Date - New to Old</option>
<option value="listdate" <?php echo $sort_date_lh ?> > List date - Old to New</option>
</select>
</div>
</div>
</form>
</div>
<br>
<?php
return ob_get_clean();
}
?>
<div id="sr-search-wrapper">
<!-- <h3>Search Listings</h3> -->
<form method="get" class="sr-search uk-margin-top" action="<?php echo $home_url; ?>">
<input type="hidden" name="sr-listings" value="sr-search">
<div class="uk-inline uk-width-1-1@s">
<span class="uk-form-icon" uk-icon="icon: search" style="margin-top: -8px;"></span>
<div class="sr-minmax-filters">
<div class="sr-search-field" id="sr-search-keywords" style="width: 100%;">
<input class="uk-input"
name="sr_keywords"
type="text"
style="padding-left: 35px;"
placeholder="Subdivision, Zipcode, <?php echo $MLS_text ?> Area, <?php echo $MLS_text ?> Number, or Market Area"
value="<?php echo $keywords ?>" />
</div>
</div>
</div>
<div class="sr-minmax-filters uk-grid-small" uk-grid>
<div class="uk-inline uk-width-1-5@s">
<button class="uk-button uk-button-default uk-width-1-1 property-search-page-form-dropdown-buttons" type="button">Price<span uk-icon="icon: triangle-down"></span></button>
<div uk-dropdown="mode: click;" class="property-search-dropdown">
<h3>Price Range</h3>
<div class="uk-grid-small" uk-grid>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-minprice">
<input class="uk-input uk-width-1-2@s" name="sr_minprice" step="1000" min="0" type="number" placeholder="Min" value="<?php echo $minprice; ?>" />
</div>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-maxprice">
<input class="uk-input" name="sr_maxprice" step="1000" min="0" type="number" placeholder="Max" value="<?php echo $maxprice; ?>" />
</div>
</div>
<input class="submit button btn uk-button uk-button-primary" type="submit" value="Update" style="width: 100%;">
</div>
</div>
<div class="uk-inline uk-width-1-5@s">
<button class="uk-button uk-button-default uk-width-1-1 property-search-page-form-dropdown-buttons" type="button">Beds<span uk-icon="icon: triangle-down"></span></button>
<div uk-dropdown="mode: click;" class="property-search-dropdown">
<h3>Beds</h3>
<div class="uk-grid-small" uk-grid>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-minbeds">
<input class="uk-input uk-width-1-2@s" name="sr_minbeds" min="0" type="number" value="<?php echo $minbeds; ?>" placeholder="Min" />
</div>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-maxbeds">
<input class="uk-input uk-width-1-2@s" name="sr_maxbeds" min="0" type="number" value="<?php echo $maxbeds; ?>" placeholder="Max" />
</div>
</div>
<input class="submit button btn uk-button uk-button-primary" type="submit" value="Update" style="width: 100%;">
</div>
</div>
<div class="uk-inline uk-width-1-5@s">
<button class="uk-button uk-button-default uk-width-1-1 property-search-page-form-dropdown-buttons" type="button">Baths<span uk-icon="icon: triangle-down"></span></button>
<div uk-dropdown="mode: click;" class="property-search-dropdown">
<h3>Baths</h3>
<div class="uk-grid-small" uk-grid>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-minbaths">
<input class="uk-input uk-width-1-2@s"name="sr_minbaths" min="0" type="number" value="<?php echo $minbaths; ?>" placeholder="Min" />
</div>
<div class="sr-search-field uk-width-1-2@s" id="sr-search-maxbaths">
<input class="uk-input uk-width-1-2@s" name="sr_maxbaths" min="0" type="number" value="<?php echo $maxbaths; ?>" placeholder="Max" />
</div>
</div>
<input class="submit button btn uk-button uk-button-primary" type="submit" value="Update" style="width: 100%;">
</div>
</div>
<div class="uk-inline uk-width-1-5@s">
<div class="uk-width-1-1" uk-form-custom="target: true">
<div class="sr-search-field" id="sr-search-ptype" style="width: 100%;">
<select class="property-search-page-type-select uk-width-1-1" name="sr_ptype">
<option selected="true" disabled="disabled" value="">Type</option>
<?php echo $type_options; ?>
</select>
</div>
</div>
</div>
<div class="uk-inline uk-width-1-5@s">
<input class="submit button btn uk-button uk-button-primary" type="submit" value="Update" style="margin-top: 0; width: 100%;">
</div>
</div>
<div>
<div class="sr-sort-wrapper uk-margin-bottom">
<label for="sr_sort">Sort by: </label>
<select class="select" name="sr_sort">
<option value="-listprice" <?php echo $sort_price_hl ?>> Price - High to Low</option>
<option value="listprice" <?php echo $sort_price_lh ?>> Price - Low to High</option>
<option value="-listdate" <?php echo $sort_date_hl ?> > List Date - New to Old</option>
<option value="listdate" <?php echo $sort_date_lh ?> > List date - Old to New</option>
</select>
</div>
</div>
<input type="hidden" name="water" value="<?php echo $water; ?>" />
<input type="hidden" name="sr_vendor" value="<?php echo $vendor; ?>" />
<input type="hidden" name="sr_brokers" value="<?php echo $brokers; ?>" />
<input type="hidden" name="sr_agent" value="<?php echo $agent; ?>" />
<input type="hidden" name="sr_counties" value="<?php echo $counties; ?>" />
<input type="hidden" name="sr_postalCodes" value="<?php echo $postalCodes; ?>" />
<input type="hidden" name="sr_neighborhoods" value="<?php echo $neighborhoods; ?>" />
<input type="hidden" name="sr_cities" value="<?php echo $cities; ?>" />
<input type="hidden" name="limit" value="<?php echo $limit; ?>" />
<input type="hidden" name="status" value="<?php echo $adv_status; ?>" />
</form>
</div>
<?php
return ob_get_clean();
}
/**
* TODO: sr_listings_slider should support attributes that can
* take multiple values (eg, postalCodes, counties). #32
*/
public static function sr_listing_slider_shortcode( $atts ) {
ob_start();
$settings = array();
$atts['limit'] = empty($atts['limit']) ? 8 : $atts['limit'];
if ($atts['vendor']) {
$settings['vendor'] = $atts['vendor'];
}
$settings['random'] = empty($atts['random']) ? NULL : $atts['random'];
$slider = SimplyRetsApiHelper::retrieveListingsSlider($atts, $settings);
echo $slider;
return ob_get_clean();
}
}