_get_os(); $should_display = array_intersect( $operating_systems, (array) $current_os ) ? true : false; return ( 'is' === $display_rule ) ? $should_display : ! $should_display; } /** * Returns the Operating System name based on user agent. * * @since 4.11.0 * * @return string */ protected function _get_os() { $os_platform = 'unknown'; // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- User Agent is not stored or displayed therefore XSS safe. $user_agent = $_SERVER['HTTP_USER_AGENT']; $os_array = array( '/windows nt/i' => 'windows', '/macintosh|mac os x/i' => 'macos', '/linux/i' => 'linux', '/android/i' => 'android', '/iphone/i' => 'iphone', '/ipad/i' => 'ipad', '/ipod/i' => 'ipod', '/appletv/i' => 'appletv', '/playstation/i' => 'playstation', '/xbox/i' => 'xbox', '/nintendo/i' => 'nintendo', '/webos|hpwOS/i' => 'webos', ); foreach ( $os_array as $regex => $value ) { if ( preg_match( $regex, $user_agent ) ) { $os_platform = $value; } } return $os_platform; } }