Skip to content

Commit

Permalink
Search: use classic search for ios<16 devices (#33929)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangzj authored and matticbot committed Nov 13, 2023
1 parent 55fa4d0 commit a9ddda5
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 80 deletions.
3 changes: 3 additions & 0 deletions jetpack_vendor/automattic/jetpack-search/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

This is an alpha version! The changes listed here are not final.

### Fixed
- Search: use classic search for iOS<16

## [0.39.5] - 2023-11-03

## [0.39.4] - 2023-10-30
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase
/**
* Compatibility for browsers that don't support Instant Search.
*
* @package automattic/jetpack-search
*/
namespace Automattic\Jetpack\Search\Compatibility;

add_filter( 'jetpack_search_classic_search_enabled', __NAMESPACE__ . '\enable_classic_search_for_unsupported_browsers', 10, 1 );

/**
* Get the iOS version from the user agent.
*
* @param string $user_agent The user agent string.
* @return null|string The iOS version, or null if not found.
*/
function get_ios_version_from_user_agent( $user_agent ) {
preg_match( '#\((iPhone|iPad|iPod).*?OS (\d+_?\d?_?\d?).*?\)#', $user_agent, $matches );

if ( empty( $matches[2] ) ) {
return null;
}

$version = str_replace( '_', '.', $matches[2] );
return $version;
}

/**
* Force enable Classic Search for browsers for iOS versions < 16.
*
* @param boolean $classic_search_enabled whether Classic Search is enabled.
*/
function enable_classic_search_for_unsupported_browsers( $classic_search_enabled ) {
$ios_version = get_ios_version_from_user_agent( isset( $_SERVER['HTTP_USER_AGENT'] ) ? filter_var( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '' );
if ( $ios_version && version_compare( $ios_version, '16.0', '<' ) ) {
return true;
}
return $classic_search_enabled;
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static function include_compatibility_files() {
}
require_once Package::get_installed_path() . 'compatibility/search-0.15.2.php';
require_once Package::get_installed_path() . 'compatibility/search-0.17.0.php';
require_once Package::get_installed_path() . 'compatibility/unsupported-browsers.php';
}

/**
Expand All @@ -112,11 +113,20 @@ protected static function init_search( $blog_id ) {
// We could provide CLI to enable search/instant search, so init them regardless of whether the module is active or not.
static::init_cli();

$success = false;
if ( ( new Module_Control() )->is_instant_search_enabled() ) {
$success = false;
$is_instant_search_enabled = ( new Module_Control() )->is_instant_search_enabled();
if ( $is_instant_search_enabled ) {
// Enable Instant search experience.
$success = static::init_instant_search( $blog_id );
} else {
}
/**
* Filter whether classic search should be enabled. By this stage, search module would be enabled already.
*
* @since Jetpack $$next_version$$
* @param boolean initial value whether classic search is enabled.
* @param boolean filtered result whether classic search is enabled.
*/
if ( apply_filters( 'jetpack_search_classic_search_enabled', ! $is_instant_search_enabled ) ) {
// Enable the classic search experience.
$success = static::init_classic_search( $blog_id );
}
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/i18n-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
),
'jetpack-search-pkg' => array(
'path' => 'jetpack_vendor/automattic/jetpack-search',
'ver' => '0.39.6-alpha1699636171',
'ver' => '0.39.6-alpha1699854388',
),
'jetpack-stats' => array(
'path' => 'jetpack_vendor/automattic/jetpack-stats',
Expand Down
54 changes: 27 additions & 27 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-a8c-mc-stats",
"reference": "e605c8d0b7590f358dc1c3b9096d3027e8ef8603"
"reference": "22bf8c7c00885bf2aca427f17b86d88cf44a8865"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down Expand Up @@ -57,7 +57,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-admin-ui",
"reference": "e7707a6be12263c80f99fba58648b404c37d7576"
"reference": "cffc22d703b01c2f0409fe3e67609df57683bf2d"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down Expand Up @@ -119,7 +119,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-assets",
"reference": "12ca01bdbbf98cd9f682d65496e1663d7957bb2e"
"reference": "bf5415ac36f9ef5759d4a537eaba3fad9007dafe"
},
"require": {
"automattic/jetpack-constants": "^1.6.23"
Expand Down Expand Up @@ -187,7 +187,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-autoloader",
"reference": "5076f1c4d9735f53b80076f668543e13bc2d0255"
"reference": "01c6f5fffee87e84daa361db33f09b769f9891b7"
},
"require": {
"composer-plugin-api": "^1.1 || ^2.0"
Expand Down Expand Up @@ -252,7 +252,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-composer-plugin",
"reference": "47c051bd7600c7648b6c99cefc37c7d838373a71"
"reference": "b63919cb799685c90ac8d25ed6658a259043c8ba"
},
"require": {
"composer-plugin-api": "^2.1.0"
Expand Down Expand Up @@ -311,7 +311,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-config",
"reference": "d419708af22aa3f4feec0b5e30ed86a4b83f2879"
"reference": "9c7c13d220f8b1eba3d613342543ab03a5081b43"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11"
Expand Down Expand Up @@ -353,7 +353,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-connection",
"reference": "1de0ad872c109f1c793b54a8c211e4452e22845e"
"reference": "05e14cd61d7230f08e3d0c2d9ac5d4fec6f3ea96"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^1.4.22",
Expand Down Expand Up @@ -431,7 +431,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-constants",
"reference": "63bdc730295f2c1482327559f7cf0704101283eb"
"reference": "ae2ba070b420007723c926780a0b29bd03594c4e"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down Expand Up @@ -482,7 +482,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-device-detection",
"reference": "c2c00c6bfa38250761dc61cd2b461a02dd94f51e"
"reference": "52fed735856e1fb728d93bdd1b4cc42fd839e3e8"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down Expand Up @@ -532,7 +532,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-identity-crisis",
"reference": "b080ca5da3af816fd390431ff99c5d5f5ec7d9b9"
"reference": "e48458532b18d242b3af2af53206c5e22bf006c1"
},
"require": {
"automattic/jetpack-assets": "^1.18.14",
Expand Down Expand Up @@ -610,7 +610,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-ip",
"reference": "f5a1764771f3e0e1bb1ccabde92a7f7ba223c07f"
"reference": "af38394ccb3d0d44490177deca667bcd0b010c49"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down Expand Up @@ -665,7 +665,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-jitm",
"reference": "3f508f3e3201ea99ba3c9fdc2b2f1976a9ff77a3"
"reference": "3b7500d448b3156f4c82e84b89e11382a021e9c6"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^1.4.22",
Expand Down Expand Up @@ -740,7 +740,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-licensing",
"reference": "065ca788cfef2a06959bdf74482fafb8d2bc0f31"
"reference": "e7f4f76a177a61d3835496f0f4acfbe69075f45e"
},
"require": {
"automattic/jetpack-connection": "^1.60.0-alpha"
Expand Down Expand Up @@ -801,7 +801,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-logo",
"reference": "47d75fcf55364808ee05031dd86823c42be0df60"
"reference": "e21591663c063b142bb59bc2e30e843b84c3a5fd"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down Expand Up @@ -851,7 +851,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-my-jetpack",
"reference": "bd034849bd7bb9f837af44987a38d72123de6b09"
"reference": "3588259dc265698ca6b2dcad11d3f6d7d67f8cb1"
},
"require": {
"automattic/jetpack-admin-ui": "^0.2.24",
Expand Down Expand Up @@ -942,7 +942,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-partner",
"reference": "d1087626406fd10d20ccb8196534a5561c6d2f36"
"reference": "d5b4977311d28d220239385b172509f6ee3114e4"
},
"require": {
"automattic/jetpack-connection": "^1.60.0-alpha",
Expand Down Expand Up @@ -1004,7 +1004,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-password-checker",
"reference": "e3b1b3672894f1610eba3553cd759f56b336cb53"
"reference": "6b570994acca12734d05996993c9cabf43186893"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down Expand Up @@ -1062,7 +1062,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-plans",
"reference": "251b0cf92bf30014a240e1f8f0f7f4b40db0181b"
"reference": "cf75d66447a67e6774ac44bd3ae713f7ba466f80"
},
"require": {
"automattic/jetpack-connection": "^1.60.0-alpha"
Expand Down Expand Up @@ -1129,7 +1129,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-plugins-installer",
"reference": "64f07d5375f8fe2ea5bc1f0863975e96b276b11e"
"reference": "f17117656240114f6d8406631e6458ec80d80631"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^1.4.22"
Expand Down Expand Up @@ -1183,7 +1183,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-redirect",
"reference": "7f6ec44821e87513b22a8a6976608acc1573f4e6"
"reference": "cddce24225885ccce3ec008143078cc8778365a5"
},
"require": {
"automattic/jetpack-status": "^1.19.0-alpha"
Expand Down Expand Up @@ -1237,7 +1237,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-roles",
"reference": "ac48b4ded807bcb3b6b7cc03ee149c9282080cd7"
"reference": "008ab62e3146959024e089d59a1b177435e977b4"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down Expand Up @@ -1283,12 +1283,12 @@
},
{
"name": "automattic/jetpack-search",
"version": "0.39.6-alpha.1699636171",
"version_normalized": "0.39.6.0-alpha1699636171",
"version": "0.39.6-alpha.1699854388",
"version_normalized": "0.39.6.0-alpha1699854388",
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-search",
"reference": "8ec3eb986d855aa099a49828bae6b63e4ab85ae1"
"reference": "6eba89aad510ee6ce8c4718893d79071679cd83f"
},
"require": {
"automattic/jetpack-assets": "^1.18.14",
Expand Down Expand Up @@ -1374,7 +1374,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-stats",
"reference": "61bf1e062361eb00d05b94062769827cc630e447"
"reference": "3ade15bb0d16347828928f243c6d74b82b4985af"
},
"require": {
"automattic/jetpack-assets": "^1.18.14",
Expand Down Expand Up @@ -1438,7 +1438,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-status",
"reference": "74a3e50e3d5643affced2ee9b9165f00a381f1f0"
"reference": "03c1bb1c0ff9ff1163114c4ce82fcccd0761d071"
},
"require": {
"automattic/jetpack-constants": "^1.6.23"
Expand Down Expand Up @@ -1493,7 +1493,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-sync",
"reference": "40dfeb82212228c88b7d7d4a1951055328412a61"
"reference": "e3503833ed3c9caceb156dda1d14ac2819da5285"
},
"require": {
"automattic/jetpack-connection": "^1.60.0-alpha",
Expand Down
Loading

0 comments on commit a9ddda5

Please sign in to comment.