Completed
Push — instant-search-master ( 6806c6...584d61 )
by
unknown
06:40
created

Jetpack_Search_Options   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A site_has_vip_index() 0 17 2
A is_instant_enabled() 0 3 1
1
<?php
2
/**
3
 * Jetpack Search: Jetpack_Search_Options class
4
 *
5
 * @package    Jetpack
6
 * @subpackage Jetpack Search
7
 * @since      8.3.0
8
 */
9
10
use Automattic\Jetpack\Constants;
11
12
/**
13
 * Helpers for parsing the various Search options
14
 *
15
 * @since 8.3.0
16
 */
17
class Jetpack_Search_Options {
18
19
	/**
20
	 * The search widget's base ID.
21
	 *
22
	 * @since 5.8.0
23
	 * @var string
24
	 */
25
	const FILTER_WIDGET_BASE = 'jetpack-search-filters';
26
27
	/**
28
	 * Prefix for options in DB.
29
	 *
30
	 * @since 8.3.0
31
	 * @var string
32
	 */
33
	const OPTION_PREFIX = 'jetpack_search_';
34
35
	/**
36
	 * Returns a boolean for whether instant search is enabled.
37
	 *
38
	 * @since 8.3.0
39
	 *
40
	 * @return bool
41
	 */
42
	public static function is_instant_enabled() {
43
		return Constants::is_true( 'JETPACK_SEARCH_PROTOTYPE' );
44
	}
45
46
47
	/**
48
	 * Returns a boolean for whether the current site has a VIP index.
49
	 *
50
	 * @since 5.8.0
51
	 *
52
	 * @return bool
53
	 */
54
	public static function site_has_vip_index() {
55
		$has_vip_index = (
56
			Constants::is_defined( 'JETPACK_SEARCH_VIP_INDEX' ) &&
57
			Constants::get_constant( 'JETPACK_SEARCH_VIP_INDEX' )
58
		);
59
60
		/**
61
		 * Allows developers to filter whether the current site has a VIP index.
62
		 *
63
		 * @module search
64
		 *
65
		 * @since  5.8.0
66
		 *
67
		 * @param bool $has_vip_index Whether the current site has a VIP index.
68
		 */
69
		return apply_filters( 'jetpack_search_has_vip_index', $has_vip_index );
70
	}
71
72
73
}
74