Changeset 5962
- Timestamp:
- 09/25/2017 04:24:26 PM (8 years ago)
- Location:
- sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/parse.php
r5961 r5962 22 22 * @type bool $upgrade Is there an update available for the browser? 23 23 * @type bool $insecure Is the browser insecure? 24 * @type bool $mobile Is the browser on a mobile platform? 24 25 * } 25 26 */ … … 35 36 'upgrade' => false, 36 37 'insecure' => false, 38 'mobile' => false, 37 39 ); 38 40 … … 48 50 if ( 'Linux' === $data['platform'] && false !== strpos( $user_agent, 'Android' ) ) { 49 51 $data['platform'] = 'Android'; 52 } 53 54 if ( in_array( $data['platform'], array( 'Android', 'iPad', 'iPhone', 'PlayBook', 'RIM Tablet OS' ) ) ) { 55 $data['mobile'] = true; 50 56 } 51 57 … … 115 121 } 116 122 117 // Don't fetch additional browser data for mobile platform browsers. 118 if ( in_array( $data['platform'], array( 'Android', 'iPad', 'iPhone' ) ) ) { 123 if ( $data['mobile'] ) { 124 // Generically set "Mobile" as the platform if a platform hasn't been set. 125 if ( ! $data['platform'] ) { 126 $data['platform'] = 'Mobile'; 127 } 128 129 // Don't fetch additional browser data for mobile platform browsers at this time. 119 130 return $data; 120 131 } -
sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/tests/phpunit/tests/browse-happy.php
r5961 r5962 252 252 } 253 253 254 /** 255 * @dataProvider data_browse_happy 256 * 257 * @param string $header 'User-Agent' header value. 258 */ 259 function test_mobile_browsers( $header ) { 260 $parsed = browsehappy_parse_user_agent( $header ); 261 262 if ( in_array( $parsed['platform'], array( 'Android', 'iPad', 'iPhone', 'Mobile', 'PlayBook', 'RIM Tablet OS' ) ) ) { 263 $this->assertTrue( $parsed['mobile'] ); 264 } else { 265 $this->assertFalse( $parsed['mobile'] ); 266 } 267 } 268 254 269 } 255
Note: See TracChangeset
for help on using the changeset viewer.