_get_browser( $useragent ); // Exception: When checking "Chrome" condition we should treat New Edge as Chrome. if ( 'edge' === $current_browser && ! $is_old_edge && $is_checking_for_chrome ) { $current_browser = 'chrome'; } $should_display = array_intersect( $browsers, (array) $current_browser ) ? true : false; return ( 'is' === $display_rule ) ? $should_display : ! $should_display; } /** * Returns the Browser name based on user agent. * * @since 4.11.0 * * @param string $useragent The useragent of the berowser. * * @return string Detected browser. */ protected function _get_browser( $useragent ) { $browser = 'unknown'; $browser_array = array( '/safari/i' => 'safari', '/chrome|CriOS/i' => 'chrome', '/firefox|FxiOS/i' => 'firefox', '/msie|Trident/i' => 'ie', '/edg/i' => 'edge', '/opr|Opera|Presto/i' => 'opera', '/maxthon/i' => 'maxthon', '/ucbrowser/i' => 'ucbrowser', ); foreach ( $browser_array as $regex => $value ) { if ( preg_match( $regex, $useragent ) ) { $browser = $value; } } return $browser; } }