classic-search
3 days ago
customberg
8 months ago
customizer
3 months ago
dashboard
2 months ago
initializers
1 month ago
inline-search
3 days ago
instant-search
2 months ago
search-blocks
3 days ago
widgets
1 month ago
wpes
8 months ago
class-ai-answers.php
3 months ago
class-cli.php
3 months ago
class-helper.php
3 days ago
class-module-control.php
2 months ago
class-options.php
3 months ago
class-package.php
3 days ago
class-plan.php
8 months ago
class-rest-controller.php
1 month ago
class-settings.php
2 months ago
class-stats.php
8 months ago
class-template-tags.php
8 months ago
class-options.php
100 lines
| 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 | } |
| 100 |