PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-search/src/class-plan.php +15 -3 13.5.2 → 16.3 View file →
@@ -11,8 +11,12 @@
11 11 use Automattic\Jetpack\Connection\Client;
12 12 use Jetpack_Options;
13 13 use WP_Error;
14 14
15 +if ( ! defined( 'ABSPATH' ) ) {
16 + exit( 0 );
17 +}
18 +
15 19 /**
16 20 * Registers the REST routes for Search.
17 21 */
18 22 class Plan {
@@ -45,9 +49,14 @@
45 49 /**
46 50 * Refresh plan info stored in options
47 51 */
48 52 public function get_plan_info_from_wpcom() {
49 - $blog_id = Jetpack_Options::get_option( 'id' );
53 + $blog_id = Jetpack_Options::get_option( 'id' );
54 + // An unregistered site (or a stale cache view hiding the registration) has no
55 + // blog ID: bail rather than requesting the malformed `/sites//…` path.
56 + if ( ! $blog_id ) {
57 + return new WP_Error( 'site_not_registered', 'Site not registered.' );
58 + }
50 59 $response = Client::wpcom_json_api_request_as_blog(
51 60 '/sites/' . $blog_id . '/jetpack-search/plan',
52 61 '2',
53 62 array(),
@@ -90,9 +99,9 @@
90 99 * Returns true if plan supports Instant Search.
91 100 */
92 101 public function supports_instant_search() {
93 102 $plan_info = $this->get_plan_info();
94 - return ( isset( $plan_info['supports_instant_search'] ) && $plan_info['supports_instant_search'] ) || $this->has_jetpack_search_product();
103 + return ( isset( $plan_info['supports_instant_search'] ) && $plan_info['supports_instant_search'] );
95 104 }
96 105
97 106 /**
98 107 * Returns true if the plan support either Instant Search or Classic Search.
@@ -98,9 +107,9 @@
98 107 * Returns true if the plan support either Instant Search or Classic Search.
99 108 */
100 109 public function supports_search() {
101 110 $plan_info = $this->get_plan_info();
102 - return ( isset( $plan_info['supports_search'] ) && $plan_info['supports_search'] ) || $this->has_jetpack_search_product();
111 + return ( isset( $plan_info['supports_search'] ) && $plan_info['supports_search'] );
103 112 }
104 113
105 114 /**
106 115 * Returns true if the plan usage is exceeded and search should no longer work.
@@ -158,8 +167,11 @@
158 167 *
159 168 * @param array $plan_info - the decoded plan info array.
160 169 */
161 170 public function set_plan_options( $plan_info ) {
171 + if ( isset( $plan_info['swap_classic_to_inline_search'] ) && is_bool( $plan_info['swap_classic_to_inline_search'] ) ) {
172 + update_option( Module_Control::SEARCH_MODULE_SWAP_CLASSIC_TO_INLINE_OPTION_KEY, (bool) $plan_info['swap_classic_to_inline_search'] );
173 + }
162 174 if ( ! isset( $plan_info['supports_instant_search'] ) ) {
163 175 return false;
164 176 }
165 177 // set option whether has Jetpack Search plan for capability reason.