-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
84 lines (67 loc) · 2.64 KB
/
functions.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
<?php
function global_site_search_roundup( $value, $dp ) {
return ceil( $value * pow( 10, $dp ) ) / pow( 10, $dp );
}
function global_site_search_get_allowed_blogs() {
if ( !defined( 'GLOBAL_SITE_SEARCH_BLOG' ) ) {
define( 'GLOBAL_SITE_SEARCH_BLOG', 1 );
}
$site_search_blog = GLOBAL_SITE_SEARCH_BLOG;
if ( is_string( $site_search_blog ) ) {
$site_search_blog = array_filter( array_map( 'absint', explode( ',', $site_search_blog ) ) );
}
return apply_filters( 'global_site_search_allowed_blogs', (array)$site_search_blog );
}
function global_site_search_locate_template( $template_name, $template_path = 'global-site-search' ) {
// Look within passed path within the theme - this is priority
$template = locate_template( array(
trailingslashit( $template_path ) . $template_name,
$template_name
) );
// Get default template
if ( !$template ) {
$template = implode( DIRECTORY_SEPARATOR, array( dirname( __FILE__ ), 'templates', $template_name ) );
}
// Return what we found
return apply_filters( 'global_site_search_locate_template', $template, $template_name, $template_path );
}
function global_site_search_form() {
include global_site_search_locate_template( 'global-site-search-form.php' );
}
function global_site_search_get_search_base() {
global $global_site_search;
return $global_site_search->global_site_search_base;
}
function global_site_search_get_phrase() {
global $wp_query;
$phrase = isset( $wp_query->query_vars['search'] ) ? urldecode( $wp_query->query_vars['search'] ) : '';
if ( empty( $phrase ) && isset( $_REQUEST['phrase'] ) ) {
$phrase = trim( stripslashes($_REQUEST['phrase'] ));
}
return $phrase;
}
function global_site_search_get_pagination( $mainlink = '' ) {
global $network_query, $current_site;
if ( absint( $network_query->max_num_pages ) <= 1 ) {
return '';
}
if ( empty( $mainlink ) ) {
$mainlink = $current_site->path . global_site_search_get_search_base() . '/' . urlencode( global_site_search_get_phrase() );
}
return paginate_links( array(
'base' => trailingslashit( $mainlink ) . '%_%',
'format' => 'page/%#%',
'total' => $network_query->max_num_pages,
'current' => !empty( $network_query->query_vars['paged'] ) ? $network_query->query_vars['paged'] : 1,
'prev_next' => true,
) );
}
function global_site_search_get_background_color() {
return get_site_option( 'global_site_search_background_color', '#F2F2EA' );
}
function global_site_search_get_alt_background_color() {
return get_site_option( 'global_site_search_alternate_background_color', '#FFFFFF' );
}
function global_site_search_get_border_color() {
return get_site_option( 'global_site_search_border_color', '#CFD0CB' );
}