-
Notifications
You must be signed in to change notification settings - Fork 30
/
geodirectory_template_actions.php
3630 lines (3209 loc) · 136 KB
/
geodirectory_template_actions.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
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Template functions that affect the output of most GeoDirectory pages
*
* @since 1.0.0
* @package GeoDirectory
*/
###############################################
########### DYNAMIC CONTENT ###################
###############################################
/**
* Outputs the CSS from the compatibility settings page.
*
* @since 1.0.0
* @package GeoDirectory
*/
function gd_compat_styles()
{
$tc = get_option('theme_compatibility_setting');
echo "<style id='gd-compat-styles' type='text/css'>";
echo $tc['geodir_theme_compat_css'];
echo "</style>";
}
/**
* Outputs the JS from the compatibility settings page.
*
* @since 1.0.0
* @package GeoDirectory
*/
function gd_compat_script()
{
$tc = get_option('theme_compatibility_setting');
echo "<script>";
echo $tc['geodir_theme_compat_js'];
echo " </script>";
}
/**
* Outputs the 'geodir_top_content_add' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_top_content_add_dynamic()
{
$tc = get_option('theme_compatibility_setting');
echo $tc['geodir_top_content_add'];
}
/**
* Outputs the 'geodir_before_main_content_add' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_before_main_content_add_dynamic()
{
$tc = get_option('theme_compatibility_setting');
echo $tc['geodir_before_main_content_add'];
}
/**
* Outputs the 'geodir_full_page_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_full_page_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_full_page_class_filter'];
}
/**
* Outputs the 'geodir_before_widget_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_before_widget_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_before_widget_filter'];
}
/**
* Outputs the 'geodir_after_widget_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_after_widget_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_after_widget_filter'];
}
/**
* Outputs the 'geodir_before_title_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_before_title_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_before_title_filter'];
}
/**
* Outputs the 'geodir_after_title_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_after_title_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_after_title_filter'];
}
/**
* Outputs the 'geodir_menu_li_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_menu_li_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_menu_li_class_filter'];
}
/**
* Outputs the 'geodir_sub_menu_ul_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_sub_menu_ul_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_sub_menu_ul_class_filter'];
}
/**
* Outputs the 'geodir_sub_menu_li_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_sub_menu_li_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_sub_menu_li_class_filter'];
}
/**
* Outputs the 'geodir_menu_a_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_menu_a_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_menu_a_class_filter'];
}
/**
* Outputs the 'geodir_sub_menu_a_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_sub_menu_a_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_sub_menu_a_class_filter'];
}
/**
* Outputs the 'geodir_location_switcher_menu_li_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_location_switcher_menu_li_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_location_switcher_menu_li_class_filter'];
}
/**
* Outputs the 'geodir_location_switcher_menu_a_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_location_switcher_menu_a_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_location_switcher_menu_a_class_filter'];
}
/**
* Outputs the 'geodir_location_switcher_menu_sub_ul_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_location_switcher_menu_sub_ul_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_location_switcher_menu_sub_ul_class_filter'];
}
/**
* Outputs the 'geodir_location_switcher_menu_sub_li_class_filter' from the compatibility settings page.
*
* This is called via filter and should not really be used direct.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_location_switcher_menu_sub_li_class_dynamic()
{
$tc = get_option('theme_compatibility_setting');
return $tc['geodir_location_switcher_menu_sub_li_class_filter'];
}
add_action('setup_theme', 'geodir_content_actions_dynamic', 10);
/**
* Changed the output settings depending on the compatibility settings.
*
* This function checks the theme compatibility settings and filters the output accordingly.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_content_actions_dynamic()
{
$tc = get_option('theme_compatibility_setting');
//print_r($tc);
if (empty($tc)) {
return;
}
//php
if (!empty($tc['geodir_theme_compat_code'])) {
include_once('geodirectory-functions/compatibility/' . $tc['geodir_theme_compat_code'] . '.php');
}
//geodir_full_page_class
if (!empty($tc['geodir_full_page_class_filter'])) {
add_filter('geodir_full_page_class', 'geodir_full_page_class_dynamic', 10);
}
//widget before filter
if (!empty($tc['geodir_before_widget_filter'])) {
add_filter('geodir_before_widget', 'geodir_before_widget_dynamic', 10);
}
//widget after filter
if (!empty($tc['geodir_after_widget_filter'])) {
add_filter('geodir_after_widget', 'geodir_after_widget_dynamic', 10);
}
//widget before title filter
if (!empty($tc['geodir_before_title_filter'])) {
add_filter('geodir_before_title', 'geodir_before_title_dynamic', 10);
}
//widget before title filter
if (!empty($tc['geodir_after_title_filter'])) {
add_filter('geodir_after_title', 'geodir_after_title_dynamic', 10);
}
//menu li class
if (!empty($tc['geodir_menu_li_class_filter'])) {
add_filter('geodir_menu_li_class', 'geodir_menu_li_class_dynamic', 10);
}
//menu ul class
if (!empty($tc['geodir_sub_menu_ul_class_filter'])) {
add_filter('geodir_sub_menu_ul_class', 'geodir_sub_menu_ul_class_dynamic', 10);
}
//menu sub li class
if (!empty($tc['geodir_sub_menu_li_class_filter'])) {
add_filter('geodir_sub_menu_li_class', 'geodir_sub_menu_li_class_dynamic', 10);
}
//menu a class
if (!empty($tc['geodir_menu_a_class_filter'])) {
add_filter('geodir_menu_a_class', 'geodir_menu_a_class_dynamic', 10);
}
//menu sub a class
if (!empty($tc['geodir_sub_menu_a_class_filter'])) {
add_filter('geodir_sub_menu_a_class', 'geodir_sub_menu_a_class_dynamic', 10);
}
//location menu li class
if (!empty($tc['geodir_location_switcher_menu_li_class_filter'])) {
add_filter('geodir_location_switcher_menu_li_class', 'geodir_location_switcher_menu_li_class_dynamic', 10);
}
//location menu sub ul class
if (!empty($tc['geodir_location_switcher_menu_sub_ul_class_filter'])) {
add_filter('geodir_location_switcher_menu_sub_ul_class', 'geodir_location_switcher_menu_sub_ul_class_dynamic', 10);
}
//location menu sub li class
if (!empty($tc['geodir_location_switcher_menu_sub_li_class_filter'])) {
add_filter('geodir_location_switcher_menu_sub_li_class', 'geodir_location_switcher_menu_sub_li_class_dynamic', 10);
}
//location menu a class
if (!empty($tc['geodir_location_switcher_menu_a_class_filter'])) {
add_filter('geodir_location_switcher_menu_a_class', 'geodir_location_switcher_menu_a_class_dynamic', 10);
}
// compat styles
if (!empty($tc['geodir_theme_compat_css'])) {
add_action('wp_head', 'gd_compat_styles');
}
// compat js
if (!empty($tc['geodir_theme_compat_js'])) {
add_action('wp_footer', 'gd_compat_script');
}
// geodir_top_content_add
if (!empty($tc['geodir_top_content_add'])) {
add_action('geodir_top_content', 'geodir_top_content_add_dynamic', 10, 1);
}
// geodir_before_main_content_add
if (!empty($tc['geodir_before_main_content_add'])) {
add_action('geodir_before_main_content', 'geodir_before_main_content_add_dynamic', 10, 1);
}
}
###############################################
########### DETAILS PAGE ACTIONS ##############
###############################################
// action for adding the wrapper div opening tag
add_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10, 3);
/**
* Outputs the opening HTML wrapper div if the compatibility settings are present.
*
* @param string $type Optional. Depreciated.
* @param string $id Optional. The div id.
* @param string $class Optional. The div class.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_wrapper_open($type = '', $id = '', $class = '')
{
$tc = get_option('theme_compatibility_setting');
if (!empty($tc['geodir_wrapper_open_replace'])) {
$text = $tc['geodir_wrapper_open_replace'];
} else {
$text = '<div id="[id]" class="[class]">';
}
if (!empty($tc['geodir_wrapper_open_id'])) {
$id = $tc['geodir_wrapper_open_id'];
}
if (!empty($tc['geodir_wrapper_open_class'])) {
$class = $tc['geodir_wrapper_open_class'];
}
$text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
echo $text;
}
// action for adding the wrapperdiv closing tag
add_action('geodir_wrapper_close', 'geodir_action_wrapper_close', 10, 1);
/**
* Outputs the closing HTML wrapper div if the compatibility settings are present.
*
* @param string $type Optional. Depreciated.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_wrapper_close($type = '')
{
$tc = get_option('theme_compatibility_setting');
if (!empty($tc['geodir_wrapper_close_replace'])) {
$text = $tc['geodir_wrapper_close_replace'];
} else {
$text = '</div><!-- wrapper ends here-->';
}
echo $text;
}
// action for adding the content div opening tag
add_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10, 3);
/**
* Outputs the opening HTML content wrapper div if the compatibility settings are present.
*
* @param string $type Optional. Page type.
* @param string $id Optional. The div id.
* @param string $class Optional. The div class.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_wrapper_content_open($type = '', $id = '', $class = '')
{
if ($type == 'home-page' && $width = get_option('geodir_width_home_contant_section')) {
$width_css = 'style="width:' . $width . '%;"';
} elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_contant_section')) {
$width_css = 'style="width:' . $width . '%;"';
} elseif ($type == 'search-page' && $width = get_option('geodir_width_search_contant_section')) {
$width_css = 'style="width:' . $width . '%;"';
} elseif ($type == 'author-page' && $width = get_option('geodir_width_author_contant_section')) {
$width_css = 'style="width:' . $width . '%;"';
} else {
$width_css = '';
}
$tc = get_option('theme_compatibility_setting');
if (!empty($tc['geodir_wrapper_content_open_replace'])) {
$text = $tc['geodir_wrapper_content_open_replace'];
} else {
$text = '<div id="[id]" class="[class]" role="main" [width_css]>';
}
if (!empty($tc['geodir_wrapper_content_open_id'])) {
$id = $tc['geodir_wrapper_content_open_id'];
}
if (!empty($tc['geodir_wrapper_content_open_class'])) {
$class = $tc['geodir_wrapper_content_open_class'];
}
$text = str_replace(array("[id]", "[class]", "[width_css]"), array($id, $class, $width_css), $text);
echo $text;
}
// action for adding the primary div closing tag
add_action('geodir_wrapper_content_close', 'geodir_action_wrapper_content_close', 10, 1);
/**
* Outputs the closing HTML content wrapper div if the compatibility settings are present.
*
* @param string $type Optional. Depreciated.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_wrapper_content_close($type = '')
{
$tc = get_option('theme_compatibility_setting');
if (!empty($tc['geodir_wrapper_content_close_replace'])) {
$text = $tc['geodir_wrapper_content_close_replace'];
} else {
$text = '</div><!-- content ends here-->';
}
echo $text;
}
// action for adding the <article> opening tag
add_action('geodir_article_open', 'geodir_action_article_open', 10, 4);
/**
* Outputs the opening HTML article wrapper if the compatibility settings are present.
*
* @param string $type Optional. Depreciated.
* @param string $id Optional. The element id.
* @param string $class Optional. The element class.
* @param string $itemtype Optional. The element itemtype.
* @since 1.0.0
* @since 1.5.4 Removed itemscope itemtype="[itemtype]" as now added
* @package GeoDirectory
*/
function geodir_action_article_open($type = '', $id = '', $class = '', $itemtype = '')
{
$class = implode(" ", $class);
$tc = get_option('theme_compatibility_setting');
if (!empty($tc['geodir_article_open_replace'])) {
$text = $tc['geodir_article_open_replace'];
} else {
$text = '<article id="[id]" class="[class]" >';
}
if (!empty($tc['geodir_article_open_id'])) {
$id = $tc['geodir_article_open_id'];
}
if (!empty($tc['geodir_article_open_class'])) {
$class = $tc['geodir_article_open_class'];
}
$text = str_replace(array("[id]", "[class]", "[itemtype]"), array($id, $class, $itemtype), $text);
echo $text;
}
// action for adding the primary div closing tag
add_action('geodir_article_close', 'geodir_action_article_close', 10, 1);
/**
* Outputs the closing HTML article wrapper if the compatibility settings are present.
*
* @param string $type Optional. Depreciated.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_article_close($type = '')
{
$tc = get_option('theme_compatibility_setting');
if (!empty($tc['geodir_article_close_replace'])) {
$text = $tc['geodir_article_close_replace'];
} else {
$text = '</article><!-- article ends here-->';
}
echo $text;
}
// action for adding the sidebar opening tag
add_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10, 4);
/**
* Outputs the opening HTML aside right sidebar wrapper if the compatibility settings are present.
*
* @param string $type Optional. Page type.
* @param string $id Optional. The element id.
* @param string $class Optional. The element class.
* @param string $itemtype Optional. The element itemtype.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '')
{
if ($type == 'home-page' && $width = get_option('geodir_width_home_right_section')) {
$width_css = 'style="width:' . $width . '%;"';
} elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_right_section')) {
$width_css = 'style="width:' . $width . '%;"';
} elseif ($type == 'search-page' && $width = get_option('geodir_width_search_right_section')) {
$width_css = 'style="width:' . $width . '%;"';
} elseif ($type == 'author-page' && $width = get_option('geodir_width_author_right_section')) {
$width_css = 'style="width:' . $width . '%;"';
} else {
$width_css = '';
}
$tc = get_option('theme_compatibility_setting');
if (!empty($tc['geodir_sidebar_right_open_replace'])) {
$text = $tc['geodir_sidebar_right_open_replace'];
} else {
$text = '<aside id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>';
}
if (!empty($tc['geodir_sidebar_right_open_id'])) {
$id = $tc['geodir_sidebar_right_open_id'];
}
if (!empty($tc['geodir_sidebar_right_open_class'])) {
$class = $tc['geodir_sidebar_right_open_class'];
}
$text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
echo $text;
}
// action for adding the primary div closing tag
add_action('geodir_sidebar_right_close', 'geodir_action_sidebar_right_close', 10, 1);
/**
* Outputs the closing HTML aside right sidebar wrapper if the compatibility settings are present.
*
* @param string $type Optional. Depreciated.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_sidebar_right_close($type = '')
{
$tc = get_option('theme_compatibility_setting');
if (!empty($tc['geodir_sidebar_right_close_replace'])) {
$text = $tc['geodir_sidebar_right_close_replace'];
} else {
$text = '</aside><!-- sidebar ends here-->';
}
echo $text;
}
// action for adding the details page top widget area
add_action('geodir_detail_before_main_content', 'geodir_action_geodir_set_preview_post', 8);
add_action('geodir_detail_before_main_content', 'geodir_action_geodir_preview_code', 9);
add_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10);
add_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20);
/**
* Set the $post value if previewing a post.
*
* @global object $post The current post object.
* @global bool $preview True if the current page is a preview page. False if not.
* @global object $gd_session GeoDirectory Session object.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_geodir_set_preview_post()
{
global $post, $preview, $gd_session;
$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
if (!$preview || $is_backend_preview) {
return;
}// bail if not previewing
$listing_type = isset($_REQUEST['listing_type']) ? sanitize_text_field($_REQUEST['listing_type']) : '';
$fields_info = geodir_get_custom_fields_type($listing_type);
foreach ($_REQUEST as $pkey => $pval) {
if ($pkey == 'geodir_video') {
$tags = '<iframe>';
} else if ($pkey == 'post_desc') {
$tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>';
} else if (is_array($fields_info) && isset($fields_info[$pkey]) && ($fields_info[$pkey] == 'textarea' || $fields_info[$pkey] == 'html')) {
$tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>';
} else if (is_array($_REQUEST[$pkey])) {
$tags = 'skip_field';
} else {
$tags = '';
}
/**
* Allows the filtering of the allowed HTML tags per field when submitting from frontend add listing page.
*
* @since 1.0.0
* @param string $tags The allowed HTML tags for the field. Can be many things, for example the description allows these tags '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>'.
* @param string|array $pkey The field id/name. If array then value is set as "skip_field".
*/
$tags = apply_filters('geodir_save_post_key', $tags, $pkey);
if ($tags != 'skip_field') {
$_REQUEST[$pkey] = strip_tags($_REQUEST[$pkey], $tags);
}
}
$post = (object)$_REQUEST;
if (isset($post->video)) {
$post->video = stripslashes($post->video);
}
if (isset($post->Video2)) {
$post->Video2 = stripslashes($post->Video2);
}
$post_type = $post->listing_type;
$post_type_info = get_post_type_object($post_type);
$listing_label = $post_type_info->labels->singular_name;
$term_icon = '';
if (!empty($post->post_category)) {
foreach ($post->post_category as $post_taxonomy => $post_term) {
if ($post_term != '' && !is_array($post_term)) {
$post_term = explode(',', trim($post_term, ','));
}
if (is_array($post_term)) {
$post_term = array_unique($post_term);
}
if (!empty($post_term)) {
foreach ($post_term as $cat_id) {
$cat_id = trim($cat_id);
if ($cat_id != '') {
$term_icon = get_option('geodir_default_marker_icon');
if (isset($post->post_default_category) && $post->post_default_category == $cat_id) {
if ($term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type)) {
if (isset($term_icon_url['src']) && $term_icon_url['src'] != '')
$term_icon = $term_icon_url['src'];
break;
}
}
}
}
}
}
}
$post_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
$post_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
$srcharr = array("'", "/", "-", '"', '\\');
$replarr = array("′", "⁄", "–", "“", '');
$json_title = str_replace($srcharr, $replarr, $post->post_title);
$json = '{';
$json .= '"post_preview": "1",';
$json .= '"t": "' . $json_title . '",';
$json .= '"lt": "' . $post_latitude . '",';
$json .= '"ln": "' . $post_longitude . '",';
$json .= '"i":"' . $term_icon . '"';
$json .= '}';
$post->marker_json = $json;
$gd_session->set('listing', $_REQUEST);
// we need to define a few things to trick the setup_postdata
if (!isset($post->ID)) {
$post->ID = '';
$post->post_author = '';
$post->post_date = '';
$post->post_content = '';
$post->default_category = '';
$post->post_type = '';
}
if (empty($post->default_category) && ! empty($post->post_default_category)) {
$post->default_category = $post->post_default_category;
}
if (empty($post->post_type) && !empty($post->listing_type)) {
$post->post_type = $post->listing_type;
}
$post_type = $post->post_type;
$cat_taxonomy = $post_type . "category";
if (!empty($post_type) && empty($post->{$cat_taxonomy}) && !empty($post->post_category) && !empty($post->post_category[$cat_taxonomy])) {
$post->{$cat_taxonomy} = $post->post_category[$cat_taxonomy];
}
setup_postdata($post);
}
/**
* Outputs the preview page top section containing the messages and submit buttons.
*
* @global bool $preview True if the current page is a preview page. False if not.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_geodir_preview_code()
{
global $preview;
$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
if (!$preview || $is_backend_preview) {
return;
}// bail if not previewing
geodir_get_template_part('preview', 'buttons');
}
// action for adding the details page top widget area
add_action('geodir_sidebar_detail_top', 'geodir_action_geodir_sidebar_detail_top', 10, 1);
/**
* Outputs the details page tops section widget area if enabled.
*
* Can be enabled/disabled from GD>Design>Detail page.
*
* @param string $class Optional. The class for the details page top section widget area.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_geodir_sidebar_detail_top($class = '')
{
if (get_option('geodir_show_detail_top_section')) { ?>
<div
class="<?php
/**
* Filter the div class for the wrapper of the full width widget areas.
*
* Allows you to filter the class of the div for the HTML Container wrapper for the full width widget areas referred to as "Top Section" or "Bottom Section" in the widget areas.
*
* @since 1.0.0
* @param string $class The class of the div.
* @param string $type The page type the widget area is being used on. Values can be 'geodir_detail_top', 'geodir_detail_bottom', 'geodir_listing_top', 'geodir_listing_bottom', 'Reg/Login Top Section',
* 'geodir_author_top','geodir_author_bottom', 'geodir_search_top', 'geodir_search_bottom', 'geodir_home_top' or 'geodir_home_bottom'.
*/
echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_top'); ?> <?php echo $class; ?>">
<?php dynamic_sidebar('geodir_detail_top'); ?>
</div>
<?php }
}
// action for adding the details page top widget area
add_action('geodir_add_breadcrumb', 'geodir_breadcrumb', 10, 1);
// action for adding the details page top widget area
add_action('geodir_sidebar_detail_bottom_section', 'geodir_action_geodir_sidebar_detail_bottom_section', 10, 1);
/**
* Outputs the details page bottom section widget area if enabled.
*
* Can be enabled/disabled from GD>Design>Detail page.
*
* @param string $class Optional. The class for the details page top section widget area.
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_geodir_sidebar_detail_bottom_section($class = '')
{
if (get_option('geodir_show_detail_bottom_section')) { ?>
<div
class="<?php
/** This action is documented in geodirectory_template_actions.php */
echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_bottom'); ?> <?php echo $class; ?>">
<?php dynamic_sidebar('geodir_detail_bottom'); ?>
</div><!-- clearfix ends here-->
<?php }
}
/**
* Outputs the details page sidebar widget area content.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_details_sidebar_widget_area()
{
dynamic_sidebar('geodir_detail_sidebar');
}
/**
* Outputs the details page sidebar place details content.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_details_sidebar_place_details()
{
/**
* Used to add items to the details page sidebar.
*
* @since 1.0.0
*/
do_action('geodir_detail_page_sidebar');
}
add_action('geodir_detail_sidebar_inside', 'geodir_details_sidebar_place_details', 10);
add_action('geodir_detail_sidebar_inside', 'geodir_details_sidebar_widget_area', 20);
add_action('geodir_detail_sidebar', 'geodir_action_details_sidebar', 10);
/**
* Outputs the details page sidebar content including all HTML wrappers.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_details_sidebar()
{
// this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
if (get_option('geodir_detail_sidebar_left_section')) {
/**
* Called before the details page left sidebar is opened.
*
* This is used to add opening wrapper HTML to the details page left sidebar.
*
* @since 1.0.0
* @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
* @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-left'.
* @param string $class The class of the sidebar wrapper. 'geodir-sidebar-left geodir-details-sidebar-left'.
* @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'.
*/
do_action('geodir_sidebar_left_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-left geodir-details-sidebar-left', 'https://schema.org/WPSideBar');
?>
<div class="geodir-content-left geodir-sidebar-wrap"><?php
/**
* Called inside the HTML wrapper of the details sidebar for either the left and right sidebar.
*
* This is used to add all info to the details page sidebars.
*
* @since 1.0.0
*/
do_action('geodir_detail_sidebar_inside');
?></div><!-- end geodir-content-left --><?php
/**
* Called after the details page left sidebar.
*
* This is used to add closing wrapper HTML to the details page left sidebar.
*
* @since 1.0.0
* @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
*/
do_action('geodir_sidebar_left_close', 'details-page');
} else {
/**
* Called before the details page right sidebar is opened.
*
* This is used to add opening wrapper HTML to the details page right sidebar.
*
* @since 1.0.0
* @param string $type The current page type. Values can be 'details-page', 'listings-page', 'add-listing-page', 'author-page', 'search-page' or 'home-page'.
* @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-right'.
* @param string $class The class of the sidebar wrapper. 'geodir-sidebar-right geodir-details-sidebar-right'.
* @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'.
*/
do_action('geodir_sidebar_right_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-right geodir-details-sidebar-right', 'http://schema.org/WPSideBar');
?>
<div class="geodir-content-right geodir-sidebar-wrap"><?php
/** This action is documented in geodirectory_template_actions.php */
do_action('geodir_detail_sidebar_inside');
?></div><!-- end geodir-content-right --><?php
/**
* Called after the details page right sidebar.
*
* This is used to add closing wrapper HTML to the details page right sidebar.
*
* @since 1.0.0
* @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
*/
do_action('geodir_sidebar_right_close', 'details-page');
}
}
add_action('geodir_page_title', 'geodir_action_page_title', 10);
/**
* Output the page title.
*
* Outputs the page title where the HTML wrappers classes are filterable.
*
* @since 1.0.0
* @package GeoDirectory
*/
function geodir_action_page_title()
{
/**
* Filter the page title HTML h1 class.
*
* @since 1.0.0
* @param string $class The class to use. Default is 'entry-title fn'.
*/
$class = apply_filters('geodir_page_title_class', 'entry-title fn');
/**
* Filter the page title HTML header wrapper class.
*
* @since 1.0.0
* @param string $class The class to use. Default is 'entry-header'.
*/
$class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . stripslashes(get_the_title()) . '</h1></header>';
}
add_action('geodir_details_slider', 'geodir_action_details_slider', 10, 1);
/**
* Output the details page slider HTML.
*
* @since 1.0.0
* @since 1.5.4 itemprop="image" removed as added via JSON-LD.
* @since 1.5.7 Hide default image on listing detail preview page.
* @package GeoDirectory
* @global bool $preview True of on a preview page. False if not.
* @global object $post The current post object.
*/
function geodir_action_details_slider()
{
global $preview, $post;
$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // preview from backend