Code

< 40 %
40-60 %
> 60 %
1
<?php
2
/**
3
 * Template functions that affect the output of most GeoDirectory pages
4
 *
5
 * @since 1.0.0
6
 * @package GeoDirectory
7
 */
8
###############################################
9
########### DYNAMIC CONTENT ###################
10
###############################################
11
12
/**
13
 * Outputs the CSS from the compatibility settings page.
14
 *
15
 * @since 1.0.0
16
 * @package GeoDirectory
17
 */
18
function gd_compat_styles()
19
{
20
    $tc = get_option('theme_compatibility_setting');
21
    echo "<style id='gd-compat-styles' type='text/css'>";
22
    echo $tc['geodir_theme_compat_css'];
23
    echo "</style>";
24
}
25
26
/**
27
 * Outputs the JS from the compatibility settings page.
28
 *
29
 * @since 1.0.0
30
 * @package GeoDirectory
31
 */
32
function gd_compat_script()
33
{
34
    $tc = get_option('theme_compatibility_setting');
35
    echo "<script>";
36
    echo $tc['geodir_theme_compat_js'];
37
    echo " </script>";
38
}
39
40
/**
41
 * Outputs the 'geodir_top_content_add' from the compatibility settings page.
42
 *
43
 * This is called via filter and should not really be used direct.
44
 *
45
 * @since 1.0.0
46
 * @package GeoDirectory
47
 */
48
function geodir_top_content_add_dynamic()
49
{
50
    $tc = get_option('theme_compatibility_setting');
51
    echo $tc['geodir_top_content_add'];
52
}
53
54
/**
55
 * Outputs the 'geodir_before_main_content_add' from the compatibility settings page.
56
 *
57
 * This is called via filter and should not really be used direct.
58
 *
59
 * @since 1.0.0
60
 * @package GeoDirectory
61
 */
62
function geodir_before_main_content_add_dynamic()
63
{
64
    $tc = get_option('theme_compatibility_setting');
65
    echo $tc['geodir_before_main_content_add'];
66
}
67
68
/**
69
 * Outputs the 'geodir_full_page_class_filter' from the compatibility settings page.
70
 *
71
 * This is called via filter and should not really be used direct.
72
 *
73
 * @since 1.0.0
74
 * @package GeoDirectory
75
 */
76
function geodir_full_page_class_dynamic()
77
{
78
    $tc = get_option('theme_compatibility_setting');
79
    return $tc['geodir_full_page_class_filter'];
80
}
81
82
/**
83
 * Outputs the 'geodir_before_widget_filter' from the compatibility settings page.
84
 *
85
 * This is called via filter and should not really be used direct.
86
 *
87
 * @since 1.0.0
88
 * @package GeoDirectory
89
 */
90
function geodir_before_widget_dynamic()
91
{
92
    $tc = get_option('theme_compatibility_setting');
93
    return $tc['geodir_before_widget_filter'];
94
}
95
96
/**
97
 * Outputs the 'geodir_after_widget_filter' from the compatibility settings page.
98
 *
99
 * This is called via filter and should not really be used direct.
100
 *
101
 * @since 1.0.0
102
 * @package GeoDirectory
103
 */
104
function geodir_after_widget_dynamic()
105
{
106
    $tc = get_option('theme_compatibility_setting');
107
    return $tc['geodir_after_widget_filter'];
108
}
109
110
/**
111
 * Outputs the 'geodir_before_title_filter' from the compatibility settings page.
112
 *
113
 * This is called via filter and should not really be used direct.
114
 *
115
 * @since 1.0.0
116
 * @package GeoDirectory
117
 */
118
function geodir_before_title_dynamic()
119
{
120
    $tc = get_option('theme_compatibility_setting');
121
    return $tc['geodir_before_title_filter'];
122
}
123
124
/**
125
 * Outputs the 'geodir_after_title_filter' from the compatibility settings page.
126
 *
127
 * This is called via filter and should not really be used direct.
128
 *
129
 * @since 1.0.0
130
 * @package GeoDirectory
131
 */
132
function geodir_after_title_dynamic()
133
{
134
    $tc = get_option('theme_compatibility_setting');
135
    return $tc['geodir_after_title_filter'];
136
}
137
138
/**
139
 * Outputs the 'geodir_menu_li_class_filter' from the compatibility settings page.
140
 *
141
 * This is called via filter and should not really be used direct.
142
 *
143
 * @since 1.0.0
144
 * @package GeoDirectory
145
 */
146
function geodir_menu_li_class_dynamic()
147
{
148
    $tc = get_option('theme_compatibility_setting');
149
    return $tc['geodir_menu_li_class_filter'];
150
}
151
152
/**
153
 * Outputs the 'geodir_sub_menu_ul_class_filter' from the compatibility settings page.
154
 *
155
 * This is called via filter and should not really be used direct.
156
 *
157
 * @since 1.0.0
158
 * @package GeoDirectory
159
 */
160
function geodir_sub_menu_ul_class_dynamic()
161
{
162
    $tc = get_option('theme_compatibility_setting');
163
    return $tc['geodir_sub_menu_ul_class_filter'];
164
}
165
166
/**
167
 * Outputs the 'geodir_sub_menu_li_class_filter' from the compatibility settings page.
168
 *
169
 * This is called via filter and should not really be used direct.
170
 *
171
 * @since 1.0.0
172
 * @package GeoDirectory
173
 */
174
function geodir_sub_menu_li_class_dynamic()
175
{
176
    $tc = get_option('theme_compatibility_setting');
177
    return $tc['geodir_sub_menu_li_class_filter'];
178
}
179
180
/**
181
 * Outputs the 'geodir_menu_a_class_filter' from the compatibility settings page.
182
 *
183
 * This is called via filter and should not really be used direct.
184
 *
185
 * @since 1.0.0
186
 * @package GeoDirectory
187
 */
188
function geodir_menu_a_class_dynamic()
189
{
190
    $tc = get_option('theme_compatibility_setting');
191
    return $tc['geodir_menu_a_class_filter'];
192
}
193
194
/**
195
 * Outputs the 'geodir_sub_menu_a_class_filter' from the compatibility settings page.
196
 *
197
 * This is called via filter and should not really be used direct.
198
 *
199
 * @since 1.0.0
200
 * @package GeoDirectory
201
 */
202
function geodir_sub_menu_a_class_dynamic()
203
{
204
    $tc = get_option('theme_compatibility_setting');
205
    return $tc['geodir_sub_menu_a_class_filter'];
206
}
207
208
/**
209
 * Outputs the 'geodir_location_switcher_menu_li_class_filter' from the compatibility settings page.
210
 *
211
 * This is called via filter and should not really be used direct.
212
 *
213
 * @since 1.0.0
214
 * @package GeoDirectory
215
 */
216
function geodir_location_switcher_menu_li_class_dynamic()
217
{
218
    $tc = get_option('theme_compatibility_setting');
219
    return $tc['geodir_location_switcher_menu_li_class_filter'];
220
}
221
222
/**
223
 * Outputs the 'geodir_location_switcher_menu_a_class_filter' from the compatibility settings page.
224
 *
225
 * This is called via filter and should not really be used direct.
226
 *
227
 * @since 1.0.0
228
 * @package GeoDirectory
229
 */
230
function geodir_location_switcher_menu_a_class_dynamic()
231
{
232
    $tc = get_option('theme_compatibility_setting');
233
    return $tc['geodir_location_switcher_menu_a_class_filter'];
234
}
235
236
/**
237
 * Outputs the 'geodir_location_switcher_menu_sub_ul_class_filter' from the compatibility settings page.
238
 *
239
 * This is called via filter and should not really be used direct.
240
 *
241
 * @since 1.0.0
242
 * @package GeoDirectory
243
 */
244
function geodir_location_switcher_menu_sub_ul_class_dynamic()
245
{
246
    $tc = get_option('theme_compatibility_setting');
247
    return $tc['geodir_location_switcher_menu_sub_ul_class_filter'];
248
}
249
250
/**
251
 * Outputs the 'geodir_location_switcher_menu_sub_li_class_filter' from the compatibility settings page.
252
 *
253
 * This is called via filter and should not really be used direct.
254
 *
255
 * @since 1.0.0
256
 * @package GeoDirectory
257
 */
258
function geodir_location_switcher_menu_sub_li_class_dynamic()
259
{
260
    $tc = get_option('theme_compatibility_setting');
261
    return $tc['geodir_location_switcher_menu_sub_li_class_filter'];
262
}
263
264
265
add_action('setup_theme', 'geodir_content_actions_dynamic', 10);
266
267
/**
268
 * Changed the output settings depending on the compatibility settings.
269
 *
270
 * This function checks the theme compatibility settings and filters the output accordingly.
271
 *
272
 * @since 1.0.0
273
 * @package GeoDirectory
274
 */
275
function geodir_content_actions_dynamic()
276
{
277
278
    $tc = get_option('theme_compatibility_setting');
279
//print_r($tc);
280
    if (empty($tc)) {
281
        return;
282
    }
283
284
    //php
285
    if (!empty($tc['geodir_theme_compat_code'])) {
286
        include_once('geodirectory-functions/compatibility/' . $tc['geodir_theme_compat_code'] . '.php');
287
    }
288
289
    //geodir_full_page_class
290
    if (!empty($tc['geodir_full_page_class_filter'])) {
291
        add_filter('geodir_full_page_class', 'geodir_full_page_class_dynamic', 10);
292
    }
293
294
    //widget before filter
295
    if (!empty($tc['geodir_before_widget_filter'])) {
296
        add_filter('geodir_before_widget', 'geodir_before_widget_dynamic', 10);
297
    }
298
299
    //widget after filter
300
    if (!empty($tc['geodir_after_widget_filter'])) {
301
        add_filter('geodir_after_widget', 'geodir_after_widget_dynamic', 10);
302
    }
303
304
    //widget before title filter
305
    if (!empty($tc['geodir_before_title_filter'])) {
306
        add_filter('geodir_before_title', 'geodir_before_title_dynamic', 10);
307
    }
308
309
    //widget before title filter
310
    if (!empty($tc['geodir_after_title_filter'])) {
311
        add_filter('geodir_after_title', 'geodir_after_title_dynamic', 10);
312
    }
313
314
    //menu li class
315
    if (!empty($tc['geodir_menu_li_class_filter'])) {
316
        add_filter('geodir_menu_li_class', 'geodir_menu_li_class_dynamic', 10);
317
    }
318
319
    //menu ul class
320
    if (!empty($tc['geodir_sub_menu_ul_class_filter'])) {
321
        add_filter('geodir_sub_menu_ul_class', 'geodir_sub_menu_ul_class_dynamic', 10);
322
    }
323
324
    //menu sub li class
325
    if (!empty($tc['geodir_sub_menu_li_class_filter'])) {
326
        add_filter('geodir_sub_menu_li_class', 'geodir_sub_menu_li_class_dynamic', 10);
327
    }
328
329
    //menu a class
330
    if (!empty($tc['geodir_menu_a_class_filter'])) {
331
        add_filter('geodir_menu_a_class', 'geodir_menu_a_class_dynamic', 10);
332
    }
333
334
    //menu sub a class
335
    if (!empty($tc['geodir_sub_menu_a_class_filter'])) {
336
        add_filter('geodir_sub_menu_a_class', 'geodir_sub_menu_a_class_dynamic', 10);
337
    }
338
339
    //location menu li class
340
    if (!empty($tc['geodir_location_switcher_menu_li_class_filter'])) {
341
        add_filter('geodir_location_switcher_menu_li_class', 'geodir_location_switcher_menu_li_class_dynamic', 10);
342
    }
343
344
    //location menu sub ul class
345
    if (!empty($tc['geodir_location_switcher_menu_sub_ul_class_filter'])) {
346
        add_filter('geodir_location_switcher_menu_sub_ul_class', 'geodir_location_switcher_menu_sub_ul_class_dynamic', 10);
347
    }
348
349
    //location menu sub li class
350
    if (!empty($tc['geodir_location_switcher_menu_sub_li_class_filter'])) {
351
        add_filter('geodir_location_switcher_menu_sub_li_class', 'geodir_location_switcher_menu_sub_li_class_dynamic', 10);
352
    }
353
354
    //location menu a class
355
    if (!empty($tc['geodir_location_switcher_menu_a_class_filter'])) {
356
        add_filter('geodir_location_switcher_menu_a_class', 'geodir_location_switcher_menu_a_class_dynamic', 10);
357
    }
358
359
    // compat styles
360
    if (!empty($tc['geodir_theme_compat_css'])) {
361
        add_action('wp_head', 'gd_compat_styles');
362
    }
363
364
    // compat js
365
    if (!empty($tc['geodir_theme_compat_js'])) {
366
        add_action('wp_footer', 'gd_compat_script');
367
    }
368
369
370
    // geodir_top_content_add
371
    if (!empty($tc['geodir_top_content_add'])) {
372
        add_action('geodir_top_content', 'geodir_top_content_add_dynamic', 10, 1);
373
    }
374
375
    // geodir_before_main_content_add
376
    if (!empty($tc['geodir_before_main_content_add'])) {
377
        add_action('geodir_before_main_content', 'geodir_before_main_content_add_dynamic', 10, 1);
378
    }
379
380
381
}
382
383
###############################################
384
########### DETAILS PAGE ACTIONS ##############
385
###############################################
386
387
// action for adding the wrapper div opening tag
388
add_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10, 3);
389
390
/**
391
 * Outputs the opening HTML wrapper div if the compatibility settings are present.
392
 *
393
 * @param string $type Optional. Depreciated.
394
 * @param string $id Optional. The div id.
395
 * @param string $class Optional. The div class.
396
 * @since 1.0.0
397
 * @package GeoDirectory
398
 */
399
function geodir_action_wrapper_open($type = '', $id = '', $class = '')
400
{
401
    $tc = get_option('theme_compatibility_setting');
402
    if (!empty($tc['geodir_wrapper_open_replace'])) {
403
        $text = $tc['geodir_wrapper_open_replace'];
404
    } else {
405
        $text = '<div id="[id]" class="[class]">';
406
    }
407
408
    if (!empty($tc['geodir_wrapper_open_id'])) {
409
        $id = $tc['geodir_wrapper_open_id'];
410
    }
411
    if (!empty($tc['geodir_wrapper_open_class'])) {
412
        $class = $tc['geodir_wrapper_open_class'];
413
    }
414
415
    $text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
416
417
    echo $text;
418
}
419
420
// action for adding the wrapperdiv closing tag
421
add_action('geodir_wrapper_close', 'geodir_action_wrapper_close', 10, 1);
422
423
/**
424
 * Outputs the closing HTML wrapper div if the compatibility settings are present.
425
 *
426
 * @param string $type Optional. Depreciated.
427
 * @since 1.0.0
428
 * @package GeoDirectory
429
 */
430
function geodir_action_wrapper_close($type = '')
431
{
432
    $tc = get_option('theme_compatibility_setting');
433
    if (!empty($tc['geodir_wrapper_close_replace'])) {
434
        $text = $tc['geodir_wrapper_close_replace'];
435
    } else {
436
        $text = '</div><!-- wrapper ends here-->';
437
    }
438
439
    echo $text;
440
}
441
442
// action for adding the content div opening tag
443
add_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10, 3);
444
/**
445
 * Outputs the opening HTML content wrapper div if the compatibility settings are present.
446
 *
447
 * @param string $type Optional. Page type.
448
 * @param string $id Optional. The div id.
449
 * @param string $class Optional. The div class.
450
 * @since 1.0.0
451
 * @package GeoDirectory
452
 */
453
function geodir_action_wrapper_content_open($type = '', $id = '', $class = '')
454
{
455
    if ($type == 'home-page' && $width = get_option('geodir_width_home_contant_section')) {
456
        $width_css = 'style="width:' . $width . '%;"';
457
    } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_contant_section')) {
458
        $width_css = 'style="width:' . $width . '%;"';
459
    } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_contant_section')) {
460
        $width_css = 'style="width:' . $width . '%;"';
461
    } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_contant_section')) {
462
        $width_css = 'style="width:' . $width . '%;"';
463
    } else {
464
        $width_css = '';
465
    }
466
467
    $tc = get_option('theme_compatibility_setting');
468
    if (!empty($tc['geodir_wrapper_content_open_replace'])) {
469
        $text = $tc['geodir_wrapper_content_open_replace'];
470
    } else {
471
        $text = '<div id="[id]" class="[class]" role="main" [width_css]>';
472
    }
473
474
    if (!empty($tc['geodir_wrapper_content_open_id'])) {
475
        $id = $tc['geodir_wrapper_content_open_id'];
476
    }
477
    if (!empty($tc['geodir_wrapper_content_open_class'])) {
478
        $class = $tc['geodir_wrapper_content_open_class'];
479
    }
480
481
    $text = str_replace(array("[id]", "[class]", "[width_css]"), array($id, $class, $width_css), $text);
482
483
    echo $text;
484
}
485
486
// action for adding the primary div closing tag
487
add_action('geodir_wrapper_content_close', 'geodir_action_wrapper_content_close', 10, 1);
488
/**
489
 * Outputs the closing HTML content wrapper div if the compatibility settings are present.
490
 *
491
 * @param string $type Optional. Depreciated.
492
 * @since 1.0.0
493
 * @package GeoDirectory
494
 */
495
function geodir_action_wrapper_content_close($type = '')
496
{
497
    $tc = get_option('theme_compatibility_setting');
498
    if (!empty($tc['geodir_wrapper_content_close_replace'])) {
499
        $text = $tc['geodir_wrapper_content_close_replace'];
500
    } else {
501
        $text = '</div><!-- content ends here-->';
502
    }
503
    echo $text;
504
}
505
506
// action for adding the <article> opening tag
507
add_action('geodir_article_open', 'geodir_action_article_open', 10, 4);
508
/**
509
 * Outputs the opening HTML article wrapper if the compatibility settings are present.
510
 *
511
 * @param string $type Optional. Depreciated.
512
 * @param string $id Optional. The element id.
513
 * @param string $class Optional. The element class.
514
 * @param string $itemtype Optional. The element itemtype.
515
 * @since 1.0.0
516
 * @since 1.5.4 Removed itemscope itemtype="[itemtype]" as now added
517
 * @package GeoDirectory
518
 */
519
function geodir_action_article_open($type = '', $id = '', $class = '', $itemtype = '')
520
{
521
    $class = implode(" ", $class);
522
    $tc = get_option('theme_compatibility_setting');
523
    if (!empty($tc['geodir_article_open_replace'])) {
524
        $text = $tc['geodir_article_open_replace'];
525
    } else {
526
        $text = '<article  id="[id]" class="[class]" >';
527
    }
528
529
    if (!empty($tc['geodir_article_open_id'])) {
530
        $id = $tc['geodir_article_open_id'];
531
    }
532
    if (!empty($tc['geodir_article_open_class'])) {
533
        $class = $tc['geodir_article_open_class'];
534
    }
535
536
    $text = str_replace(array("[id]", "[class]", "[itemtype]"), array($id, $class, $itemtype), $text);
537
538
    echo $text;
539
}
540
541
// action for adding the primary div closing tag
542
add_action('geodir_article_close', 'geodir_action_article_close', 10, 1);
543
/**
544
 * Outputs the closing HTML article wrapper if the compatibility settings are present.
545
 *
546
 * @param string $type Optional. Depreciated.
547
 * @since 1.0.0
548
 * @package GeoDirectory
549
 */
550
function geodir_action_article_close($type = '')
551
{
552
    $tc = get_option('theme_compatibility_setting');
553
    if (!empty($tc['geodir_article_close_replace'])) {
554
        $text = $tc['geodir_article_close_replace'];
555
    } else {
556
        $text = '</article><!-- article ends here-->';
557
    }
558
    echo $text;
559
}
560
561
// action for adding the sidebar opening tag
562
add_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10, 4);
563
/**
564
 * Outputs the opening HTML aside right sidebar wrapper if the compatibility settings are present.
565
 *
566
 * @param string $type Optional. Page type.
567
 * @param string $id Optional. The element id.
568
 * @param string $class Optional. The element class.
569
 * @param string $itemtype Optional. The element itemtype.
570
 * @since 1.0.0
571
 * @package GeoDirectory
572
 */
573
function geodir_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '')
574
{
575
    if ($type == 'home-page' && $width = get_option('geodir_width_home_right_section')) {
576
        $width_css = 'style="width:' . $width . '%;"';
577
    } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_right_section')) {
578
        $width_css = 'style="width:' . $width . '%;"';
579
    } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_right_section')) {
580
        $width_css = 'style="width:' . $width . '%;"';
581
    } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_right_section')) {
582
        $width_css = 'style="width:' . $width . '%;"';
583
    } else {
584
        $width_css = '';
585
    }
586
587
    $tc = get_option('theme_compatibility_setting');
588
    if (!empty($tc['geodir_sidebar_right_open_replace'])) {
589
        $text = $tc['geodir_sidebar_right_open_replace'];
590
    } else {
591
        $text = '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>';
592
    }
593
594
    if (!empty($tc['geodir_sidebar_right_open_id'])) {
595
        $id = $tc['geodir_sidebar_right_open_id'];
596
    }
597
    if (!empty($tc['geodir_sidebar_right_open_class'])) {
598
        $class = $tc['geodir_sidebar_right_open_class'];
599
    }
600
601
    $text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
602
603
    echo $text;
604
}
605
606
// action for adding the primary div closing tag
607
add_action('geodir_sidebar_right_close', 'geodir_action_sidebar_right_close', 10, 1);
608
/**
609
 * Outputs the closing HTML aside right sidebar wrapper if the compatibility settings are present.
610
 *
611
 * @param string $type Optional. Depreciated.
612
 * @since 1.0.0
613
 * @package GeoDirectory
614
 */
615
function geodir_action_sidebar_right_close($type = '')
616
{
617
    $tc = get_option('theme_compatibility_setting');
618
    if (!empty($tc['geodir_sidebar_right_close_replace'])) {
619
        $text = $tc['geodir_sidebar_right_close_replace'];
620
    } else {
621
        $text = '</aside><!-- sidebar ends here-->';
622
    }
623
    echo $text;
624
}
625
626
627
// action for adding the details page top widget area
628
add_action('geodir_detail_before_main_content', 'geodir_action_geodir_set_preview_post', 8);
629
add_action('geodir_detail_before_main_content', 'geodir_action_geodir_preview_code', 9);
630
add_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10);
631
add_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20);
632
633
/**
634
 * Set the $post value if previewing a post.
635
 *
636
 * @global object $post The current post object.
637
 * @global bool $preview True if the current page is a preview page. False if not.
638
 * @global object $gd_session GeoDirectory Session object.
639
 * @since 1.0.0
640
 * @package GeoDirectory
641
 */
642
function geodir_action_geodir_set_preview_post()
643
{
644
    global $post, $preview, $gd_session;
645
    $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
646
    if (!$preview || $is_backend_preview) {
647
        return;
648
    }// bail if not previewing
649
650
    $listing_type = isset($_REQUEST['listing_type']) ? sanitize_text_field($_REQUEST['listing_type']) : '';
651
652
    $fields_info = geodir_get_custom_fields_type($listing_type);
653
654
    foreach ($_REQUEST as $pkey => $pval) {
655
        if ($pkey == 'geodir_video') {
656
            $tags = '<iframe>';
657
        } else if ($pkey == 'post_desc') {
658
            $tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>';
659
        } else if (is_array($fields_info) && isset($fields_info[$pkey]) && ($fields_info[$pkey] == 'textarea' || $fields_info[$pkey] == 'html')) {
660
            $tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>';
661
        } else if (is_array($_REQUEST[$pkey])) {
662
            $tags = 'skip_field';
663
        } else {
664
            $tags = '';
665
        }
666
        /**
667
         * Allows the filtering of the allowed HTML tags per field when submitting from frontend add listing page.
668
         *
669
         * @since 1.0.0
670
         * @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>'.
671
         * @param string|array $pkey The field id/name. If array then value is set as "skip_field".
672
         */
673
        $tags = apply_filters('geodir_save_post_key', $tags, $pkey);
674
675
        if ($tags != 'skip_field') {
676
            $_REQUEST[$pkey] = strip_tags($_REQUEST[$pkey], $tags);
677
        }
678
    }
679
680
    $post = (object)$_REQUEST;
681
682
683
    if (isset($post->video)) {
684
        $post->video = stripslashes($post->video);
685
    }
686
687
    if (isset($post->Video2)) {
688
        $post->Video2 = stripslashes($post->Video2);
689
    }
690
691
    $post_type = $post->listing_type;
692
    $post_type_info = get_post_type_object($post_type);
693
694
    $listing_label = $post_type_info->labels->singular_name;
695
696
    $term_icon = '';
697
698
    if (!empty($post->post_category)) {
699
        foreach ($post->post_category as $post_taxonomy => $post_term) {
700
701
            if ($post_term != '' && !is_array($post_term)) {
702
                $post_term = explode(',', trim($post_term, ','));
703
            }
704
705
            if (is_array($post_term)) {
706
                $post_term = array_unique($post_term);
707
            }
708
709
            if (!empty($post_term)) {
710
                foreach ($post_term as $cat_id) {
711
                    $cat_id = trim($cat_id);
712
713
                    if ($cat_id != '') {
714
                        $term_icon = get_option('geodir_default_marker_icon');
715
716
                        if (isset($post->post_default_category) && $post->post_default_category == $cat_id) {
717
                            if ($term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type)) {
718
                                if (isset($term_icon_url['src']) && $term_icon_url['src'] != '')
719
                                    $term_icon = $term_icon_url['src'];
720
                                break;
721
                            }
722
                        }
723
                    }
724
                }
725
            }
726
        }
727
    }
728
729
    $post_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
730
    $post_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
731
732
    $srcharr = array("'", "/", "-", '"', '\\');
733
    $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
734
735
    $json_title = str_replace($srcharr, $replarr, $post->post_title);
736
737
    $json = '{';
738
    $json .= '"post_preview": "1",';
739
    $json .= '"t": "' . $json_title . '",';
740
    $json .= '"lt": "' . $post_latitude . '",';
741
    $json .= '"ln": "' . $post_longitude . '",';
742
    $json .= '"i":"' . $term_icon . '"';
743
    $json .= '}';
744
745
    $post->marker_json = $json;
746
747
    $gd_session->set('listing', $_REQUEST);
748
749
    // we need to define a few things to trick the setup_postdata
750
    if (!isset($post->ID)) {
751
        $post->ID = '';
752
        $post->post_author = '';
753
        $post->post_date = '';
754
        $post->post_content = '';
755
        $post->default_category = '';
756
        $post->post_type = '';
757
    }
758
	if (empty($post->default_category) && ! empty($post->post_default_category)) {
759
		$post->default_category = $post->post_default_category;
760
	}
761
	if (empty($post->post_type) && !empty($post->listing_type)) {
762
		$post->post_type = $post->listing_type;
763
	}
764
	$post_type = $post->post_type;
765
	$cat_taxonomy = $post_type . "category";
766
	if (!empty($post_type) && empty($post->{$cat_taxonomy}) && !empty($post->post_category) && !empty($post->post_category[$cat_taxonomy])) {
767
		$post->{$cat_taxonomy} = $post->post_category[$cat_taxonomy];
768
	}
769
    setup_postdata($post);
770
}
771
772
/**
773
 * Outputs the preview page top section containing the messages and submit buttons.
774
 *
775
 * @global bool $preview True if the current page is a preview page. False if not.
776
 * @since 1.0.0
777
 * @package GeoDirectory
778
 */
779
function geodir_action_geodir_preview_code()
780
{
781
    global $preview;
782
783
    $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
784
785
    if (!$preview || $is_backend_preview) {
786
        return;
787
    }// bail if not previewing
788
789
    geodir_get_template_part('preview', 'buttons');
790
}
791
792
// action for adding the details page top widget area
793
add_action('geodir_sidebar_detail_top', 'geodir_action_geodir_sidebar_detail_top', 10, 1);
794
/**
795
 * Outputs the details page tops section widget area if enabled.
796
 *
797
 * Can be enabled/disabled from GD>Design>Detail page.
798
 *
799
 * @param string $class Optional. The class for the details page top section widget area.
800
 * @since 1.0.0
801
 * @package GeoDirectory
802
 */
803
function geodir_action_geodir_sidebar_detail_top($class = '')
804
{
805
    if (get_option('geodir_show_detail_top_section')) { ?>
806
        <div
807
            class="<?php
808
            /**
809
             * Filter the div class for the wrapper of the full width widget areas.
810
             *
811
             * 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.
812
             *
813
             * @since 1.0.0
814
             * @param string $class The class of the div.
815
             * @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',
816
             *               'geodir_author_top','geodir_author_bottom', 'geodir_search_top', 'geodir_search_bottom', 'geodir_home_top' or 'geodir_home_bottom'.
817
             */
818
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_top'); ?> <?php echo $class; ?>">
819
            <?php dynamic_sidebar('geodir_detail_top'); ?>
820
        </div>
821
    <?php }
822
823
}
824
825
// action for adding the details page top widget area
826
add_action('geodir_add_breadcrumb', 'geodir_breadcrumb', 10, 1);
827
828
// action for adding the details page top widget area
829
add_action('geodir_sidebar_detail_bottom_section', 'geodir_action_geodir_sidebar_detail_bottom_section', 10, 1);
830
831
/**
832
 * Outputs the details page bottom section widget area if enabled.
833
 *
834
 * Can be enabled/disabled from GD>Design>Detail page.
835
 *
836
 * @param string $class Optional. The class for the details page top section widget area.
837
 * @since 1.0.0
838
 * @package GeoDirectory
839
 */
840
function geodir_action_geodir_sidebar_detail_bottom_section($class = '')
841
{
842
    if (get_option('geodir_show_detail_bottom_section')) { ?>
843
        <div
844
            class="<?php
845
            /** This action is documented in geodirectory_template_actions.php */
846
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_bottom'); ?> <?php echo $class; ?>">
847
            <?php dynamic_sidebar('geodir_detail_bottom'); ?>
848
        </div><!-- clearfix ends here-->
849
    <?php }
850
}
851
852
/**
853
 * Outputs the details page sidebar widget area content.
854
 *
855
 * @since 1.0.0
856
 * @package GeoDirectory
857
 */
858
function geodir_details_sidebar_widget_area()
859
{
860
    dynamic_sidebar('geodir_detail_sidebar');
861
}
862
863
/**
864
 * Outputs the details page sidebar place details content.
865
 *
866
 * @since 1.0.0
867
 * @package GeoDirectory
868
 */
869
function geodir_details_sidebar_place_details()
870
{
871
    /**
872
     * Used to add items to the details page sidebar.
873
     *
874
     * @since 1.0.0
875
     */
876
    do_action('geodir_detail_page_sidebar');
877
}
878
879
add_action('geodir_detail_sidebar_inside', 'geodir_details_sidebar_place_details', 10);
880
add_action('geodir_detail_sidebar_inside', 'geodir_details_sidebar_widget_area', 20);
881
882
add_action('geodir_detail_sidebar', 'geodir_action_details_sidebar', 10);
883
/**
884
 * Outputs the details page sidebar content including all HTML wrappers.
885
 *
886
 * @since 1.0.0
887
 * @package GeoDirectory
888
 */
889
function geodir_action_details_sidebar()
890
{
891
    // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
892
    if (get_option('geodir_detail_sidebar_left_section')) {
893
        /**
894
         * Called before the details page left sidebar is opened.
895
         *
896
         * This is used to add opening wrapper HTML to the details page left sidebar.
897
         *
898
         * @since 1.0.0
899
         * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
900
         * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-left'.
901
         * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-left geodir-details-sidebar-left'.
902
         * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'.
903
         */
904
        do_action('geodir_sidebar_left_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-left geodir-details-sidebar-left', 'https://schema.org/WPSideBar');
905
        ?>
906
        <div class="geodir-content-left geodir-sidebar-wrap"><?php
907
        /**
908
         * Called inside the HTML wrapper of the details sidebar for either the left and right sidebar.
909
         *
910
         * This is used to add all info to the details page sidebars.
911
         *
912
         * @since 1.0.0
913
         */
914
        do_action('geodir_detail_sidebar_inside');
915
        ?></div><!-- end geodir-content-left --><?php
916
        /**
917
         * Called after the details page left sidebar.
918
         *
919
         * This is used to add closing wrapper HTML to the details page left sidebar.
920
         *
921
         * @since 1.0.0
922
         * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
923
         */
924
        do_action('geodir_sidebar_left_close', 'details-page');
925
    } else {
926
        /**
927
         * Called before the details page right sidebar is opened.
928
         *
929
         * This is used to add opening wrapper HTML to the details page right sidebar.
930
         *
931
         * @since 1.0.0
932
         * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'add-listing-page', 'author-page', 'search-page' or 'home-page'.
933
         * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-right'.
934
         * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-right geodir-details-sidebar-right'.
935
         * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'.
936
         */
937
        do_action('geodir_sidebar_right_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-right geodir-details-sidebar-right', 'http://schema.org/WPSideBar');
938
        ?>
939
        <div class="geodir-content-right geodir-sidebar-wrap"><?php
940
        /** This action is documented in geodirectory_template_actions.php */
941
        do_action('geodir_detail_sidebar_inside');
942
        ?></div><!-- end geodir-content-right --><?php
943
        /**
944
         * Called after the details page right sidebar.
945
         *
946
         * This is used to add closing wrapper HTML to the details page right sidebar.
947
         *
948
         * @since 1.0.0
949
         * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
950
         */
951
        do_action('geodir_sidebar_right_close', 'details-page');
952
    }
953
}
954
955
add_action('geodir_page_title', 'geodir_action_page_title', 10);
956
/**
957
 * Output the page title.
958
 *
959
 * Outputs the page title where the HTML wrappers classes are filterable.
960
 *
961
 * @since 1.0.0
962
 * @package GeoDirectory
963
 */
964
function geodir_action_page_title()
965
{
966
    /**
967
     * Filter the page title HTML h1 class.
968
     *
969
     * @since 1.0.0
970
     * @param string $class The class to use. Default is 'entry-title fn'.
971
     */
972
    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
973
    /**
974
     * Filter the page title HTML header wrapper class.
975
     *
976
     * @since 1.0.0
977
     * @param string $class The class to use. Default is 'entry-header'.
978
     */
979
    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
980
    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . stripslashes(get_the_title()) . '</h1></header>';
981
}
982
983
984
add_action('geodir_details_slider', 'geodir_action_details_slider', 10, 1);
985
/**
986
 * Output the details page slider HTML.
987
 *
988
 * @since 1.0.0
989
 * @since 1.5.4 itemprop="image" removed as added via JSON-LD.
990
 * @since 1.5.7 Hide default image on listing detail preview page.
991
 * @package GeoDirectory
992
 * @global bool $preview True of on a preview page. False if not.
993
 * @global object $post The current post object.
994
 */
995
function geodir_action_details_slider()
996
{
997
    global $preview, $post;
998
999
    $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // preview from backend
1000
1001
    if ($is_backend_preview && !empty($post) && !empty($post->ID) && !isset($post->post_images)) {
1002
        $preview_get_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
1003
1004
        $preview_post_images = array();
1005
        if ($preview_get_images) {
1006
            foreach ($preview_get_images as $row) {
1007
                $preview_post_images[] = $row->src;
1008
            }
1009
        }
1010
        if (!empty($preview_post_images)) {
1011
            $post->post_images = implode(',', $preview_post_images);
1012
        }
1013
    }
1014
    
1015
    $package_info = geodir_post_package_info(array(), $post, (!empty($post->post_type) ? $post->post_type : ''));
1016
    $image_limit = '';
1017
    if (defined('GEODIRPAYMENT_VERSION') && !empty($package_info) && isset($package_info->image_limit) && $package_info->image_limit !== '') {
1018
        $image_limit = (int)$package_info->image_limit;
1019
    }
1020
1021
    if ($preview) {
1022
        $post_images = array();
1023
        if (isset($post->post_images) && !empty($post->post_images)) {
1024
            $post->post_images = trim($post->post_images, ",");
1025
            $post_images = explode(",", $post->post_images);
1026
        }
1027
1028
        $main_slides = '';
1029
        $nav_slides = '';
1030
        $slides = 0;
1031
1032
        if (!empty($post_images)) {
1033
            foreach ($post_images as $image) {
1034
                if ($image_limit !== '' && ($slides+1) > $image_limit) {
1035
                     break;
1036
                }
1037
                if (!empty($image)) {
1038
                    $sizes = getimagesize(trim($image));
1039
                    $width = !empty($sizes) && isset($sizes[0]) ? $sizes[0] : 0;
1040
                    $height = !empty($sizes) && isset($sizes[1]) ? $sizes[1] : 0;
1041
1042
                    if ($image && $width && $height) {
1043
                        $image = (object)array('src' => $image, 'width' => $width, 'height' => $height);
1044
                    }
1045
1046
                    if (isset($image->src)) {
1047
                        if ($image->height >= 400) {
1048
                            $spacer_height = 0;
1049
                        } else {
1050
                            $spacer_height = ((400 - $image->height) / 2);
1051
                        }
1052
1053
                        $image_title = isset($image->title) ? $image->title : '';
1054
1055
                        $main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />';
1056
                        $main_slides .= '<img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:400px;margin:0 auto;" /></li>';
1057
                        $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:48px;margin:0 auto;" /></li>';
1058
                        $slides++;
1059
                    }
1060
                }
1061
            }// endfore
1062
        } //end if
1063
    } else {
1064
        $main_slides = '';
1065
        $nav_slides = '';
1066
        /**
1067
         * Filter if default images should show on the details page.
1068
         *
1069
         * @param bool $use_default_image Default false.
1070
         * @since 1.6.16
1071
         */
1072
        $use_default_image = apply_filters('geodir_details_default_image_show', false);
1073
        $post_images = geodir_get_images($post->ID, 'thumbnail', $use_default_image); // Hide default image on listing preview/detail page.
1074
        $slides = 0;
1075
1076
        if (!empty($post_images)) {
1077
            foreach ($post_images as $image) {
1078
                if ($image_limit !== '' && ($slides+1) > $image_limit) {
1079
                     break;
1080
                }
1081
                if ($image->height >= 400) {
1082
                    $spacer_height = 0;
1083
                } else {
1084
                    $spacer_height = ((400 - $image->height) / 2);
1085
                }
1086
1087
                $caption = '';//(!empty($image->caption)) ? '<p class="flex-caption">'.$image->caption.'</p>' : '';
1088
                $main_slides .= '<li><img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:400px;margin:0 auto;" />'.$caption.'</li>';
1089
                $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
1090
                $slides++;
1091
            }
1092
        }// endfore
1093
    }
1094
1095
    if (!empty($post_images)) {
1096
        ?>
1097
        <div class="geodir_flex-container">
1098
            <div class="geodir_flex-loader"><i class="fas fa-sync fa-spin"></i></div>
1099
            <div id="geodir_slider" class="geodir_flexslider ">
1100
                <ul class="geodir-slides clearfix"><?php echo $main_slides; ?></ul>
1101
            </div>
1102
            <?php if ($slides > 1) { ?>
1103
                <div id="geodir_carousel" class="geodir_flexslider">
1104
                    <ul class="geodir-slides clearfix"><?php echo $nav_slides; ?></ul>
1105
                </div>
1106
            <?php } ?>
1107
        </div>
1108
    <?php
1109
    }
1110
}
1111
1112
add_action('geodir_details_taxonomies', 'geodir_action_details_taxonomies', 10);
1113
/**
1114
 * Output link to the posts categories and tags.
1115
 *
1116
 * @global bool $preview True of on a preview page. False if not.
1117
 * @global object $post The current post object.
1118
 * @since 1.0.0
1119
 * @since 1.5.7 Modified to add parent categories if only sub category selected.
1120
 * @package GeoDirectory
1121
 */
1122
function geodir_action_details_taxonomies()
1123
{
1124
    global $preview, $post;?>
1125
    <p class="geodir_post_taxomomies clearfix">
1126
    <?php
1127
    $taxonomies = array();
1128
1129
    $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
1130
1131
    if ($preview && !$is_backend_preview) {
1132
        $post_type = $post->listing_type;
1133
        $post_taxonomy = $post_type . 'category';
1134
        $post->{$post_taxonomy} = $post->post_category[$post_taxonomy];
1135
    } else {
1136
        $post_type = $post->post_type;
1137
        $post_taxonomy = $post_type . 'category';
1138
    }
1139
//{	
1140
    $post_type_info = get_post_type_object($post_type);
1141
    $listing_label = __($post_type_info->labels->singular_name, 'geodirectory');
1142
1143
    if (!empty($post->post_tags)) {
1144
1145
        if (taxonomy_exists($post_type . '_tags')):
1146
            $links = array();
1147
            $terms = array();
1148
            // to limit post tags
1149
            $post_tags = trim($post->post_tags, ",");
1150
            $post_id = isset($post->ID) ? $post->ID : '';
1151
            /**
1152
             * Filter the post tags.
1153
             *
1154
             * Allows you to filter the post tags output on the details page of a post.
1155
             *
1156
             * @since 1.0.0
1157
             * @param string $post_tags A comma seperated list of tags.
1158
             * @param int $post_id The current post id.
1159
             */
1160
            $post_tags = apply_filters('geodir_action_details_post_tags', $post_tags, $post_id);
1161
1162
            $post->post_tags = $post_tags;
1163
            $post_tags = explode(",", trim($post->post_tags, ","));
1164
1165
1166
            foreach ($post_tags as $post_term) {
1167
1168
                // fix slug creation order for tags & location
1169
                $post_term = trim($post_term);
1170
1171
                $priority_location = false;
1172
                if ($insert_term = term_exists($post_term, $post_type . '_tags')) {
1173
                    $term = get_term_by('id', $insert_term['term_id'], $post_type . '_tags');
1174
                } else {
1175
                    $post_country = isset($_REQUEST['post_country']) && $_REQUEST['post_country'] != '' ? sanitize_text_field($_REQUEST['post_country']) : NULL;
1176
                    $post_region = isset($_REQUEST['post_region']) && $_REQUEST['post_region'] != '' ? sanitize_text_field($_REQUEST['post_region']) : NULL;
1177
                    $post_city = isset($_REQUEST['post_city']) && $_REQUEST['post_city'] != '' ? sanitize_text_field($_REQUEST['post_city']) : NULL;
1178
                    $match_country = $post_country && sanitize_title($post_term) == sanitize_title($post_country) ? true : false;
1179
                    $match_region = $post_region && sanitize_title($post_term) == sanitize_title($post_region) ? true : false;
1180
                    $match_city = $post_city && sanitize_title($post_term) == sanitize_title($post_city) ? true : false;
1181
                    if ($match_country || $match_region || $match_city) {
1182
                        $priority_location = true;
1183
                        $term = get_term_by('name', $post_term, $post_type . '_tags');
1184
                    } else {
1185
                        $insert_term = wp_insert_term($post_term, $post_type . '_tags');
1186
                        $term = get_term_by('name', $post_term, $post_type . '_tags');
1187
                    }
1188
                }
1189
1190
                if (!is_wp_error($term) && is_object($term)) {
1191
1192
                    // fix tag link on detail page
1193
                    if ($priority_location) {
1194
1195
                        $tag_link = "<a href=''>$post_term</a>";
1196
                        /**
1197
                         * Filter the tag name on the details page.
1198
                         *
1199
                         * @since 1.5.6
1200
                         * @param string $tag_link The tag link html.
1201
                         * @param object $term The tag term object.
1202
                         */
1203
                        $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
1204
                        $links[] = $tag_link;
1205
                    } else {
1206
                        $tag_link = "<a href='" . esc_attr(get_term_link($term->term_id, $term->taxonomy)) . "'>$term->name</a>";
1207
                        /** This action is documented in geodirectory-template_actions.php */
1208
                        $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
1209
                        $links[] = $tag_link;
1210
                    }
1211
                    $terms[] = $term;
1212
                }
1213
                //
1214
            }
1215
            if (!isset($listing_label)) {
1216
                $listing_label = '';
1217
            }
1218
            $taxonomies[$post_type . '_tags'] = wp_sprintf(__('%s Tags: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
1219
        endif;
1220
1221
    }
1222
1223
    if (!empty($post->{$post_taxonomy})) {
1224
        $links = array();
1225
        $terms = array();
1226
        $termsOrdered = array();
1227
        if (!is_array($post->{$post_taxonomy})) {
1228
            $post_term = explode(",", trim($post->{$post_taxonomy}, ","));
1229
        } else {
1230
            $post_term = $post->{$post_taxonomy};
1231
			
1232
			if ($preview && !$is_backend_preview) {
1233
				$post_term = geodir_add_parent_terms($post_term, $post_taxonomy);
1234
			}
1235
        }
1236
1237
        $post_term = array_unique($post_term);
1238
        if (!empty($post_term)) {
1239
            foreach ($post_term as $post_term) {
1240
                $post_term = trim($post_term);
1241
1242
                if ($post_term != ''):
1243
                    $term = get_term_by('id', $post_term, $post_taxonomy);
1244
1245
                    if (is_object($term)) {
1246
                        $term_link = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>$term->name</a>";
1247
                        /**
1248
                         * Filter the category name on the details page.
1249
                         *
1250
                         * @since 1.5.6
1251
                         * @param string $term_link The link html to the category.
1252
                         * @param object $term The category term object.
1253
                         */
1254
                        $term_link = apply_filters('geodir_details_taxonomies_cat_link',$term_link,$term);
1255
                        $links[] = $term_link;
1256
                        $terms[] = $term;
1257
                    }
1258
                endif;
1259
            }
1260
            // order alphabetically
1261
            asort($links);
1262
            foreach (array_keys($links) as $key) {
1263
                $termsOrdered[$key] = $terms[$key];
1264
            }
1265
            $terms = $termsOrdered;
1266
1267
        }
1268
1269
        if (!isset($listing_label)) {
1270
            $listing_label = '';
1271
        }
1272
        $taxonomies[$post_taxonomy] = wp_sprintf(__('%s Category: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
1273
1274
    }
1275
1276
    /**
1277
     * Filter the taxonomies array before output.
1278
     *
1279
     * @since 1.5.9
1280
     * @param array $taxonomies The array of cats and tags.
1281
     * @param string $post_type The post type being output.
1282
     * @param string $listing_label The post type label.
1283
     * @param string $listing_label The post type label with ucwords function.
1284
     */
1285
    $taxonomies = apply_filters('geodir_details_taxonomies_output',$taxonomies,$post_type,$listing_label,geodir_ucwords($listing_label));
1286
1287
    if (isset($taxonomies[$post_taxonomy])) {
1288
        echo '<span class="geodir-category">' . $taxonomies[$post_taxonomy] . '</span>';
1289
    }
1290
1291
    if (isset($taxonomies[$post_type . '_tags']))
1292
        echo '<span class="geodir-tags">' . $taxonomies[$post_type . '_tags'] . '</span>';
1293
1294
    ?>
1295
    </p><?php
1296
}
1297
1298
add_action('wp_head', 'geodir_action_details_micordata', 10);
1299
1300
/**
1301
 * Output the posts microdata in the source code.
1302
 *
1303
 * This micordata is used by things like Google as a standard way of declaring things like telephone numbers etc.
1304
 *
1305
 * @global bool $preview True of on a preview page. False if not.
1306
 * @global object $post The current post object.
1307
 * @since 1.0.0
1308
 * @since 1.5.4 Changed to JSON-LD and added filters.
1309
 * @since 1.5.7 Added $post param.
1310
 * @param object $post Optional. The post object or blank.
1311
 * @package GeoDirectory
1312
 */
1313
function geodir_action_details_micordata($post='')
1314
{
1315
1316
    global $preview;
1317
    if(empty($post)){global $post;}
1318
    if ($preview || !geodir_is_page('detail')) {
1319
        return;
1320
    }
1321
1322
    // url
1323
    $c_url = geodir_curPageURL();
1324
1325
    // post reviews
1326
    $post_reviews = get_comments(array('post_id' => $post->ID, 'status' => 'approve'));
1327
    if (empty($post_reviews)) {
1328
        $reviews = '';
1329
    } else {
1330
        foreach ($post_reviews as $review) {
1331
1332
            if($rating_value = geodir_get_commentoverall($review->comment_ID)){
1333
                $reviews[] = array(
1334
                    "@type" => "Review",
1335
                    "author" => $review->comment_author,
1336
                    "datePublished" => $review->comment_date,
1337
                    "description" => $review->comment_content,
1338
                    "reviewRating" => array(
1339
                        "@type" => "Rating",
1340
                        "bestRating" => "5",// @todo this will need to be filtered for review manager if user changes the score.
1341
                        "ratingValue" => $rating_value,
1342
                        "worstRating" => "1"
1343
                    )
1344
                );
1345
            }
1346
1347
        }
1348
1349
    }
1350
1351
    // post images
1352
    $post_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
1353
    if (empty($post_images)) {
1354
        $images = '';
1355
    } else {
1356
        $i_arr = array();
1357
        foreach ($post_images as $img) {
1358
            $i_arr[] = $img->src;
1359
        }
1360
1361
        if (count($i_arr) == 1) {
1362
            $images = $i_arr[0];
1363
        } else {
1364
            $images = $i_arr;
1365
        }
1366
1367
    }
1368
    //print_r($post);
1369
    // external links
1370
    $external_links =  array();
1371
    $external_links[] = $post->geodir_website;
1372
    $external_links[] = $post->geodir_twitter;
1373
    $external_links[] = $post->geodir_facebook;
1374
    $external_links = array_filter($external_links);
1375
1376
    if(!empty($external_links)){
1377
        $external_links = array_values($external_links);
1378
    }
1379
1380
    // reviews
1381
    $comment_count = geodir_get_review_count_total($post->ID);
1382
    $post_avgratings = geodir_get_post_rating($post->ID);
1383
1384
    // schema type
1385
    $schema_type = 'LocalBusiness';
1386
    if(isset($post->default_category) && $post->default_category){
1387
        $cat_schema = geodir_get_tax_meta($post->default_category, 'ct_cat_schema', false, $post->post_type);
1388
        if($cat_schema){$schema_type = $cat_schema;}
1389
        if(!$cat_schema && $schema_type=='LocalBusiness' && $post->post_type=='gd_event'){$schema_type = 'Event';}
1390
    }
1391
1392
    $schema = array();
1393
    $schema['@context'] = "https://schema.org";
1394
    $schema['@type'] = $schema_type;
1395
    $schema['name'] = $post->post_title;
1396
    $schema['description'] = wp_strip_all_tags( $post->post_content, true );
1397
    $schema['telephone'] = $post->geodir_contact;
1398
    $schema['url'] = $c_url;
1399
    $schema['sameAs'] = $external_links;
1400
    $schema['image'] = $images;
1401
    $schema['address'] = array(
1402
        "@type" => "PostalAddress",
1403
        "streetAddress" => $post->post_address,
1404
        "addressLocality" => $post->post_city,
1405
        "addressRegion" => $post->post_region,
1406
        "addressCountry" => $post->post_country,
1407
        "postalCode" => $post->post_zip
1408
    );
1409
1410
    if($post->post_latitude && $post->post_longitude) {
1411
        $schema['geo'] = array(
1412
            "@type" => "GeoCoordinates",
1413
            "latitude" => $post->post_latitude,
1414
            "longitude" => $post->post_longitude
1415
        );
1416
    }
1417
1418
    if($post_avgratings) {
1419
        $schema['aggregateRating'] = array(
1420
            "@type" => "AggregateRating",
1421
            "ratingValue" => $post_avgratings,
1422
            "bestRating" => "5", // @todo this will need to be filtered for review manager if user changes the score.
1423
            "worstRating" => "1",
1424
            "ratingCount" => $comment_count
1425
        );
1426
    }
1427
    $schema['review'] = $reviews;
1428
1429
    /**
1430
     * Allow the schema JSON-LD info to be filtered.
1431
     *
1432
     * @since 1.5.4
1433
     * @since 1.5.7 Added $post variable.
1434
     * @param array $schema The array of schema data to be filtered.
1435
     * @param object $post The post object.
1436
     */
1437
    $schema = apply_filters('geodir_details_schema', $schema,$post);
1438
1439
1440
    echo '<script type="application/ld+json">' . json_encode($schema) . '</script>';
1441
1442
1443
    $uploads = wp_upload_dir();
1444
    $facebook_og = (isset($post->featured_image) && $post->featured_image) ? '<meta property="og:image" content="'.$uploads['baseurl'].$post->featured_image.'"/>' : '';
1445
1446
    /**
1447
     * Show facebook open graph meta info
1448
     *
1449
     * @since 1.6.6
1450
     * @param string $facebook_og The open graph html to be filtered.
1451
     * @param object $post The post object.
1452
     */
1453
    echo apply_filters('geodir_details_facebook_og', $facebook_og,$post);
1454
1455
1456
1457
}
1458
1459
add_action('geodir_details_tabs', 'geodir_show_detail_page_tabs', 10);
1460
1461
1462
add_action('geodir_details_next_prev', 'geodir_action_details_next_prev', 10);
1463
/**
1464
 * Outputs the prev/next links of the post details page.
1465
 *
1466
 * This is called by a filter 'geodir_details_next_prev' and can be replaced.
1467
 *
1468
 * @since 1.0.0
1469
 * @package GeoDirectory
1470
 */
1471
function geodir_action_details_next_prev()
1472
{
1473
    ?>
1474
    <div class="geodir-pos_navigation clearfix">
1475
    <div
1476
        class="geodir-post_left"><?php previous_post_link('%link', '' . __('Previous', 'geodirectory'), false) ?></div>
1477
    <div
1478
        class="geodir-post_right"><?php next_post_link('%link', __('Next', 'geodirectory') . '', false) ?></div>
1479
    </div><?php
1480
}
1481
1482
/**
1483
 * Outputs the action 'geodir_before_single_post' on the details page main content.
1484
 *
1485
 * @since 1.0.0
1486
 * @package GeoDirectory
1487
 * @global object $post The current post object.
1488
 */
1489
function geodir_action_before_single_post()
1490
{
1491
    global $post;
1492
    /**
1493
     * Called at the very start of the details page output, before the title section.
1494
     *
1495
     * @since 1.0.0
1496
     * @param object $post The current post object.
1497
     * @global WP_Post|null $post The current post, if available.
1498
     */
1499
    do_action('geodir_before_single_post', $post); // extra action	
1500
}
1501
1502
/**
1503
 * Outputs the action 'geodir_after_single_post' on the details page main content.
1504
 *
1505
 * @since 1.0.0
1506
 * @package GeoDirectory
1507
 */
1508
function geodir_action_after_single_post($post)
1509
{
1510
    /**
1511
     * Called on the details page after the details page tabs section and before the next/prev buttons.
1512
     *
1513
     * @since 1.0.0
1514
     * @param object $post The current post object.
1515
     */
1516
    do_action('geodir_after_single_post', $post); // extra action	
1517
}
1518
1519
add_action('geodir_details_main_content', 'geodir_action_before_single_post', 10);
1520
add_action('geodir_details_main_content', 'geodir_action_page_title', 20);
1521
add_action('geodir_details_main_content', 'geodir_action_details_slider', 30);
1522
add_action('geodir_details_main_content', 'geodir_action_details_taxonomies', 40);
1523
add_action('geodir_details_main_content', 'geodir_show_detail_page_tabs', 60);
1524
add_action('geodir_details_main_content', 'geodir_action_after_single_post', 70);
1525
add_action('geodir_details_main_content', 'geodir_action_details_next_prev', 80);
1526
1527
1528
###############################################
1529
########### LISTINGS PAGE ACTIONS #############
1530
###############################################
1531
add_action('geodir_listings_page_title', 'geodir_action_listings_title', 10);
1532
/**
1533
 * Outputs the listings template title.
1534
 *
1535
 * @since 1.0.0
1536
 * @package GeoDirectory
1537
 * @global object $wp The WordPress object.
1538
 * @global string $term Current term slug.
1539
 */
1540
function geodir_action_listings_title()
1541
{
1542
    global $wp, $term;
1543
1544
    $gd_post_type = geodir_get_current_posttype();
1545
    $post_type_info = get_post_type_object($gd_post_type);
1546
1547
    $add_string_in_title = __('All', 'geodirectory') . ' ';
1548
    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
1549
        $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
1550
    }
1551
1552
    $list_title = $add_string_in_title . __($post_type_info->labels->name, 'geodirectory');
1553
    $single_name = $post_type_info->labels->singular_name;
1554
1555
    $taxonomy = geodir_get_taxonomies($gd_post_type, true);
1556
1557
    $gd_country = get_query_var('gd_country');
1558
    $gd_region = get_query_var('gd_region');
1559
    $gd_city = get_query_var('gd_city');
1560
1561
    if (!empty($term)) {
1562
        $location_name = '';
1563
        if ($gd_country != '' || $gd_region != '' || $gd_city != '') {
1564
            if ($gd_country != '') {
1565
                $location_name = geodir_sanitize_location_name('gd_country', $gd_country);
1566
            }
1567
1568
            if ($gd_region != '') {
1569
                $location_name = geodir_sanitize_location_name('gd_region', $gd_region);
1570
            }
1571
1572
            if ($gd_city != '') {
1573
                $location_name = geodir_sanitize_location_name('gd_city', $gd_city);
1574
            }
1575
        }
1576
1577
        $current_term = get_term_by('slug', $term, $taxonomy[0]);
1578
        if (!empty($current_term)) {
1579
            $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory');
1580
            if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
1581
                $location_last_char = substr($location_name, -1);
1582
                $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
1583
                $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
1584
            } else {
1585
                $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
1586
            }
1587
        } else {
1588
            if (count($taxonomy) > 1) {
1589
                $current_term = get_term_by('slug', $term, $taxonomy[1]);
1590
1591
                if (!empty($current_term)) {
1592
                    $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory');
1593
                    if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
1594
                        $location_last_char = substr($location_name, -1);
1595
                        $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
1596
                        $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
1597
                    } else {
1598
                        $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
1599
                    }
1600
                }
1601
            }
1602
        }
1603
1604
    } else {
1605
        $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
1606
        $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
1607
        $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
1608
1609
        $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
1610
1611
        if (function_exists('get_actual_location_name')) {
1612
            $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
1613
            $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
1614
            $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
1615
        }
1616
1617
        if ($gd_city != '') {
1618
            if ($gd_city_actual != '') {
1619
                $gd_city = $gd_city_actual;
1620
            } else {
1621
                $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
1622
                $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
1623
                $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
1624
            }
1625
1626
            $list_title .= __(' in', 'geodirectory') . " '" . $gd_city . "'";
1627
        } else if ($gd_region != '') {
1628
            if ($gd_region_actual != '') {
1629
                $gd_region = $gd_region_actual;
1630
            } else {
1631
                $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
1632
                $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
1633
                $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
1634
            }
1635
1636
            $list_title .= __(' in', 'geodirectory') . " '" . $gd_region . "'";
1637
        } else if ($gd_country != '') {
1638
            if ($gd_country_actual != '') {
1639
                $gd_country = $gd_country_actual;
1640
            } else {
1641
                $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
1642
                $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
1643
                $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
1644
            }
1645
1646
            $list_title .= __(' in', 'geodirectory') . " '" . $gd_country . "'";
1647
        }
1648
    }
1649
1650
    if (is_search()) {
1651
        $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
1652
    }
1653
    /** This action is documented in geodirectory_template_actions.php */
1654
    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
1655
    /** This action is documented in geodirectory_template_actions.php */
1656
    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
1657
1658
1659
    $title = $list_title;
1660
    $gd_page = '';
1661
    if(geodir_is_page('pt')){
1662
        $gd_page = 'pt';
1663
        $title  = (get_option('geodir_page_title_pt')) ? get_option('geodir_page_title_pt') : $title;
1664
    }
1665
    elseif(geodir_is_page('listing')){
1666
        $gd_page = 'listing';
1667
        global $wp_query;
1668
        $current_term = $wp_query->get_queried_object();
1669
        if (strpos($current_term->taxonomy,'_tags') !== false) {
1670
            $title = (get_option('geodir_page_title_tag-listing')) ? get_option('geodir_page_title_tag-listing') : $title;
1671
        }else{
1672
            $title = (get_option('geodir_page_title_cat-listing')) ? get_option('geodir_page_title_cat-listing') : $title;
1673
        }
1674
1675
    }
1676
    elseif(geodir_is_page('author')){
1677
        $gd_page = 'author';
1678
        if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
1679
            $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
1680
        }else{
1681
            $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
1682
        }
1683
1684
    }
1685
1686
1687
    /**
1688
     * Filter page title to replace variables.
1689
     *
1690
     * @since 1.5.4
1691
     * @param string $title The page title including variables.
1692
     * @param string $gd_page The GeoDirectory page type if any.
1693
     */
1694
    $title =  apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
1695
1696
    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' .
1697
        /**
1698
         * Filter the listing page title.
1699
         *
1700
         * @since 1.0.0
1701
         * @param string $list_title The title for the category page.
1702
         */
1703
        apply_filters('geodir_listing_page_title', $title) . '</h1></header>';
1704
}
1705
1706
add_action('geodir_listings_page_description', 'geodir_action_listings_description', 10);
1707
/**
1708
 * Outputs the listings page description HTML.
1709
 *
1710
 * @since 1.0.0
1711
 * @package GeoDirectory
1712
 * @global object $wp_query WordPress Query object.
1713
 */
1714
function geodir_action_listings_description()
1715
{
1716
    global $wp_query;
1717
    $current_term = $wp_query->get_queried_object();
1718
1719
    $gd_post_type = geodir_get_current_posttype();
1720
    if (isset($current_term->term_id) && $current_term->term_id != '') {
1721
1722
        $term_desc = term_description($current_term->term_id, $gd_post_type . '_tags');
1723
        $saved_data = stripslashes(geodir_get_tax_meta($current_term->term_id, 'ct_cat_top_desc', false, $gd_post_type));
1724
        if ($term_desc && !$saved_data) {
1725
            $saved_data = $term_desc;
1726
        }
1727
1728
        // stop payment manager filtering content length
1729
        $filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' );
1730
        if ( false !== $filter_priority ) {
1731
            remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority );
1732
        }
1733
1734
        /**
1735
         * Apply the core filter `the_content` filter to the variable string.
1736
         *
1737
         * This is a WordPress core filter that does many things.
1738
         *
1739
         * @since 1.0.0
1740
         * @param string $var The string to apply the filter to.
1741
         */
1742
        $cat_description = apply_filters('the_content', $saved_data);
1743
1744
1745
        if ( false !== $filter_priority ) {
1746
            add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority );
1747
        }
1748
1749
        if ($cat_description) {
1750
            ?>
1751
1752
            <div class="term_description"><?php echo $cat_description;?></div> <?php
1753
        }
1754
1755
    }
1756
}
1757
1758
// action for adding the listings page top widget area
1759
add_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10);
1760
add_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20);
1761
1762
// action for adding the details page top widget area
1763
add_action('geodir_sidebar_listings_top', 'geodir_action_geodir_sidebar_listings_top', 10);
1764
/**
1765
 * Outputs the listings page top section widget area if enabled.
1766
 *
1767
 * Can be enabled disabled from GD>Design>Listings page.
1768
 *
1769
 * @since 1.0.0
1770
 * @package GeoDirectory
1771
 */
1772
function geodir_action_geodir_sidebar_listings_top()
1773
{
1774
    if (get_option('geodir_show_listing_top_section')) { ?>
1775
        <div
1776
            class="<?php
1777
            /** This action is documented in geodirectory_template_actions.php */
1778
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_top'); ?>">
1779
            <?php dynamic_sidebar('geodir_listing_top'); ?>
1780
        </div><!-- clearfix ends here-->
1781
    <?php }
1782
1783
}
1784
1785
// action for adding the sidebar opening tag
1786
add_action('geodir_sidebar_left_open', 'geodir_action_sidebar_left_open', 10, 4);
1787
/**
1788
 * Outputs the listings page left sidebar opening HTML wrapper if enabled.
1789
 *
1790
 * Can be enabled disabled from GD>Design>Listings page.
1791
 *
1792
 * @since 1.0.0
1793
 * @package GeoDirectory
1794
 * @param string $type Optional. The page type.
1795
 * @param int $id Optional. The id for the HTML element.
1796
 * @param string $class Optional. The class for the HTML element.
1797
 * @param string $itemtype Optional The itemtype property of the HTML element.
1798
 */
1799
function geodir_action_sidebar_left_open($type = '', $id = '', $class = '', $itemtype = '')
1800
{
1801
    if ($type == 'home-page' && $width = get_option('geodir_width_home_left_section')) {
1802
        $width_css = 'style="width:' . $width . '%;"';
1803
    } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_left_section')) {
1804
        $width_css = 'style="width:' . $width . '%;"';
1805
    } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_left_section')) {
1806
        $width_css = 'style="width:' . $width . '%;"';
1807
    } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_left_section')) {
1808
        $width_css = 'style="width:' . $width . '%;"';
1809
    } else {
1810
        $width_css = '';
1811
    }
1812
1813
    $tc = get_option('theme_compatibility_setting');
1814
    if (!empty($tc['geodir_sidebar_left_open_replace'])) {
1815
        $text = $tc['geodir_sidebar_left_open_replace'];
1816
    } else {
1817
        $text = '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>';
1818
    }
1819
1820
    if (!empty($tc['geodir_sidebar_left_open_id'])) {
1821
        $id = $tc['geodir_sidebar_left_open_id'];
1822
    }
1823
    if (!empty($tc['geodir_sidebar_left_open_class'])) {
1824
        $class = $tc['geodir_sidebar_left_open_class'];
1825
    }
1826
1827
    $text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
1828
1829
    echo $text;
1830
}
1831
1832
// action for adding the primary div closing tag
1833
add_action('geodir_sidebar_left_close', 'geodir_action_sidebar_left_close', 10, 1);
1834
/**
1835
 * Outputs the listings page left sidebar closing HTML wrapper if enabled.
1836
 *
1837
 * Can be enabled disabled from GD>Design>Listings page.
1838
 *
1839
 * @since 1.0.0
1840
 * @package GeoDirectory
1841
 * @param string $type Optional. Depreciated.
1842
 */
1843
function geodir_action_sidebar_left_close($type = '')
1844
{
1845
    $tc = get_option('theme_compatibility_setting');
1846
    if (!empty($tc['geodir_sidebar_left_close_replace'])) {
1847
        $text = $tc['geodir_sidebar_left_close_replace'];
1848
    } else {
1849
        $text = '</aside><!-- sidebar ends here-->';
1850
    }
1851
    echo $text;
1852
}
1853
1854
/**
1855
 * Outputs the listings page left sidebar content including inner wrapper if enabled.
1856
 *
1857
 * Can be enabled disabled from GD>Design>Listings page.
1858
 *
1859
 * @since 1.0.0
1860
 * @package GeoDirectory
1861
 */
1862
function geodir_listing_left_section()
1863
{
1864
    if (get_option('geodir_show_listing_left_section')) { ?>
1865
        <div class="geodir-content-left geodir-sidebar-wrap">
1866
            <?php dynamic_sidebar('geodir_listing_left_sidebar'); ?>
1867
        </div><!-- end geodir-content-left -->
1868
    <?php }
1869
}
1870
1871
add_action('geodir_listings_sidebar_left_inside', 'geodir_listing_left_section', 10);
1872
1873
add_action('geodir_listings_sidebar_left', 'geodir_action_listings_sidebar_left', 10);
1874
/**
1875
 * Outputs the listings left sidebar via action call.
1876
 *
1877
 * @since 1.0.0
1878
 * @package GeoDirectory
1879
 */
1880
function geodir_action_listings_sidebar_left()
1881
{
1882
    if (get_option('geodir_show_listing_left_section')) {
1883
        /** This action is documented in geodirectory_template_actions.php */
1884
        do_action('geodir_sidebar_left_open', 'listings-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'https://schema.org/WPSideBar');
1885
        /**
1886
         * Calls the listings page (category) left sidebar content.
1887
         *
1888
         * All the content for the listings page left sidebar is added via this hook.
1889
         *
1890
         * @since 1.0.0
1891
         */
1892
        do_action('geodir_listings_sidebar_left_inside');
1893
        /** This action is documented in geodirectory_template_actions.php */
1894
        do_action('geodir_sidebar_left_close', 'listings-page');
1895
    }
1896
}
1897
1898
/**
1899
 * Outputs the listings page right sidebar content including inner wrapper if enabled.
1900
 *
1901
 * Can be enabled disabled from GD>Design>Listings page.
1902
 *
1903
 * @since 1.0.0
1904
 * @package GeoDirectory
1905
 */
1906
function geodir_listing_right_section()
1907
{
1908
    if (get_option('geodir_show_listing_right_section')) { ?>
1909
        <div class="geodir-content-right geodir-sidebar-wrap">
1910
            <?php dynamic_sidebar('geodir_listing_right_sidebar'); ?>
1911
        </div><!-- end geodir-content-right -->
1912
    <?php }
1913
}
1914
1915
add_action('geodir_listings_sidebar_right_inside', 'geodir_listing_right_section', 10);
1916
1917
add_action('geodir_listings_sidebar_right', 'geodir_action_listings_sidebar_right', 10);
1918
/**
1919
 * Outputs the listings right sidebar via action call.
1920
 *
1921
 * @since 1.0.0
1922
 * @package GeoDirectory
1923
 */
1924
function geodir_action_listings_sidebar_right()
1925
{
1926
    if (get_option('geodir_show_listing_right_section')) {
1927
        /** This action is documented in geodirectory_template_actions.php */
1928
        do_action('geodir_sidebar_right_open', 'listings-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
1929
        /**
1930
         * Calls the listings page (category) right sidebar content.
1931
         *
1932
         * All the content for the listings page right sidebar is added via this hook.
1933
         *
1934
         * @since 1.0.0
1935
         */
1936
        do_action('geodir_listings_sidebar_right_inside');
1937
        /** This action is documented in geodirectory_template_actions.php */
1938
        do_action('geodir_sidebar_right_close', 'listings-page');
1939
    }
1940
}
1941
1942
1943
// action for adding the sidebar opening tag
1944
add_action('geodir_main_content_open', 'geodir_action_main_content_open', 10, 3);
1945
/**
1946
 * Outputs the main content opening HTML elements.
1947
 *
1948
 * @param string $type Optional. Depreciated.
1949
 * @param string $id Optional. The HTML element id.
1950
 * @param string $class Optional. The HTML element class.
1951
 * @since 1.0.0
1952
 * @package GeoDirectory
1953
 */
1954
function geodir_action_main_content_open($type = '', $id = '', $class = '')
1955
{
1956
    $tc = get_option('theme_compatibility_setting');
1957
    if (!empty($tc['geodir_main_content_open_replace'])) {
1958
        $text = $tc['geodir_main_content_open_replace'];
1959
    } else {
1960
        $text = '<main id="[id]" class="[class]" role="main">';
1961
    }
1962
1963
    if (!empty($tc['geodir_main_content_open_id'])) {
1964
        $id = $tc['geodir_main_content_open_id'];
1965
    }
1966
    if (!empty($tc['geodir_main_content_open_class'])) {
1967
        $class = $tc['geodir_main_content_open_class'];
1968
    }
1969
1970
    $text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
1971
1972
    echo $text;
1973
}
1974
1975
// action for adding the primary div closing tag
1976
add_action('geodir_main_content_close', 'geodir_action_main_content_close', 10);
1977
/**
1978
 * Outputs the main content closing HTML elements.
1979
 *
1980
 * @since 1.0.0
1981
 * @package GeoDirectory
1982
 */
1983
function geodir_action_main_content_close()
1984
{
1985
    $tc = get_option('theme_compatibility_setting');
1986
    if (!empty($tc['geodir_main_content_close_replace'])) {
1987
        $text = $tc['geodir_main_content_close_replace'];
1988
    } else {
1989
        $text = '</main><!-- main ends here-->';
1990
    }
1991
    echo $text;
1992
}
1993
1994
/**
1995
 * Calls the listing template part.
1996
 *
1997
 * @since 1.0.0
1998
 * @package GeoDirectory
1999
 * @global string $gridview_columns The girdview style of the listings.
2000
 */
2001
function geodir_action_listings_content_inside()
2002
{
2003
    global $gridview_columns;
2004
    $listing_view = get_option('geodir_listing_view');
2005
    if (strstr($listing_view, 'gridview')) {
2006
        $gridview_columns = $listing_view;
2007
        $listing_view_exp = explode('_', $listing_view);
2008
        $listing_view = $listing_view_exp[0];
2009
    }
2010
    geodir_get_template_part('listing', 'listview');
2011
}
2012
2013
add_action('geodir_listings_content_inside', 'geodir_action_listings_content_inside', 10);
2014
add_action('geodir_listings_content_inside', 'geodir_pagination', 20);
2015
2016
2017
add_action('geodir_listings_content', 'geodir_action_listings_content', 10);
2018
/**
2019
 * Builds and outputs the listings content via actions.
2020
 *
2021
 * @since 1.0.0
2022
 * @package GeoDirectory
2023
 */
2024
function geodir_action_listings_content()
2025
{
2026
    /**
2027
     * This is used to add HTML opening wrappers to the main content of most pages including listings, author, search, home etc.
2028
     *
2029
     * @since 1.0.0
2030
     * @param string $type The page type. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'.
2031
     * @param string $id The id for the div. Usually 'geodir-main-content'.
2032
     * @param string $class The class for the div. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'.
2033
     * @see 'geodir_main_content_close' Where the oposing closing tag is added.
2034
     */
2035
    do_action('geodir_main_content_open', 'listings-page', 'geodir-main-content', 'listings-page');
2036
    $extra_class = apply_filters('geodir_before_listing_wrapper_extra_class', '', 'listings-page');
2037
    echo '<div class="clearfix '.$extra_class.'">';
2038
    /**
2039
     * Called before the listings page content, inside the outer wrapper. Used on listings pages and search and author pages.
2040
     *
2041
     * @since 1.0.0
2042
     */
2043
    do_action('geodir_before_listing');
2044
    echo '</div>';
2045
2046
    /**
2047
     * This actions calls the listings list content. Used on listings pages and search and author pages.
2048
     *
2049
     * @since 1.0.0
2050
     */
2051
    do_action('geodir_listings_content_inside');
2052
2053
    /**
2054
     * Called after the listings content, inside the outer wrapper HTML. Used on listings pages and search and author pages.
2055
     *
2056
     * @since 1.0.0
2057
     */
2058
    do_action('geodir_after_listing');
2059
2060
    /**
2061
     * This is used to add HTML closing wrappers to the main content of most pages including listings, author, search, home etc.
2062
     *
2063
     * @since 1.0.0
2064
     * @see 'geodir_main_content_open' Where the oposing opening tag is added.
2065
     */
2066
    do_action('geodir_main_content_close', 'listings-page');
2067
}
2068
2069
2070
add_action('geodir_sidebar_listings_bottom_section', 'geodir_action_sidebar_listings_bottom_section', 10);
2071
/**
2072
 * Outputs the listings page bottom widget area if enabled.
2073
 *
2074
 * Can be enabled/disabled via GD>Design>Listings page.
2075
 *
2076
 * @since 1.0.0
2077
 * @package GeoDirectory
2078
 */
2079
function geodir_action_sidebar_listings_bottom_section()
2080
{
2081
    if (get_option('geodir_show_listing_bottom_section')) { ?>
2082
        <div class="<?php
2083
            /** This action is documented in geodirectory_template_actions.php */
2084
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_bottom'); ?>">
2085
            <?php dynamic_sidebar('geodir_listing_bottom'); ?>
2086
        </div><!-- clearfix ends here-->
2087
    <?php }
2088
}
2089
2090
###############################################
2091
######## ADD LISTINGS PAGE ACTIONS ############
2092
###############################################
2093
2094
2095
add_action('geodir_add_listing_page_title', 'geodir_action_add_listing_page_title', 10);
2096
/**
2097
 * Outputs the add listings page title with HTML wrappers of which most can be filtered.
2098
 *
2099
 * @since 1.0.0
2100
 * @package GeoDirectory
2101
 */
2102
function geodir_action_add_listing_page_title()
2103
{
2104
    if (isset($_REQUEST['listing_type']) && $_REQUEST['listing_type'] != '')
2105
        $listing_type = sanitize_text_field($_REQUEST['listing_type']);
2106
    /** This action is documented in geodirectory_template_actions.php */
2107
    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
2108
    /** This action is documented in geodirectory_template_actions.php */
2109
    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
2110
2111
    $title = apply_filters('geodir_add_listing_page_title_text', get_the_title());
2112
2113
    if(geodir_is_page('add-listing')){
2114
        $gd_page = 'add-listing';
2115
        if(isset($_REQUEST['pid']) && $_REQUEST['pid'] != ''){
2116
            $title = (get_option('geodir_page_title_edit-listing')) ? get_option('geodir_page_title_edit-listing') : $title;
2117
        }elseif(isset($listing_type)){
2118
            $title = (get_option('geodir_page_title_add-listing')) ? get_option('geodir_page_title_add-listing') : $title;
2119
        }
2120
2121
    }
2122
2123
2124
    /**
2125
     * Filter page title to replace variables.
2126
     *
2127
     * @since 1.5.4
2128
     * @param string $title The page title including variables.
2129
     * @param string $gd_page The GeoDirectory page type if any.
2130
     */
2131
    $title =  apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
2132
2133
    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">';
2134
    echo $title;
2135
    echo '</h1></header>';
2136
}
2137
2138
add_action('geodir_add_listing_page_mandatory', 'geodir_action_add_listing_page_mandatory', 10);
2139
/**
2140
 * Outputs the add listing page mandatory message.
2141
 *
2142
 * @since 1.0.0
2143
 * @package GeoDirectory
2144
 */
2145
function geodir_action_add_listing_page_mandatory()
2146
{?>
2147
    <p class="geodir-note "><span class="geodir-required">*</span>&nbsp;<?php echo INDICATES_MANDATORY_FIELDS_TEXT;?></p>
2148
<?php
2149
}
2150
2151
add_action('geodir_add_listing_form', 'geodir_action_add_listing_form', 10);
2152
/**
2153
 * Outputs the add listing form HTML content.
2154
 *
2155
 * Other things are needed to output a working add listing form, you should use the add listing shortcode if needed.
2156
 *
2157
 * @since 1.0.0
2158
 * @package GeoDirectory
2159
 * @global object $current_user Current user object.
2160
 * @global object $post The current post object.
2161
 * @global object $post_images Image objects of current post if available.
2162
 * @global object $gd_session GeoDirectory Session object.
2163
 */
2164
function geodir_action_add_listing_form()
2165
{
2166
    global $cat_display, $post_cat, $current_user, $gd_session;
2167
    $page_id = get_the_ID();
2168
    $post = '';
2169
    $title = '';
2170
    $desc = '';
2171
    $kw_tags = '';
2172
    $required_msg = '';
2173
    $submit_button = '';
2174
2175
    $ajax_action = isset($_REQUEST['ajax_action']) ? $_REQUEST['ajax_action'] : 'add';
2176
2177
    $thumb_img_arr = array();
2178
    $curImages = '';
2179
2180
    if (isset($_REQUEST['backandedit'])) {
2181
        global $post;
2182
        $post = (object)$gd_session->get('listing');
2183
        $listing_type = $post->listing_type;
2184
        $title = $post->post_title;
2185
        $desc = $post->post_desc;
2186
        $post_cat = isset($post->post_category) ? $post->post_category : '';
2187
2188
        $kw_tags = $post->post_tags;
2189
        $curImages = isset($post->post_images) ? $post->post_images : '';
2190
    } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2191
        global $post, $post_images;
2192
2193
        $post = geodir_get_post_info($_REQUEST['pid']);
2194
        $thumb_img_arr = geodir_get_images($post->ID);
2195
        if ($thumb_img_arr) {
2196
            foreach ($thumb_img_arr as $post_img) {
2197
                $curImages .= $post_img->src . ',';
2198
            }
2199
        }
2200
2201
        $listing_type = $post->post_type;
2202
        $title = $post->post_title;
2203
        $desc = $post->post_content;
2204
        $kw_tags = $post->post_tags;
2205
        $kw_tags = implode(",", wp_get_object_terms($post->ID, $listing_type . '_tags', array('fields' => 'names')));
2206
    } else {
2207
        $listing_type = sanitize_text_field($_REQUEST['listing_type']);
2208
    }
2209
2210
    if ($current_user->ID != '0') {
2211
        $user_login = true;
2212
    }
2213
2214
    $post_type_info = geodir_get_posttype_info($listing_type);
2215
2216
    $cpt_singular_name = (isset($post_type_info['labels']['singular_name']) && $post_type_info['labels']['singular_name']) ? __($post_type_info['labels']['singular_name'], 'geodirectory') : __('Listing','geodirectory');
2217
    
2218
    $package_info = array();
2219
    $package_info = geodir_post_package_info($package_info, $post);
2220
    ?>
2221
    <form name="propertyform" id="propertyform" action="<?php echo get_page_link(geodir_preview_page_id());?>" method="post" enctype="multipart/form-data">
2222
        <input type="hidden" name="preview" value="<?php echo sanitize_text_field($listing_type);?>"/>
2223
        <input type="hidden" name="listing_type" value="<?php echo sanitize_text_field($listing_type);?>"/>
2224
        <?php if ($page_id) { ?>
2225
        <input type="hidden" name="add_listing_page_id" value="<?php echo $page_id;?>"/>
2226
        <?php } if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { ?>
2227
            <input type="hidden" name="pid" value="<?php echo sanitize_text_field($_REQUEST['pid']);?>"/>
2228
        <?php } if (isset($_REQUEST['backandedit'])) { ?>
2229
            <input type="hidden" name="backandedit" value="<?php echo sanitize_text_field($_REQUEST['backandedit']);?>"/>
2230
        <?php
2231
        } 
2232
        /**
2233
         * Called at the very top of the add listing page form for frontend.
2234
         *
2235
         * This is called just before the "Enter Listing Details" text.
2236
         *
2237
         * @since 1.0.0
2238
         */
2239
        do_action('geodir_before_detail_fields');
2240
        ?>
2241
        <h5 id="geodir_fieldset_details" class="geodir-fieldset-row" gd-fieldset="details"><?php echo LISTING_DETAILS_TEXT;?></h5>
2242
        <?php
2243
        /**
2244
         * Called at the top of the add listing page form for frontend.
2245
         *
2246
         * This is called after the "Enter Listing Details" text.
2247
         *
2248
         * @since 1.0.0
2249
         */
2250
        do_action('geodir_before_main_form_fields');
2251
        ?>
2252
        <div id="geodir_post_title_row" class="required_field geodir_form_row clearfix gd-fieldset-details">
2253
            <label><?php
2254
                /**
2255
                 * Filter the add listing page title input label.
2256
                 *
2257
                 * @since 1.6.11
2258
                 * @param string $title The title to be output.
2259
                 * @param string $cpt_singular_name The singular title of the curent CPT.
2260
                 * @param string $listing_type The CPT being requested. ie: gd_place.
2261
                 */
2262
                echo apply_filters('geodir_add_listing_title_label', sprintf( __('%s Title', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span>*</span> </label>
2263
            <input type="text" field_type="text" name="post_title" id="post_title" class="geodir_textfield"
2264
                   value="<?php echo esc_attr(stripslashes($title)); ?>"/>
2265
            <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory');?></span>
2266
        </div>
2267
        <?php
2268
        $show_editor = get_option('geodir_tiny_editor_on_add_listing');
2269
        $show_editor = !empty($show_editor) && in_array($listing_type, $show_editor) ? true : false;
2270
        /**
2271
         * Filter whether to show or don't show the editor.
2272
         *
2273
         * @since 1.6.16
2274
         * @param bool $show_editor If true the editor will be available for description field.
2275
         * @param object $package_info The listing package.
2276
         * @param string $listing_type The current post type.
2277
         * @param object $post The current post object.
2278
         */
2279
        $show_editor = apply_filters('geodir_description_field_show_editor', $show_editor, $package_info, $listing_type, $post);
2280
2281
        $desc = $show_editor ? stripslashes($desc) : esc_attr(stripslashes($desc));
2282
        $desc_limit = '';
2283
        /**
2284
         * Filter the add listing description field character limit number.
2285
         *
2286
         * @since 1.0.0
2287
         * @param int $desc_limit The amount of characters to limit the description to.
2288
         */
2289
        $desc_limit = apply_filters('geodir_description_field_desc_limit', $desc_limit);
2290
        /**
2291
         * Filter the add listing description field text.
2292
         *
2293
         * @since 1.0.0
2294
         * @param string $desc The text for the description field.
2295
         * @param int $desc_limit The character limit number if any.
2296
         */
2297
        $desc = apply_filters('geodir_description_field_desc', $desc, $desc_limit);
2298
        $desc_limit_msg = '';
2299
        /**
2300
         * Filter the add listing description limit message.
2301
         *
2302
         * This is the message shown if there is a limit applied to the amount of characters the description can use.
2303
         *
2304
         * @since 1.0.0
2305
         * @param string $desc_limit_msg The limit message string if any.
2306
         * @param int $desc_limit The character limit numer if any.
2307
         */
2308
        $desc_limit_msg = apply_filters('geodir_description_field_desc_limit_msg', $desc_limit_msg, $desc_limit);
2309
        
2310
        $desc_class = '';
2311
        if ($desc_limit === '' || (int)$desc_limit > 0) {
2312
            /**
2313
             * Called on the add listing page form for frontend just before the description field.
2314
             *
2315
             * @since 1.0.0
2316
             */
2317
            do_action('geodir_before_description_field');
2318
            
2319
            $desc_class = ' required_field';
2320
        } else {
2321
            $desc_class = ' hidden';
2322
        }
2323
        ?>
2324
        <div id="geodir_post_desc_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $desc_class;?>">
2325
            <label><?php
2326
                /**
2327
                 * Filter the add listing page description input label.
2328
                 *
2329
                 * @since 1.6.11
2330
                 * @param string $title The title to be output.
2331
                 * @param string $cpt_singular_name The singular title of the curent CPT.
2332
                 * @param string $listing_type The CPT being requested. ie: gd_place.
2333
                 */
2334
                echo apply_filters('geodir_add_listing_description_label',sprintf( __('%s Description', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span><?php if ($desc_limit != '0') { echo '*'; } ?></span> </label>
2335
            <?php
2336
            if ($show_editor) {
2337
                $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
2338
            ?>
2339
                <div class="editor" field_id="post_desc" field_type="editor">
2340
                    <?php wp_editor($desc, "post_desc", $editor_settings); ?>
2341
                </div>
2342
            <?php if ($desc_limit != '') { ?>
2343
                <script type="text/javascript">jQuery('textarea#post_desc').attr('maxlength', "<?php echo $desc_limit;?>");</script>
2344
            <?php } } else { ?>
2345
                <textarea field_type="textarea" name="post_desc" id="post_desc" class="geodir_textarea" maxlength="<?php echo $desc_limit; ?>"><?php echo $desc; ?></textarea>
2346
            <?php } if ($desc_limit_msg != '') { ?>
2347
                <span class="geodir_message_note"><?php echo $desc_limit_msg; ?></span>
2348
            <?php } ?>
2349
            <span class="geodir_message_error"><?php echo _e($required_msg, 'geodirectory');?></span>
2350
        </div>
2351
        <?php
2352
        if ($desc_limit === '' || (int)$desc_limit > 0) {
2353
            /**
2354
             * Called on the add listing page form for frontend just after the description field.
2355
             *
2356
             * @since 1.0.0
2357
             */
2358
            do_action('geodir_after_description_field');
2359
        }
2360
        
2361
        $kw_tags = esc_attr(stripslashes($kw_tags));
2362
        $kw_tags_count = TAGKW_TEXT_COUNT;
2363
        $kw_tags_msg = TAGKW_MSG;
2364
        /**
2365
         * Filter the add listing tags character limit.
2366
         *
2367
         * @since 1.0.0
2368
         * @param int $kw_tags_count The character count limit if any.
2369
         */
2370
        $kw_tags_count = apply_filters('geodir_listing_tags_field_tags_count', $kw_tags_count);
2371
        /**
2372
         * Filter the add listing tags field value.
2373
         *
2374
         * You can use the $_REQUEST values to check if this is a go back and edit value etc.
2375
         *
2376
         * @since 1.0.0
2377
         * @param string $kw_tags The tag field value, usually a comma separated list of tags.
2378
         * @param int $kw_tags_count The character count limit if any.
2379
         */
2380
        $kw_tags = apply_filters('geodir_listing_tags_field_tags', $kw_tags, $kw_tags_count);
2381
        /**
2382
         * Filter the add listing tags field message text.
2383
         *
2384
         * @since 1.0.0
2385
         * @param string $kw_tags_msg The message shown under the field.
2386
         * @param int $kw_tags_count The character count limit if any.
2387
         */
2388
        $kw_tags_msg = apply_filters('geodir_listing_tags_field_tags_msg', $kw_tags_msg, $kw_tags_count);
2389
        
2390
        $tags_class = '';
2391
        if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
2392
            /**
2393
             * Called on the add listing page form for frontend just before the tags field.
2394
             *
2395
             * @since 1.0.0
2396
             */
2397
            do_action('geodir_before_listing_tags_field');
2398
        } else {
2399
            $tags_class = ' hidden';
2400
        }
2401
        ?>
2402
        <div id="geodir_post_tags_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $tags_class;?>">
2403
            <label><?php echo TAGKW_TEXT; ?></label>
2404
            <input name="post_tags" id="post_tags" value="<?php echo $kw_tags; ?>" type="text" class="geodir_textfield"
2405
                   maxlength="<?php echo $kw_tags_count;?>"/>
2406
            <span class="geodir_message_note"><?php echo $kw_tags_msg;?></span>
2407
        </div>
2408
        <?php
2409
        if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
2410
            /**
2411
             * Called on the add listing page form for frontend just after the tags field.
2412
             *
2413
             * @since 1.0.0
2414
             */
2415
            do_action('geodir_after_listing_tags_field');
2416
        }
2417
        
2418
        $package_info = array();
2419
        $package_info = geodir_post_package_info($package_info, $post);
2420
        
2421
        geodir_get_custom_fields_html($package_info->pid, 'all', $listing_type);
2422
        
2423
        // adjust values here
2424
        $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
2425
2426
        $multiple = true; // allow multiple files upload
2427
2428
        $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2429
2430
        $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2431
2432
        $thumb_img_arr = array();
2433
        $totImg = 0;
2434
        if (isset($_REQUEST['backandedit']) && empty($_REQUEST['pid'])) {
2435
            $post = (object)$gd_session->get('listing');
2436
            if (isset($post->post_images))
2437
                $curImages = trim($post->post_images, ",");
2438
2439
2440
            if ($curImages != '') {
2441
                $curImages_array = explode(',', $curImages);
2442
                $totImg = count($curImages_array);
2443
            }
2444
2445
            $listing_type = $post->listing_type;
2446
2447
        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2448
            $post = geodir_get_post_info((int)$_REQUEST['pid']);
2449
            $listing_type = $post->post_type;
2450
            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
2451
2452
        } else {
2453
            $listing_type = sanitize_text_field($_REQUEST['listing_type']);
2454
        }
2455
2456
2457
        if (!empty($thumb_img_arr)) {
2458
            foreach ($thumb_img_arr as $img) {
2459
                //$curImages = $img->src.",";
2460
            }
2461
2462
            $totImg = count((array)$thumb_img_arr);
2463
        }
2464
2465
        if ($curImages != '')
2466
            $svalue = $curImages; // this will be initial value of the above form field. Image urls.
2467
        else
2468
            $svalue = '';
2469
2470
        $image_limit = isset($package_info->image_limit) ? $package_info->image_limit : '0';
2471
        $show_image_input_box = ($image_limit != '0');
2472
        /**
2473
         * Filter to be able to show/hide the image upload section of the add listing form.
2474
         *
2475
         * @since 1.0.0
2476
         * @param bool $show_image_input_box Set true to show. Set false to not show.
2477
         * @param string $listing_type The custom post type slug.
2478
         */
2479
        $show_image_input_box = apply_filters('geodir_image_uploader_on_add_listing', $show_image_input_box, $listing_type);
2480
        if ($show_image_input_box) {
2481
            ?>
2482
2483
            <h5 id="geodir_form_title_row" class="geodir-form_title"> <?php echo PRO_PHOTO_TEXT;?>
2484
                <?php if ($image_limit == 1) {
2485
                    echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2486
                } ?>
2487
                <?php if ($image_limit > 1) {
2488
                    echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2489
                } ?>
2490
                <?php if ($image_limit == '') {
2491
                    echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2492
                } ?>
2493
            </h5>
2494
2495
            <div class="geodir_form_row clearfix" id="<?php echo $id; ?>dropbox"
2496
                 style="border:1px solid #ccc;min-height:100px;height:auto;padding:10px;text-align:center;">
2497
                <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/>
2498
                <input type="hidden" name="<?php echo $id; ?>image_limit" id="<?php echo $id; ?>image_limit"
2499
                       value="<?php echo $image_limit; ?>"/>
2500
                <input type="hidden" name="<?php echo $id; ?>totImg" id="<?php echo $id; ?>totImg"
2501
                       value="<?php echo $totImg; ?>"/>
2502
2503
                <div
2504
                    class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>"
2505
                    id="<?php echo $id; ?>plupload-upload-ui">
2506
                    <h4><?php _e('Drop files to upload', 'geodirectory');?></h4><br/>
2507
                    <input id="<?php echo $id; ?>plupload-browse-button" type="button"
2508
                           value="<?php esc_attr_e('Select Files', 'geodirectory'); ?>" class="geodir_button"/>
2509
                    <span class="ajaxnonceplu"
2510
                          id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span>
2511
                    <?php if ($width && $height): ?>
2512
                        <span class="plupload-resize"></span>
2513
                        <span class="plupload-width" id="plupload-width<?php echo $width; ?>"></span>
2514
                        <span class="plupload-height" id="plupload-height<?php echo $height; ?>"></span>
2515
                    <?php endif; ?>
2516
                    <div class="filelist"></div>
2517
                </div>
2518
2519
                <div class="plupload-thumbs <?php if ($multiple): ?>plupload-thumbs-multiple<?php endif; ?> clearfix"
2520
                     id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;">
2521
                </div>
2522
                <span
2523
                    id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory');?></span>
2524
                <span id="<?php echo $id; ?>upload-error" style="display:none"></span>
2525
            </div>
2526
2527
        <?php } ?>
2528
2529
        <?php
2530
        /**
2531
         * Called on the add listing page form for frontend just after the image upload field.
2532
         *
2533
         * @since 1.0.0
2534
         */
2535
        do_action('geodir_after_main_form_fields');?>
2536
2537
2538
        <!-- add captcha code -->
2539
2540
        <script>
2541
            /*<!--<script>-->*/
2542
            document.write('<inp' + 'ut type="hidden" id="geodir_sp' + 'amblocker_top_form" name="geodir_sp' + 'amblocker" value="64"/>');
2543
        </script>
2544
        <noscript>
2545
            <div>
2546
                <label><?php _e('Type 64 into this box', 'geodirectory');?></label>
2547
                <input type="text" id="geodir_spamblocker_top_form" name="geodir_spamblocker" value="" maxlength="10"/>
2548
            </div>
2549
        </noscript>
2550
        <input type="text" id="geodir_filled_by_spam_bot_top_form" name="geodir_filled_by_spam_bot" value=""/>
2551
2552
2553
        <!-- end captcha code -->
2554
2555
        <div id="geodir-add-listing-submit" class="geodir_form_row clear_both" style="padding:2px;text-align:center;">
2556
            <input type="submit" value="<?php echo PRO_PREVIEW_BUTTON;?>"
2557
                   class="geodir_button" <?php echo $submit_button;?>/>
2558
            <span class="geodir_message_note"
2559
                  style="padding-left:0px;"> <?php _e('Note: You will be able to see a preview in the next page', 'geodirectory');?></span>
2560
        </div>
2561
2562
    </form>
2563
    <?php
2564
    wp_reset_query();
2565
}
2566
2567
/**
2568
 * Output the add listing sidebar.
2569
 *
2570
 * @since 1.0.0
2571
 * @package GeoDirectory
2572
 */
2573
function geodir_add_listing_sidebar_widget_area()
2574
{
2575
    dynamic_sidebar('geodir_add_listing_sidebar');
2576
}
2577
2578
add_action('geodir_add_listing_sidebar_inside', 'geodir_add_listing_sidebar_widget_area', 10);
2579
2580
add_action('geodir_add_listing_sidebar', 'geodir_action_add_listing_sidebar', 10);
2581
2582
/**
2583
 * Output the add listing sidebar including all HTML wrappers.
2584
 *
2585
 * @since 1.0.0
2586
 * @package GeoDirectory
2587
 */
2588
function geodir_action_add_listing_sidebar()
2589
{
2590
    /** This action is documented in geodirectory_template_actions.php */
2591
    do_action('geodir_sidebar_right_open', 'add-listing-page', 'geodir-sidebar', 'geodir-sidebar-right', 'http://schema.org/WPSideBar');
2592
    /**
2593
     * This is used to add the content to the add listing page sidebar.
2594
     *
2595
     * @since 1.0.0
2596
     */
2597
    do_action('geodir_add_listing_sidebar_inside');
2598
    /** This action is documented in geodirectory_template_actions.php */
2599
    do_action('geodir_sidebar_right_close', 'details-page');
2600
}
2601
2602
###############################################
2603
######## SIGNUP/REG PAGE ACTIONS ##############
2604
###############################################
2605
2606
// action for adding the details page top widget area
2607
add_action('geodir_sidebar_signup_top', 'geodir_action_geodir_sidebar_signup_top', 10);
2608
/**
2609
 * Output the signup/register page top section widget area.
2610
 *
2611
 * @since 1.0.0
2612
 * @package GeoDirectory
2613
 */
2614
function geodir_action_geodir_sidebar_signup_top()
2615
{
2616
    ?>
2617
    <div
2618
        class="<?php
2619
        /** This action is documented in geodirectory_template_actions.php */
2620
        echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'Reg/Login Top Section'); ?>">
2621
        <?php dynamic_sidebar('Reg/Login Top Section');?>
2622
    </div><!-- clearfix ends here-->
2623
<?php
2624
}
2625
2626
2627
// action for adding the details page top widget area
2628
add_action('geodir_signup_forms', 'geodir_action_signup_forms', 10);
2629
/**
2630
 * Output the signup and register forms with included JS to make them work properly.
2631
 *
2632
 * @global bool $user_login True if user is logged in. False if not.
2633
 * @since 1.0.0
2634
 * @package GeoDirectory
2635
 */
2636
function geodir_action_signup_forms()
2637
{
2638
2639
    global $user_login;
2640
    
2641
    $is_enable_signup = get_option( 'users_can_register' );
2642
    
2643
    ?>
2644
    <script type="text/javascript">
2645
        <?php if ( $user_login ) { ?>
2646
        setTimeout(function () {
2647
            try {
2648
                d = document.getElementById('user_pass');
2649
                d.value = '';
2650
                d.focus();
2651
            } catch (e) {
2652
            }
2653
        }, 200);
2654
        <?php } else { ?>
2655
        try {
2656
            document.getElementById('user_login').focus();
2657
        } catch (e) {
2658
        }
2659
        <?php } ?>
2660
    </script>
2661
    <script type="text/javascript">
2662
        <?php if ( $user_login ) { ?>
2663
        setTimeout(function () {
2664
            try {
2665
                d = document.getElementById('user_pass');
2666
                d.value = '';
2667
                d.focus();
2668
            } catch (e) {
2669
            }
2670
        }, 200);
2671
        <?php } else { ?>
2672
        try {
2673
            document.getElementById('user_login').focus();
2674
        } catch (e) {
2675
        }
2676
        <?php } ?>
2677
    </script><?php
2678
2679
    global $errors;
2680
    if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'claim')
2681
        $errors->add('claim_login', LOGIN_CLAIM);
2682
2683
    if (!empty($errors)) {
2684
        foreach ($errors as $errorsObj) {
2685
            foreach ($errorsObj as $key => $val) {
2686
                for ($i = 0; $i < count($val); $i++) {
2687
                    echo "<div class=error_msg_fix>" . $val[$i] . '</div>';
2688
                    $registration_error_msg = 1;
2689
                }
2690
            }
2691
        }
2692
    }
2693
2694
    if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_in') {
2695
        ?>
2696
2697
        <div class="login_form">
2698
            <?php
2699
            /**
2700
             * Contains login form template.
2701
             *
2702
             * @since 1.0.0
2703
             */
2704
            include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?>
2705
        </div>
2706
2707
    <?php } elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_up' && $is_enable_signup ) { ?>
2708
2709
        <div class="registration_form">
2710
            <?php
2711
            /**
2712
             * Contains registration form template.
2713
             *
2714
             * @since 1.0.0
2715
             */
2716
            include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?>
2717
        </div>
2718
2719
    <?php } else { ?>
2720
2721
        <div class="login_form_l">
2722
            <?php
2723
            /**
2724
             * Contains login form template.
2725
             *
2726
             * @since 1.0.0
2727
             */
2728
            include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?>
2729
        </div>
2730
        
2731
        <?php if ( $is_enable_signup ) { ?>
2732
            <div class="registration_form_r">
2733
                <?php
2734
                /**
2735
                 * Contains registration form template.
2736
                 *
2737
                 * @since 1.0.0
2738
                 */
2739
                include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?>
2740
            </div>
2741
        <?php } ?>
2742
2743
    <?php }?>
2744
    <script type="text/javascript">
2745
        try {
2746
            document.getElementById('user_login').focus();
2747
        } catch (e) {
2748
        }
2749
    </script>
2750
2751
2752
    <?php if ((isset($errors->errors['invalidcombo']) && $errors->errors['invalidcombo'] != '') || (isset($errors->errors['empty_username']) && $errors->errors['empty_username'] != '')) { ?>
2753
    <script type="text/javascript">document.getElementById('lostpassword_form').style.display = '';</script>
2754
<?php }
2755
}
2756
2757
###############################################
2758
########### AUTHOR PAGE ACTIONS ###############
2759
###############################################
2760
2761
add_action('geodir_author_page_title', 'geodir_action_author_page_title', 10);
2762
/**
2763
 * Output the author page title including HTML wrappers.
2764
 *
2765
 * @global string $term Current term slug.
2766
 * @since 1.0.0
2767
 * @package GeoDirectory
2768
 */
2769
function geodir_action_author_page_title()
2770
{
2771
    global $term;
2772
2773
    $gd_post_type = geodir_get_current_posttype();
2774
    $post_type_info = get_post_type_object($gd_post_type);
2775
2776
    $add_string_in_title = __('All', 'geodirectory') . ' ';
2777
    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
2778
        $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
2779
    }
2780
2781
    $list_title = $add_string_in_title . $post_type_info->labels->name;
2782
    $single_name = $post_type_info->labels->singular_name;
2783
2784
    $taxonomy = geodir_get_taxonomies($gd_post_type);
2785
2786
    if (!empty($term)) {
2787
        $current_term = get_term_by('slug', $term, $taxonomy[0]);
2788
        if (!empty($current_term))
2789
            $list_title .= __(' in', 'geodirectory') . " '" . geodir_ucwords($current_term->name) . "'";
2790
    }
2791
2792
2793
    if (is_search()) {
2794
        $list_title = __('Search', 'geodirectory') . ' ' . __($post_type_info->labels->name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
2795
2796
    }
2797
    /** This action is documented in geodirectory_template_actions.php */
2798
    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
2799
    /** This action is documented in geodirectory_template_actions.php */
2800
    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
2801
2802
    $title = $list_title;
2803
    if(geodir_is_page('author')){
2804
        $gd_page = 'author';
2805
        if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
2806
            $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
2807
        }else{
2808
            $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
2809
        }
2810
2811
    }
2812
2813
2814
    /**
2815
     * Filter page title to replace variables.
2816
     *
2817
     * @since 1.5.4
2818
     * @param string $title The page title including variables.
2819
     * @param string $gd_page The GeoDirectory page type if any.
2820
     */
2821
    $title =  apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
2822
2823
    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' .
2824
        /**
2825
         * Filter the author page title text.
2826
         *
2827
         * @since 1.0.0
2828
         * @param string $list_title The title for the page.
2829
         */
2830
        apply_filters('geodir_author_page_title_text', $title) . '</h1></header>';
2831
}
2832
2833
2834
// action for adding the details page top widget area
2835
add_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10);
2836
add_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20);
2837
2838
/**
2839
 * Output the author page top sections widget area if enabled.
2840
 *
2841
 * Can be enabled/disabled from GD>Design>Author page.
2842
 *
2843
 * @since 1.0.0
2844
 * @package GeoDirectory
2845
 */
2846
function geodir_action_geodir_sidebar_author_top()
2847
{
2848
    if (get_option('geodir_show_author_top_section')) { ?>
2849
        <div
2850
            class="<?php
2851
            /** This action is documented in geodirectory_template_actions.php */
2852
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_top'); ?>">
2853
            <?php dynamic_sidebar('geodir_author_top'); ?>
2854
        </div><!-- clearfix ends here-->
2855
    <?php }
2856
}
2857
2858
/**
2859
 * Output the author page left sidebar if enabled.
2860
 *
2861
 * Can be enabled/disabled from GD>Design>Author page.
2862
 *
2863
 * @since 1.0.0
2864
 * @package GeoDirectory
2865
 */
2866
function geodir_author_left_section()
2867
{
2868
    if (get_option('geodir_show_author_left_section')) { ?>
2869
        <div class="geodir-content-left geodir-sidebar-wrap">
2870
            <?php dynamic_sidebar('geodir_author_left_sidebar'); ?>
2871
        </div><!-- end geodir-content-left -->
2872
    <?php }
2873
}
2874
2875
add_action('geodir_author_sidebar_left_inside', 'geodir_author_left_section', 10);
2876
2877
add_action('geodir_author_sidebar_left', 'geodir_action_author_sidebar_left', 10);
2878
2879
/**
2880
 * Build the content via hooks for the author page left sidebar.
2881
 *
2882
 * Can be enabled/disabled from GD>Design>Author page.
2883
 *
2884
 * @since 1.0.0
2885
 * @package GeoDirectory
2886
 */
2887
function geodir_action_author_sidebar_left()
2888
{
2889
    if (get_option('geodir_show_author_left_section')) {
2890
// this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
2891
        /** This action is documented in geodirectory_template_actions.php */
2892
        do_action('geodir_sidebar_left_open', 'author-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
2893
        /**
2894
         * This is used to add the content to the author page left sidebar (if active).
2895
         *
2896
         * @since 1.0.0
2897
         */
2898
        do_action('geodir_author_sidebar_left_inside');
2899
        /** This action is documented in geodirectory_template_actions.php */
2900
        do_action('geodir_sidebar_left_close', 'author-page');
2901
    }
2902
}
2903
2904
/**
2905
 * Output the author page right sidebar if enabled.
2906
 *
2907
 * Can be enabled/disabled from GD>Design>Author page.
2908
 *
2909
 * @since 1.0.0
2910
 * @package GeoDirectory
2911
 */
2912
function geodir_author_right_section()
2913
{
2914
    if (get_option('geodir_show_author_right_section')) { ?>
2915
        <div class="geodir-content-right geodir-sidebar-wrap">
2916
            <?php dynamic_sidebar('geodir_author_right_sidebar'); ?>
2917
        </div><!-- end geodir-content-right -->
2918
    <?php }
2919
}
2920
2921
add_action('geodir_author_sidebar_right_inside', 'geodir_author_right_section', 10);
2922
2923
add_action('geodir_author_sidebar_right', 'geodir_action_author_sidebar_right', 10);
2924
/**
2925
 * Build the content via hooks for the author page right sidebar.
2926
 *
2927
 * Can be enabled/disabled from GD>Design>Author page.
2928
 *
2929
 * @since 1.0.0
2930
 * @package GeoDirectory
2931
 */
2932
function geodir_action_author_sidebar_right()
2933
{
2934
    if (get_option('geodir_show_author_right_section')) {
2935
        /** This action is documented in geodirectory_template_actions.php */
2936
        do_action('geodir_sidebar_right_open', 'author-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
2937
        /**
2938
         * This is used to add the content to the author page right sidebar (if active).
2939
         *
2940
         * @since 1.0.0
2941
         */
2942
        do_action('geodir_author_sidebar_right_inside');
2943
        /** This action is documented in geodirectory_template_actions.php */
2944
        do_action('geodir_sidebar_right_close', 'author-page');
2945
    }
2946
}
2947
2948
/**
2949
 * Calls and outputs the template for the author page content section.
2950
 *
2951
 * @since 1.0.0
2952
 * @package GeoDirectory
2953
 * @global string $gridview_columns The girdview style of the listings.
2954
 */
2955
function geodir_action_author_content_inside()
2956
{
2957
    global $gridview_columns;
2958
    $listing_view = get_option('geodir_author_view');
2959
    if (strstr($listing_view, 'gridview')) {
2960
        $gridview_columns = $listing_view;
2961
        $listing_view_exp = explode('_', $listing_view);
2962
        $listing_view = $listing_view_exp[0];
2963
    }
2964
    geodir_get_template_part('listing', 'listview');
2965
}
2966
2967
add_action('geodir_author_content_inside', 'geodir_action_author_content_inside', 10);
2968
add_action('geodir_author_content_inside', 'geodir_pagination', 20);
2969
2970
add_action('geodir_author_content', 'geodir_action_author_content', 10);
2971
/**
2972
 * Build the content via hooks for the author page content.
2973
 *
2974
 * @since 1.0.0
2975
 * @package GeoDirectory
2976
 */
2977
function geodir_action_author_content()
2978
{
2979
    /** This action is documented in geodirectory_template_actions.php */
2980
    do_action('geodir_main_content_open', 'author-page', 'geodir-main-content', 'author-page');
2981
    echo '<div class="clearfix">';
2982
    /** This action is documented in geodirectory_template_actions.php */
2983
    do_action('geodir_before_listing');
2984
    echo '</div>';
2985
    /**
2986
     * This is used to add the content to the author page main content.
2987
     *
2988
     * @since 1.0.0
2989
     */
2990
    do_action('geodir_author_content_inside');
2991
    /** This action is documented in geodirectory_template_actions.php */
2992
    do_action('geodir_after_listing');
2993
    /** This action is documented in geodirectory_template_actions.php */
2994
    do_action('geodir_main_content_close', 'author-page');
2995
}
2996
2997
add_action('geodir_sidebar_author_bottom_section', 'geodir_action_sidebar_author_bottom_section', 10);
2998
/**
2999
 * Output the author page bottom sections widget area if enabled.
3000
 *
3001
 * Can be enabled/disabled from GD>Design>Author page.
3002
 *
3003
 * @since 1.0.0
3004
 * @package GeoDirectory
3005
 */
3006
function geodir_action_sidebar_author_bottom_section()
3007
{
3008
    if (get_option('geodir_show_author_bottom_section')) { ?>
3009
        <div
3010
            class="<?php
3011
            /** This action is documented in geodirectory_template_actions.php */
3012
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_bottom'); ?>">
3013
            <?php dynamic_sidebar('geodir_author_bottom'); ?>
3014
        </div><!-- clearfix ends here-->
3015
    <?php }
3016
}
3017
3018
###############################################
3019
########### SEARCH PAGE ACTIONS ###############
3020
###############################################
3021
3022
add_action('geodir_search_page_title', 'geodir_action_search_page_title', 10);
3023
/**
3024
 * Output the search page title including HTML wrappers.
3025
 *
3026
 * @since 1.0.0
3027
 * @package GeoDirectory
3028
 */
3029
function geodir_action_search_page_title()
3030
{
3031
    $gd_post_type = geodir_get_current_posttype();
3032
    $post_type_info = get_post_type_object($gd_post_type);
3033
3034
    $pt_name = '';
3035
    if(isset($post_type_info->labels->name)){$pt_name=$post_type_info->labels->name;}
3036
3037
    if (is_search()) {
3038
        $list_title = __('Search', 'geodirectory') . ' ' . __($pt_name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
3039
3040
    }
3041
    /** This action is documented in geodirectory_template_actions.php */
3042
    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
3043
    /** This action is documented in geodirectory_template_actions.php */
3044
    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
3045
    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' .
3046
        /** This action is documented in geodirectory_template_actions.php */
3047
        apply_filters('geodir_listing_page_title', wptexturize($list_title)) . '</h1></header>';
3048
}
3049
3050
// action for adding the listings page top widget area
3051
add_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10);
3052
add_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20);
3053
/**
3054
 * Output the search page top section widget area if enabled.
3055
 *
3056
 * Can be enabled/disabled from GD>Design>Search page.
3057
 *
3058
 * @since 1.0.0
3059
 * @package GeoDirectory
3060
 */
3061
function geodir_action_geodir_sidebar_search_top()
3062
{
3063
    if (get_option('geodir_show_search_top_section')) { ?>
3064
        <div
3065
            class="<?php
3066
            /** This action is documented in geodirectory_template_actions.php */
3067
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_top'); ?>">
3068
            <?php dynamic_sidebar('geodir_search_top'); ?>
3069
        </div><!-- clearfix ends here-->
3070
    <?php }
3071
}
3072
3073
/**
3074
 * Output the search page left sidebar widget area if enabled.
3075
 *
3076
 * Can be enabled/disabled from GD>Design>Search page.
3077
 *
3078
 * @since 1.0.0
3079
 * @package GeoDirectory
3080
 */
3081
function geodir_search_left_section()
3082
{
3083
    if (get_option('geodir_show_search_left_section')) { ?>
3084
        <div class="geodir-content-left geodir-sidebar-wrap">
3085
            <?php dynamic_sidebar('geodir_search_left_sidebar'); ?>
3086
        </div><!-- end geodir-content-left -->
3087
    <?php }
3088
}
3089
3090
add_action('geodir_search_sidebar_left_inside', 'geodir_search_left_section', 10);
3091
3092
add_action('geodir_search_sidebar_left', 'geodir_action_search_sidebar_left', 10);
3093
/**
3094
 * Build the content for the search page left sidebar via hooks.
3095
 *
3096
 * Can be enabled/disabled from GD>Design>Search page.
3097
 *
3098
 * @since 1.0.0
3099
 * @package GeoDirectory
3100
 */
3101
function geodir_action_search_sidebar_left()
3102
{
3103
    if (get_option('geodir_show_search_left_section')) {
3104
// this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
3105
        /** This action is documented in geodirectory_template_actions.php */
3106
        do_action('geodir_sidebar_left_open', 'search-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
3107
        /**
3108
         * This is used to add the content to the search page left sidebar (if active).
3109
         *
3110
         * @since 1.0.0
3111
         */
3112
        do_action('geodir_search_sidebar_left_inside');
3113
        /** This action is documented in geodirectory_template_actions.php */
3114
        do_action('geodir_sidebar_left_close', 'search-page');
3115
    }
3116
}
3117
3118
/**
3119
 * Output the search page right sidebar widget area if enabled.
3120
 *
3121
 * Can be enabled/disabled from GD>Design>Search page.
3122
 *
3123
 * @since 1.0.0
3124
 * @package GeoDirectory
3125
 */
3126
function geodir_search_right_section()
3127
{
3128
    if (get_option('geodir_show_search_right_section')) { ?>
3129
        <div class="geodir-content-right geodir-sidebar-wrap">
3130
            <?php dynamic_sidebar('geodir_search_right_sidebar'); ?>
3131
        </div><!-- end geodir-content-right -->
3132
    <?php }
3133
}
3134
3135
add_action('geodir_search_sidebar_right_inside', 'geodir_search_right_section', 10);
3136
3137
add_action('geodir_search_sidebar_right', 'geodir_action_search_sidebar_right', 10);
3138
/**
3139
 * Build the content for the search page right sidebar via hooks.
3140
 *
3141
 * Can be enabled/disabled from GD>Design>Search page.
3142
 *
3143
 * @since 1.0.0
3144
 * @package GeoDirectory
3145
 */
3146
function geodir_action_search_sidebar_right()
3147
{
3148
    if (get_option('geodir_show_search_right_section')) {
3149
        /** This action is documented in geodirectory_template_actions.php */
3150
        do_action('geodir_sidebar_right_open', 'search-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
3151
        /**
3152
         * This is used to add the content to the search page right sidebar (if active).
3153
         *
3154
         * @since 1.0.0
3155
         */
3156
        do_action('geodir_search_sidebar_right_inside');
3157
        /** This action is documented in geodirectory_template_actions.php */
3158
        do_action('geodir_sidebar_right_close', 'search-page');
3159
    }
3160
}
3161
3162
3163
add_action('geodir_sidebar_search_bottom_section', 'geodir_action_sidebar_search_bottom_section', 10);
3164
/**
3165
 * Output the search page bottom section widget area if enabled.
3166
 *
3167
 * Can be enabled/disabled from GD>Design>Search page.
3168
 *
3169
 * @since 1.0.0
3170
 * @package GeoDirectory
3171
 */
3172
function geodir_action_sidebar_search_bottom_section()
3173
{
3174
    if (get_option('geodir_show_search_bottom_section')) { ?>
3175
        <div
3176
            class="<?php
3177
            /** This action is documented in geodirectory_template_actions.php */
3178
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_bottom'); ?>">
3179
            <?php dynamic_sidebar('geodir_search_bottom'); ?>
3180
        </div><!-- clearfix ends here-->
3181
    <?php }
3182
}
3183
3184
/**
3185
 * Calls and outputs the template for the search page content section.
3186
 *
3187
 * @since 1.0.0
3188
 * @package GeoDirectory
3189
 * @global string $gridview_columns The girdview style of the listings.
3190
 */
3191
function geodir_action_search_content_inside()
3192
{
3193
    global $gridview_columns;
3194
    $listing_view = get_option('geodir_search_view');
3195
    if (strstr($listing_view, 'gridview')) {
3196
        $gridview_columns = $listing_view;
3197
        $listing_view_exp = explode('_', $listing_view);
3198
        $listing_view = $listing_view_exp[0];
3199
    }
3200
    geodir_get_template_part('listing', 'listview');
3201
}
3202
3203
add_action('geodir_search_content_inside', 'geodir_action_search_content_inside', 10);
3204
add_action('geodir_search_content_inside', 'geodir_pagination', 20);
3205
3206
add_action('geodir_search_content', 'geodir_action_search_content', 10);
3207
3208
/**
3209
 * Build the content via hooks for the search page content.
3210
 *
3211
 * @since 1.0.0
3212
 * @package GeoDirectory
3213
 */
3214
function geodir_action_search_content()
3215
{
3216
    /** This action is documented in geodirectory_template_actions.php */
3217
    do_action('geodir_main_content_open', 'search-page', 'geodir-main-content', 'search-page');
3218
    echo '<div class="clearfix">';
3219
    /** This action is documented in geodirectory_template_actions.php */
3220
    do_action('geodir_before_listing');
3221
    echo '</div>';
3222
    /**
3223
     * This is used to add the content to the search page main content.
3224
     *
3225
     * @since 1.0.0
3226
     */
3227
    do_action('geodir_search_content_inside');
3228
    /** This action is documented in geodirectory_template_actions.php */
3229
    do_action('geodir_after_listing');
3230
    /** This action is documented in geodirectory_template_actions.php */
3231
    do_action('geodir_main_content_close', 'search-page');
3232
}
3233
3234
###############################################
3235
############# HOME PAGE ACTIONS ###############
3236
###############################################
3237
// action for adding the details page top widget area
3238
add_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
3239
add_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20);
3240
3241
add_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
3242
add_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20);
3243
3244
/**
3245
 * Output the home page top section widget area if enabled.
3246
 *
3247
 * Can be enabled/disabled from GD>Design>Home page.
3248
 *
3249
 * @since 1.0.0
3250
 * @package GeoDirectory
3251
 */
3252
function geodir_action_geodir_sidebar_home_top()
3253
{
3254
    if (get_option('geodir_show_home_top_section')) { ?>
3255
        <div
3256
            class="<?php
3257
            /** This action is documented in geodirectory_template_actions.php */
3258
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_top'); ?>">
3259
            <?php dynamic_sidebar('geodir_home_top'); ?>
3260
        </div><!-- clearfix ends here-->
3261
    <?php }
3262
}
3263
3264
/**
3265
 * Output the home page left sidebar widget area if enabled.
3266
 *
3267
 * Can be enabled/disabled from GD>Design>Home page.
3268
 *
3269
 * @since 1.0.0
3270
 * @package GeoDirectory
3271
 */
3272
function geodir_home_left_section()
3273
{
3274
    if (get_option('geodir_show_home_left_section')) { ?>
3275
        <div class="geodir-content-left geodir-sidebar-wrap">
3276
            <?php dynamic_sidebar('geodir_home_left'); ?>
3277
        </div><!-- end geodir-content-left -->
3278
    <?php }
3279
}
3280
3281
add_action('geodir_home_sidebar_left_inside', 'geodir_home_left_section', 10);
3282
3283
add_action('geodir_location_sidebar_left', 'geodir_action_home_sidebar_left', 10);
3284
add_action('geodir_home_sidebar_left', 'geodir_action_home_sidebar_left', 10);
3285
3286
/**
3287
 * Build the content for the home page left sidebar via hooks.
3288
 *
3289
 * Can be enabled/disabled from GD>Design>Home page.
3290
 *
3291
 * @since 1.0.0
3292
 * @package GeoDirectory
3293
 */
3294
function geodir_action_home_sidebar_left()
3295
{
3296
    if (get_option('geodir_show_home_left_section')) {
3297
// this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
3298
        /** This action is documented in geodirectory_template_actions.php */
3299
        do_action('geodir_sidebar_left_open', 'home-page', 'geodir-sidebar-left', 'geodir-sidebar geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
3300
        /**
3301
         * This is used to add the content to the home page left sidebar (if active).
3302
         *
3303
         * @since 1.0.0
3304
         */
3305
        do_action('geodir_home_sidebar_left_inside');
3306
        /** This action is documented in geodirectory_template_actions.php */
3307
        do_action('geodir_sidebar_left_close', 'home-page');
3308
    }
3309
}
3310
3311
/**
3312
 * Output the home page right sidebar widget area if enabled.
3313
 *
3314
 * Can be enabled/disabled from GD>Design>Home page.
3315
 *
3316
 * @since 1.0.0
3317
 * @package GeoDirectory
3318
 */
3319
function geodir_home_right_section()
3320
{
3321
    if (get_option('geodir_show_home_right_section')) { ?>
3322
        <div class="geodir-content-right geodir-sidebar-wrap">
3323
            <?php dynamic_sidebar('geodir_home_right'); ?>
3324
        </div><!-- end geodir-content-right -->
3325
    <?php }
3326
}
3327
3328
add_action('geodir_home_sidebar_right_inside', 'geodir_home_right_section', 10);
3329
3330
add_action('geodir_location_sidebar_right', 'geodir_action_home_sidebar_right', 10);
3331
add_action('geodir_home_sidebar_right', 'geodir_action_home_sidebar_right', 10);
3332
/**
3333
 * Build the content for the home page right sidebar via hooks.
3334
 *
3335
 * Can be enabled/disabled from GD>Design>Home page.
3336
 *
3337
 * @since 1.0.0
3338
 * @package GeoDirectory
3339
 */
3340
function geodir_action_home_sidebar_right()
3341
{
3342
    if (get_option('geodir_show_home_right_section')) {
3343
        /** This action is documented in geodirectory_template_actions.php */
3344
        do_action('geodir_sidebar_right_open', 'home-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
3345
        /**
3346
         * This is used to add the content to the home page right sidebar (if active).
3347
         *
3348
         * @since 1.0.0
3349
         */
3350
        do_action('geodir_home_sidebar_right_inside');
3351
        /** This action is documented in geodirectory_template_actions.php */
3352
        do_action('geodir_sidebar_right_close', 'home-page');
3353
    }
3354
}
3355
3356
/**
3357
 * Build and output the content of the home page via hooks.
3358
 *
3359
 * @since 1.0.0
3360
 * @package GeoDirectory
3361
 */
3362
function geodir_action_home_content_inside()
3363
{
3364
    dynamic_sidebar('geodir_home_content');
3365
}
3366
3367
add_action('geodir_home_content_inside', 'geodir_action_home_content_inside', 10);
3368
add_action('geodir_home_content_inside', 'geodir_pagination', 20);
3369
3370
add_action('geodir_location_content', 'geodir_action_home_content', 10);
3371
add_action('geodir_home_content', 'geodir_action_home_content', 10);
3372
/**
3373
 *
3374
 * @since 1.0.0
3375
 * @package GeoDirectory
3376
 */
3377
function geodir_action_home_content()
3378
{
3379
    /** This action is documented in geodirectory_template_actions.php */
3380
    do_action('geodir_main_content_open', 'home-page', 'geodir-main-content', 'home-page');
3381
    /**
3382
     * This called before the home page main content.
3383
     *
3384
     * @since 1.0.0
3385
     */
3386
    do_action('geodir_before_home_content');
3387
    /**
3388
     * This is used to add the content to the home page main content.
3389
     *
3390
     * @since 1.0.0
3391
     */
3392
    do_action('geodir_home_content_inside');
3393
    /**
3394
     * This is called after the homepage main content.
3395
     *
3396
     * @since 1.0.0
3397
     */
3398
    do_action('geodir_after_home_content');
3399
    /** This action is documented in geodirectory_template_actions.php */
3400
    do_action('geodir_main_content_close', 'home-page');
3401
}
3402
3403
add_action('geodir_sidebar_location_bottom_section', 'geodir_action_sidebar_home_bottom_section', 10);
3404
add_action('geodir_sidebar_home_bottom_section', 'geodir_action_sidebar_home_bottom_section', 10);
3405
/**
3406
 * Output the home page bottom section widget area if enabled.
3407
 *
3408
 * Can be enabled/disabled from GD>Design>Home page.
3409
 *
3410
 * @since 1.0.0
3411
 * @package GeoDirectory
3412
 */
3413
function geodir_action_sidebar_home_bottom_section()
3414
{
3415
    if (get_option('geodir_show_home_bottom_section')) { ?>
3416
        <div
3417
            class="<?php
3418
            /** This action is documented in geodirectory_template_actions.php */
3419
            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_bottom'); ?>">
3420
            <?php dynamic_sidebar('geodir_home_bottom'); ?>
3421
        </div><!-- clearfix ends here-->
3422
    <?php }
3423
}
3424
3425
add_filter('geodir_filter_widget_listings_fields', 'geodir_function_widget_listings_fields');
3426
add_filter('geodir_filter_widget_listings_join', 'geodir_function_widget_listings_join');
3427
add_filter('geodir_filter_widget_listings_where', 'geodir_function_widget_listings_where');
3428
add_filter('geodir_filter_widget_listings_orderby', 'geodir_function_widget_listings_orderby');
3429
add_filter('geodir_filter_widget_listings_limit', 'geodir_function_widget_listings_limit');
3430
3431
/* add class for listing row */
3432
add_filter('geodir_post_view_extra_class', 'geodir_core_post_view_extra_class');
3433
3434
// filter for listing page title
3435
add_filter('geodir_listing_page_title', 'geodir_filter_listing_page_title', 1, 1);
3436
3437
/**
3438
 * Output the home page title including HTML wrappers.
3439
 *
3440
 * @since 1.0.0
3441
 * @package GeoDirectory
3442
 * @param string $list_title The home page title.
3443
 * @return string
3444
 */
3445
function geodir_filter_listing_page_title($list_title)
3446
{
3447
    if (is_search() && trim(get_search_query()) == '') {
3448
        $gd_post_type = geodir_get_current_posttype();
3449
        $post_type_info = get_post_type_object($gd_post_type);
3450
3451
        $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' :', 'geodirectory');
3452
    }
3453
    return $list_title;
3454
}
3455
3456
add_action('geodir_message_not_found_on_listing', 'geodir_display_message_not_found_on_listing');
3457
add_filter('geodir_breadcrumb', 'geodir_strip_breadcrumb_li_wrappers', 999, 2);
3458
3459
/**
3460
 * Adds page content to the page.
3461
 *
3462
 * @since 1.6.3
3463
 * @since 1.6.26 Listing description limit affects page description on add listing page - FIXED
3464
 *
3465
 * @param string $position Position to add the post content. 'before' or 'after'. Default 'before'.
3466
 * @param string $gd_page The geodirectory page type. Default null.
3467
 */
3468
function geodir_add_page_content( $position = 'before', $gd_page = '' ) {
3469
    global $post;
3470
3471
    $gd_page_id = NULL;
3472
    if ($gd_page == 'home-page' && geodir_is_page('home')) {
3473
        $gd_page_id = geodir_home_page_id();
3474
    } else if ($gd_page == 'details-page' && geodir_is_page('preview')) {
3475
        $gd_page_id = geodir_preview_page_id();
3476
    } else if ($gd_page == 'add-listing-page' && geodir_is_page('add-listing')) {
3477
        $gd_page_id = geodir_add_listing_page_id();
3478
    } else if ($gd_page == 'success-page' && geodir_is_page('listing-success')) {
3479
        $gd_page_id = geodir_success_page_id();
3480
    } else if ($gd_page == 'location-page' && geodir_is_page('location')) {
3481
        $gd_page_id = geodir_location_page_id();
3482
    } else if ($gd_page == 'info-page' && geodir_is_page('info')) {
3483
        $gd_page_id = geodir_info_page_id();
3484
    } else if ($gd_page == 'signup-page' && geodir_is_page('login')) {
3485
        $gd_page_id = geodir_login_page_id();
3486
    } else if ($gd_page == 'checkout-page' && geodir_is_page('checkout')) {
3487
        $gd_page_id = geodir_payment_checkout_page_id();
3488
    } else if ($gd_page == 'invoices-page' && geodir_is_page('invoices')) {
3489
        $gd_page_id = geodir_payment_invoices_page_id();
3490
    }
3491
3492
    if (!$gd_page_id > 0) {
3493
        return;
3494
    }
3495
    
3496
    $display = 'before';
3497
    /**
3498
     * Filter the position to display the page content.
3499
     *
3500
     * @since 1.6.3
3501
     *
3502
     * @param string $display Position to add the post content.
3503
     * @param string $gd_page The geodirectory page type.
3504
     */
3505
    $display = apply_filters('geodir_add_page_content_position', $display, $gd_page);
3506
3507
    if ($position !== $display) {
3508
        return;
3509
    }
3510
3511
    $gd_post = $post;
3512
    $post = get_post($gd_page_id);
3513
3514
    setup_postdata($post);
3515
3516
    if (get_the_content()) {
3517
        ?>
3518
        <section class="entry-content clearfix" itemprop="articleBody"><?php the_content(); ?></section>
3519
        <?php
3520
    }
3521
3522
    $post = $gd_post;
3523
    if (!empty($gd_post) && is_object($gd_post)) {
3524
        setup_postdata($gd_post);
3525
    }
3526
3527
}
3528
add_action('geodir_add_page_content', 'geodir_add_page_content', 10, 2);
3529
3530
/**
3531
 * Filters the JOIN clause in the SQL for an adjacent post query.
3532
 *
3533
 * @since 1.6.16
3534
 * @package GeoDirectory
3535
 *
3536
 * @global string $plugin_prefix Geodirectory plugin table prefix.
3537
 *
3538
 * @param string  $join           The JOIN clause in the SQL.
3539
 * @param bool    $in_same_term   Whether post should be in a same taxonomy term.
3540
 * @param array   $excluded_terms Array of excluded term IDs.
3541
 * @param string  $taxonomy       Taxonomy. Used to identify the term used when `$in_same_term` is true.
3542
 * @param WP_Post $post           WP_Post object.
3543
 * @return string Filtered SQL JOIN clause.
3544
 */
3545
function geodir_previous_next_post_join( $join, $in_same_term, $excluded_terms, $taxonomy, $post ) {
3546
    global $plugin_prefix;
3547
3548
    if ( !empty($post->post_type) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
3549
        $join .= " INNER JOIN " . $plugin_prefix . $post->post_type . "_detail AS gd ON gd.post_id = p.ID";
3550
    }
3551
    
3552
    return $join;
3553
}
3554
add_filter( 'get_previous_post_join', 'geodir_previous_next_post_join', 10, 5 );
3555
add_filter( 'get_next_post_join', 'geodir_previous_next_post_join', 10, 5 );
3556
3557
/**
3558
 * Filters the WHERE clause in the SQL for an adjacent post query.
3559
 *
3560
 * @since 1.6.16
3561
 * @package GeoDirectory
3562
 *
3563
 * @global object $wpdb WordPress Database object.
3564
 * @global string $plugin_prefix Geodirectory plugin table prefix.
3565
 *
3566
 * @param string $where          The `WHERE` clause in the SQL.
3567
 * @param bool   $in_same_term   Whether post should be in a same taxonomy term.
3568
 * @param array  $excluded_terms Array of excluded term IDs.
3569
 * @param string $taxonomy       Taxonomy. Used to identify the term used when `$in_same_term` is true.
3570
 * @param WP_Post $post          WP_Post object.
3571
 * @return string Filtered SQL WHERE clause.
3572
 */
3573
function geodir_previous_next_post_where( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) {
3574
    global $wpdb, $plugin_prefix;
3575
3576
    if ( !empty($post->post_type) && ( !empty( $post->country_slug ) || !empty( $post->region_slug ) || !empty( $post->city_slug ) ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
3577
        $post_locations = '';
3578
        $post_locations_var = array();
3579
        
3580
        if ( !empty( $post->country_slug ) ) {
3581
            $post_locations .= " AND post_locations LIKE %s";
3582
            $post_locations_var[] = "%,[" . $post->country_slug . "]";
3583
        }
3584
3585
        if ( !empty( $post->region_slug ) ) {
3586
            $post_locations .= " AND post_locations LIKE %s";
3587
            $post_locations_var[] = "%,[" . $post->region_slug . "],%";
3588
        }
3589
3590
        if ( !empty( $post->city_slug ) ) {
3591
            $post_locations .= " AND post_locations LIKE %s";
3592
            $post_locations_var[] = "[" . $post->city_slug . "],%";
3593
        }
3594
        
3595
        $where .= $wpdb->prepare( $post_locations, $post_locations_var );
3596
    }
3597
    
3598
    return $where;
3599
}
3600
add_filter( 'get_previous_post_where', 'geodir_previous_next_post_where', 10, 5 );
3601
add_filter( 'get_next_post_where', 'geodir_previous_next_post_where', 10, 5 );
3602
3603
/**
3604
 * Filter whether a post is able to be edited in the block editor.
3605
 * 
3606
 * @since 1.6.38
3607
 *
3608
 * @param $use_block_editor  Whether the post type can be edited or not.
3609
 * @param $post_type The post type being checked.
3610
 * @return bool True if can be edited else False.
3611
 */
3612
function geodir_block_editor( $use_block_editor, $post_type ) {
3613
	if ( $use_block_editor ) {
3614
		$gd_post_types = geodir_get_posttypes();
3615
3616
		if ( ! empty( $gd_post_types ) && in_array( $post_type, $gd_post_types ) ) {
3617
			$use_block_editor = false;
3618
		}
3619
	}
3620
3621
	return $use_block_editor;
3622
}
3623
// Prevent Gutenberg block editing GD CPTs, we only allow editing of the template pages.
3624
if ( ! empty( $GLOBALS['wp_version'] ) && version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ) ) {
3625
	// WP > 5 beta
3626
	add_filter( 'use_block_editor_for_post_type', 'geodir_block_editor', 101, 2 );
3627
} else {
3628
	// WP < 5 beta
3629
	add_filter( 'gutenberg_can_edit_post_type', 'geodir_block_editor', 101, 2 );
3630
}