Skip to content

Commit

Permalink
General: Update Opera browser sniff follow UA string changes.
Browse files Browse the repository at this point in the history
Since switching to the Blink engine, Opera browsers contain both the strings `Chrome` and `OPR\`. This change relocates the Opera test to take place before the Chrome test to ensure the correct browser is detected.

Props brasofilo, desrosj, costdev, mukesh27, swissspidy.
Fixes #46132.


git-svn-id: https://develop.svn.wordpress.org/trunk@56224 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
peterwilsoncc committed Jul 13, 2023
1 parent 65a048f commit b892f51
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wp-includes/vars.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
$is_lynx = true;
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Edg' ) ) {
$is_edge = true;
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Opera' ) || str_contains( $_SERVER['HTTP_USER_AGENT'], 'OPR/' ) ) {
$is_opera = true;
} elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chrome' ) !== false ) {
if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) {
$is_admin = is_admin();
Expand All @@ -95,8 +97,6 @@
$is_macIE = true;
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Gecko' ) ) {
$is_gecko = true;
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Opera' ) ) {
$is_opera = true;
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Nav' ) && str_contains( $_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.' ) ) {
$is_NS4 = true;
}
Expand Down

0 comments on commit b892f51

Please sign in to comment.