shortcodes.php
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
add_shortcode('advance-search', 'advance_search');
function advance_search($atts){
try{
$search_id = $atts['search_id'];
ob_start(); ?>
<a href="javascript:void(0);" class="advance-search-button" data-bs-toggle="modal" data-bs-target="#advance-search-modal"><?php _e('Advance Search','msf'); ?></a>
<div class="modal fade left flag-modal" id="advance-search-modal" tabindex="-1" data-bs-backdrop="static" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?php echo do_shortcode('[searchandfilter slug="'.$search_id.'"]'); ?>
<div class="searching-loading"> <?php _e('Searching...','msf'); ?>
<div class="spinner-border text-danger" role="status">
<span class="visually-hidden" >...</span>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
wp_reset_query();
$output = ob_get_clean();
return $output;
}catch(Throwable $e) {
error_log("advance_search()". $e->getMessage()) ;
}
}
function add_linebreak_shortcode() {
return '<br />';
}
add_shortcode('br', 'add_linebreak_shortcode' );
add_shortcode('list_media', 'list_media');
function list_media($atts){
ob_start();
$args = array( 'posts_per_page' => -1, 'post_type' => 'attachment');
$pages = get_posts( $args );
foreach ( $pages as $page ){
$exclude_from_search = get_post_meta($page->ID, 'exclude_from_search', true);
if($exclude_from_search == '0'){ ?>
<a href='<?php echo wp_get_attachment_url($page->ID);?>' >
<?= get_the_title($page->ID) ?>
</a><br><br>
<?php }
}
wp_reset_query();
$output = ob_get_clean();
return $output;
}