This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchform.php
56 lines (51 loc) · 2.83 KB
/
searchform.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
<?php
/**
* Mayflower Lite Search Form
*
* Complete search form used in the Mayflower lite header
*
* @package Mayflower
*/
global $mayflower_options;
// Load options if they are not already present.
if ( ! ( is_array( $mayflower_options ) ) ) {
$mayflower_options = mayflower_get_options();
}
// Set variables for ease of use/configuration.
$limit_searchform_scope = $mayflower_options['limit_searchform_scope'];
$search_url_default = 'https://www.bellevuecollege.edu/search/';
$search_url = ( $limit_searchform_scope && ( '' !== $mayflower_options['custom_search_url'] ) ) ?
$mayflower_options['custom_search_url'] : $search_url_default;
$search_field_id = $limit_searchform_scope ? 'college-search-field-custom' : 'college-search-field';
$filter_value = ( '' !== $mayflower_options['custom_search_scope'] ) ? $mayflower_options['custom_search_scope'] : mayflower_trimmed_url();
$search_api_key = '' !== $mayflower_options['custom_search_api_key'] ? $mayflower_options['custom_search_api_key'] :
'YUFwdxQ6-Kaa9Zac4rpb'; // <-- Default API Key.
$search_query_peram = 'query';
$filter_peram = 'scope'; // Hardcoded default.
?>
<form action="<?php echo esc_url( $search_url ); ?>" method="get" class="form-search" id="bc-search">
<label class="sr-only" for="<?php echo esc_attr( $search_field_id ); ?>">Search</label>
<div class="input-group" role="search">
<input type="text" name="<?php echo esc_attr( $search_query_peram ); ?>" class="form-control" maxlength="255" autocomplete="off" id="<?php echo esc_attr( $search_field_id ); ?>" />
<?php if ( $limit_searchform_scope ) : ?>
<?php
if ( '' === $mayflower_options['custom_search_url'] ) :
// If there is NOT a custom search URL, output filter peram and filter js.
?>
<input type="hidden" class="college-search-filter" name="<?php echo esc_attr( $filter_peram ); ?>" value="<?php echo esc_attr( $filter_value ); ?>">
<?php endif; // no custom search url set. ?>
<?php endif; // limit searchform scope. ?>
<div class="input-group-append">
<button type="submit" class="btn btn-light" id="college-search-submit">Search</button>
<?php if ( $limit_searchform_scope ) : ?>
<button type="button" class="btn btn-light dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">More Search Options</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="<?php echo esc_url( $search_url ); ?>" id="college-search-site-link">Search <?php bloginfo( 'name' ); ?></a>
<a class="dropdown-item" href="<?php echo esc_url( $search_url_default ); ?>" id="college-search-all-link">Search Bellevue College <i class="fas fa-external-link-alt" aria-hidden="true"></i></a>
</div>
<?php endif; // limit searchform scope. ?>
</div>
</div>
</form>