Making WordPress.org


Ignore:
Timestamp:
10/02/2017 07:39:32 PM (6 years ago)
Author:
coffee2code
Message:

Browse Happy API: Improve indentification of BlackBerry, Nokia, and Sony Ericsson devices generically as mobile devices if platform not otherwise known.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/parse.php

    r5986 r5988  
    3838        'mobile'          => false,
    3939    );
     40    $mobile_device = '';
    4041
    4142    if ( preg_match(
     
    5455            $data['platform'] = 'Android';
    5556        }
    56     } elseif ( 'Windows Phone' === $data['platform'] ) {
     57    }
     58    // Normalize Windows Phone OS name when "OS" is omitted.
     59    elseif ( 'Windows Phone' === $data['platform'] ) {
    5760        $data['platform'] = 'Windows Phone OS';
    5861    }
    59 
    60     if ( in_array( $data['platform'], array( 'Android', 'Fire OS', 'iPad', 'iPhone', 'PlayBook', 'RIM Tablet OS', 'Windows Phone OS' ) ) ) {
     62    // Generically detect some mobile devices.
     63    elseif (
     64        ! $data['platform']
     65    &&
     66        preg_match( '/BlackBerry|Nokia|SonyEricsson/', $user_agent, $matches )
     67    ) {
     68        $data['platform'] = 'Mobile';
     69        $mobile_device    = $matches[0];
     70    }
     71
     72    // Flag known mobile platforms as mobile.
     73    if ( in_array( $data['platform'], array( 'Android', 'Fire OS', 'iPad', 'iPhone', 'Mobile', 'PlayBook', 'RIM Tablet OS', 'Windows Phone OS' ) ) ) {
    6174        $data['mobile'] = true;
    6275    }
     
    146159            $data['name'] = 'unknown';
    147160            $result['version'][ $key ] = '';
     161            $version = '';
    148162        }
    149163        $data['version'] = $result['version'][ $key ];
Note: See TracChangeset for help on using the changeset viewer.