forked from argoproject/Argo
-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
search.php
146 lines (128 loc) · 3.59 KB
/
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
* The template for displaying Search Results pages.
*/
get_header();
?>
<div id="content" class="stories archive search-results span8" role="main">
<?php if (of_get_option('use_gcs') && of_get_option('gcs_id')) { ?>
<h1>
<?php
$search_query = esc_html( get_search_query() );
if ( empty( $search_query ) ) {
echo wp_kses_post( __('Search', 'largo') );
} else {
echo wp_kses_post( sprintf(
// translators: %s is the search query.
__('Search results for <span class="search-term">%s</span>', 'largo'),
$search_query
) );
}
?>
</h1>
<?php
/**
* Fires before the Google Custom Search container
*
* @since Largo 0.5.5
*/
do_action('largo_search_gcs_before_container');
?>
<div class="gcs_container">
<script>
(function() {
var cx = '<?php echo of_get_option('gcs_id'); ?>';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchbox
gname="largoGCSE"
overlayResults="false"
queryParameterName="s"></gcse:searchbox>
<?php if (is_search()) { ?>
<gcse:searchresults
gname="largoGCSE"
overlayResults="false"
queryParameterName="s"></gcse:searchresults>
<?php } ?>
<?php if (is_search() && !isset($_GET['s'])) { ?>
<script type="text/javascript">
(function() {
var setQuery = function() {
var query = '<?php echo get_search_query(); ?>';
google.setOnLoadCallback(function() {
var el = google.search.cse.element.getElement('largoGCSE');
el.execute(query);
});
};
window.__gcse = {
callback: setQuery
};
}());
</script>
<?php } ?>
</div>
<?php
/**
* Fires after the Google Custom Search container
*
* @since Largo 0.5.5
*/
do_action('largo_search_gcs_after_container');
?>
<?php } else { ?>
<?php if ( have_posts() ) {
/**
* Fires before the non-GCS search form
*
* @since Largo 0.5.5
*/
do_action('largo_search_normal_before_form');
get_search_form();
/**
* Fires after the non-GCS search form, before the search results counter
*
* @since Largo 0.5.5
*/
do_action('largo_search_normal_before_results');
?>
<h3 class="recent-posts clearfix">
<?php
printf(
// translators: %s is the search query.
__('Your search for <span class="search-term">%s</span> returned ', 'largo'),
get_search_query()
);
printf(
// translators: %s is the output of number_format_i18n( the number of found posts ) .
_n( '%s result', '%s results', $wp_query->found_posts, 'largo' ),
number_format_i18n( $wp_query->found_posts )
);
printf( '<a class="rss-link" href="%1$s"><i class="icon-rss"></i></a>', get_search_feed_link() );
?>
</h3>
<?php
while ( have_posts() ) : the_post();
$partial = largo_get_partial_by_post_type('search', get_post_type( $post ), 'search');
get_template_part( 'partials/content', $partial );
endwhile;
largo_content_nav( 'nav-below' );
} else {
get_template_part( 'partials/content', 'not-found' );
}
/**
* Fires after the non-GCS search results or lack-of-results
*
* @since Largo 0.5.5
*/
do_action('largo_search_normal_after_results');
} ?>
</div><!-- #content -->
<?php get_sidebar(); ?>
<?php get_footer();