PluginProbe
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation / trunk
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation vtrunk
1.4.48 1.4.47 1.4.46 1.4.45 1.4.44 1.4.43 1.4.42 1.4.41 1.4.40 1.4.39 1.4.38 1.4.37 1.4.36 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 64 releases
optin / includes / utils / class-os.php

class-os.php in WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation trunk, at includes/utils/class-os.php

61 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace OPTN\Includes\Utils;
4
5 use OPTN\Includes\Utils\Device;
6
7 class Os {
8
9 private static $desktop_oses =
10 array(
11 '/windows nt 10/i' => 'Windows',
12 '/windows nt 6.3/i' => 'Windows',
13 '/windows nt 6.2/i' => 'Windows',
14 '/windows nt 6.1/i' => 'Windows',
15 '/windows nt 6.0/i' => 'Windows',
16 '/windows nt 5.2/i' => 'Windows',
17 '/windows nt 5.1/i' => 'Windows',
18 '/windows xp/i' => 'Windows',
19 '/windows nt 5.0/i' => 'Windows',
20 '/windows me/i' => 'Windows',
21 '/win98/i' => 'Windows',
22 '/win95/i' => 'Windows',
23 '/win16/i' => 'Windows',
24 '/macintosh|mac os x/i' => 'Mac',
25 '/mac_powerpc/i' => 'Mac',
26 '/linux/i' => 'Linux',
27 '/ubuntu/i' => 'Linux',
28 );
29
30 private static $mobile_oses =
31 array(
32 '/android/i' => 'Android',
33 '/blackberry/i' => 'Android',
34 '/webos/i' => 'Android',
35 '/iphone/i' => 'iOS',
36 '/ipod/i' => 'iOS',
37 '/ipad/i' => 'iOS',
38 );
39
40 public static function getOS() {
41
42 if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
43 return 'Windows';
44 }
45
46 $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); // phpcs:ignore
47
48 $device = Device::get_device( $user_agent );
49
50 $os_list = $device === 'lg' ? self::$desktop_oses : self::$mobile_oses;
51
52 foreach ( $os_list as $regex => $value ) {
53 if ( preg_match( $regex, $user_agent ) ) {
54 return $value;
55 }
56 }
57
58 return $device === 'lg' ? 'Windows' : 'Android';
59 }
60 }
61