No Description

class-jetpack-search-options.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. use Automattic\Jetpack\Constants;
  10. /**
  11. * Helpers for parsing the various Search options
  12. *
  13. * @since 8.3.0
  14. */
  15. class Jetpack_Search_Options {
  16. /**
  17. * The search widget's base ID.
  18. *
  19. * @since 5.8.0
  20. * @var string
  21. */
  22. const FILTER_WIDGET_BASE = 'jetpack-search-filters';
  23. /**
  24. * Prefix for options in DB.
  25. *
  26. * @since 8.3.0
  27. * @var string
  28. */
  29. const OPTION_PREFIX = 'jetpack_search_';
  30. /**
  31. * Available result formats.
  32. *
  33. * @since 9.6.0
  34. * @var string
  35. */
  36. const RESULT_FORMAT_MINIMAL = 'minimal';
  37. const RESULT_FORMAT_EXPANDED = 'expanded';
  38. const RESULT_FORMAT_PRODUCT = 'product';
  39. /**
  40. * Available overlay triggers.
  41. *
  42. * @since 9.9.0
  43. * @var string
  44. */
  45. const OVERLAY_TRIGGER_IMMEDIATE = 'immediate';
  46. const OVERLAY_TRIGGER_RESULTS = 'results';
  47. const OVERLAY_TRIGGER_SUBMIT = 'submit';
  48. /**
  49. * Returns a boolean for whether instant search is enabled.
  50. *
  51. * @since 8.3.0
  52. *
  53. * @return bool
  54. */
  55. public static function is_instant_enabled() {
  56. return true === (bool) get_option( 'instant_search_enabled' );
  57. }
  58. /**
  59. * Returns a boolean for whether the current site has a VIP index.
  60. *
  61. * @since 5.8.0
  62. *
  63. * @return bool
  64. */
  65. public static function site_has_vip_index() {
  66. $has_vip_index = (
  67. Constants::is_defined( 'JETPACK_SEARCH_VIP_INDEX' ) &&
  68. Constants::get_constant( 'JETPACK_SEARCH_VIP_INDEX' )
  69. );
  70. /**
  71. * Allows developers to filter whether the current site has a VIP index.
  72. *
  73. * @module search
  74. *
  75. * @since 5.8.0
  76. *
  77. * @param bool $has_vip_index Whether the current site has a VIP index.
  78. */
  79. return apply_filters( 'jetpack_search_has_vip_index', $has_vip_index );
  80. }
  81. }