-
Notifications
You must be signed in to change notification settings - Fork 2
/
help-search.php
97 lines (83 loc) · 2.93 KB
/
help-search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
// phpcs:disable WordPress.Security.NonceVerification.Recommended
$help_search = isset( $_GET['help-search'] ) ? urldecode( $_GET['help-search'] ) : '';
$pag_page = isset( $_GET['hs-page'] ) ? intval( $_GET['hs-page'] ) : 1;
// phpcs:enable WordPress.Security.NonceVerification.Recommended
?>
<?php get_header(); ?>
<div id="content" class="hfeed row">
<div class="col-sm-18 col-xs-24 col-help">
<div id="openlab-main-content" class="content-wrapper">
<div class="entry-title">
<h1 class="help-entry-title"><?php esc_html_e( 'Search Help', 'commons-in-a-box' ); ?></h1>
</div>
<div id="help-title">
<h2 class="page-title clearfix submenu">
<div class="subenu-text pull-left bold"><?php esc_html_e( 'Results:', 'commons-in-a-box' ); ?></div>
</h2>
</div>
<div class="entry-content archive">
<?php
$hq = new WP_Query(
array(
'post_type' => 'help',
's' => $help_search,
'posts_per_page' => 10,
'paged' => $pag_page,
)
);
?>
<?php if ( $hq->have_posts() ) : ?>
<p>The following match the search term <strong>"<?php echo esc_html( $help_search ); ?>"</strong>:</p>
<div class="child-cat-container help-cat-block">
<ul>
<?php while ( $hq->have_posts() ) : ?>
<?php $hq->the_post(); ?>
<li>
<h3 class="help-title no-margin no-margin-bottom"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<div class="help-search-excerpt">
<?php the_excerpt(); ?>
</div>
</li>
<?php endwhile; ?>
</ul>
</div><!-- .child-cat-container help-cat-block -->
<div class="pagination-links help-search-pagination">
<?php
$add_args = array();
if ( ! empty( $help_search ) ) {
$add_args['help-search'] = rawurlencode( $help_search );
}
$pag_links = paginate_links(
array(
'base' => add_query_arg( 'hs-page', '%#%', openlab_get_help_search_url() ),
'format' => '',
'current' => $pag_page,
'total' => $hq->max_num_pages,
'type' => 'array',
'prev_text' => _x( '<i class="fa fa-angle-left"></i>', 'Group pagination previous text', 'buddypress' ),
'next_text' => _x( '<i class="fa fa-angle-right"></i>', 'Group pagination next text', 'buddypress' ),
'mid_size' => 3,
)
);
echo '<ul class="pagination page-numbers">';
foreach ( $pag_links as $pag_link ) {
printf(
'<li>%s</li>',
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$pag_link
);
}
echo '</ul>';
?>
</div>
<?php else : ?>
<?php esc_html_e( 'Sorry, no help documents were found matching your query.', 'commons-in-a-box' ); ?>
<?php endif; ?>
</div><!-- .entry-content -->
</div><!-- .content-wrapper -->
</div>
<?php get_template_part( 'parts/sidebar/help' ); ?>
</div>
<?php
get_footer();