Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
6 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Options | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| is_instant_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| site_has_vip_index | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Another helper class for parsing Jetpack Search options. |
| 4 | * |
| 5 | * @package automattic/jetpack-search |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\Search; |
| 9 | |
| 10 | use Automattic\Jetpack\Constants; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit( 0 ); |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Helpers for parsing the various Search options |
| 18 | */ |
| 19 | class Options { |
| 20 | /** |
| 21 | * The search widget's base ID. |
| 22 | * |
| 23 | * @since 5.8.0 |
| 24 | * @var string |
| 25 | */ |
| 26 | const FILTER_WIDGET_BASE = 'jetpack-search-filters'; |
| 27 | |
| 28 | /** |
| 29 | * Prefix for options in DB. |
| 30 | * |
| 31 | * @since 8.3.0 |
| 32 | * @var string |
| 33 | */ |
| 34 | const OPTION_PREFIX = 'jetpack_search_'; |
| 35 | |
| 36 | /** |
| 37 | * Available result formats. |
| 38 | * |
| 39 | * @since 9.6.0 |
| 40 | * @var string |
| 41 | */ |
| 42 | const RESULT_FORMAT_MINIMAL = 'minimal'; |
| 43 | const RESULT_FORMAT_EXPANDED = 'expanded'; |
| 44 | const RESULT_FORMAT_PRODUCT = 'product'; |
| 45 | |
| 46 | /** |
| 47 | * Available overlay triggers. |
| 48 | * |
| 49 | * @since 9.9.0 |
| 50 | * @var string |
| 51 | */ |
| 52 | const OVERLAY_TRIGGER_IMMEDIATE = 'immediate'; |
| 53 | const OVERLAY_TRIGGER_SUBMIT = 'submit'; |
| 54 | const DEFAULT_OVERLAY_TRIGGER = self::OVERLAY_TRIGGER_SUBMIT; |
| 55 | |
| 56 | /** |
| 57 | * Deprecated overlay trigger. |
| 58 | * |
| 59 | * @var string |
| 60 | * @deprecated since 11.3 |
| 61 | */ |
| 62 | const OVERLAY_TRIGGER_RESULTS = 'results'; |
| 63 | |
| 64 | /** |
| 65 | * Returns a boolean for whether instant search is enabled. |
| 66 | * |
| 67 | * @since 8.3.0 |
| 68 | * |
| 69 | * @return bool |
| 70 | */ |
| 71 | public static function is_instant_enabled() { |
| 72 | return (bool) get_option( 'instant_search_enabled' ); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Returns a boolean for whether the current site has a VIP index. |
| 77 | * |
| 78 | * @since 5.8.0 |
| 79 | * |
| 80 | * @return bool |
| 81 | */ |
| 82 | public static function site_has_vip_index() { |
| 83 | $has_vip_index = ( |
| 84 | Constants::is_defined( 'JETPACK_SEARCH_VIP_INDEX' ) && |
| 85 | Constants::get_constant( 'JETPACK_SEARCH_VIP_INDEX' ) |
| 86 | ); |
| 87 | |
| 88 | /** |
| 89 | * Allows developers to filter whether the current site has a VIP index. |
| 90 | * |
| 91 | * @module search |
| 92 | * |
| 93 | * @since 5.8.0 |
| 94 | * |
| 95 | * @param bool $has_vip_index Whether the current site has a VIP index. |
| 96 | */ |
| 97 | return apply_filters( 'jetpack_search_has_vip_index', $has_vip_index ); |
| 98 | } |
| 99 | } |