WordPress.org

Make WordPress Core

Changeset 36813


Ignore:
Timestamp:
03/03/16 03:24:02 (19 months ago)
Author:
johnbillion
Message:

Uploads: Remove an unnecessary static var from wp_is_mobile() to allow its direct and indirect use within unit tests. The static `$is_m
obile var was only used to avoid a handful of calls to strpos()`, which are exceptionally fast and result in no measurable increase in
processing time on each call to wp_is_mobile().

See #35976, #20014

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/vars.php

    r36812 r36813  
    121121 * Test if the current browser runs on a mobile device (smart phone, tablet, etc.) 
    122122 * 
    123  * @staticvar bool $is_mobile 
    124  * 
    125123 * @return bool 
    126124 */ 
    127125function wp_is_mobile() { 
    128     static $is_mobile = null; 
    129  
    130     if ( isset( $is_mobile ) ) { 
    131         return $is_mobile; 
    132     } 
    133  
    134126    if ( empty($_SERVER['HTTP_USER_AGENT']) ) { 
    135127        $is_mobile = false; 
Note: See TracChangeset for help on using the changeset viewer.