Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_check_browser_version [ WordPress Function ]

wp_check_browser_version ( No parameters )
Returns:
  • (array|bool) False on failure, array of browser data on success.
Defined at:



Check if the user needs a browser update

Source


<?php
function wp_check_browser_version() {
    if ( empty( 
$_SERVER['HTTP_USER_AGENT'] ) )
        return 
false;

    
$key md5$_SERVER['HTTP_USER_AGENT'] );

    if ( 
false === ($response get_site_transient('browser_' $key) ) ) {
        global 
$wp_version;

        
$options = array(
            
'body'            => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
            
'user-agent'    => 'WordPress/' $wp_version '; ' home_url()
        );

        
$response wp_remote_post'http://api.wordpress.org/core/browse-happy/1.0/'$options );

        if ( 
is_wp_error$response ) || 200 != wp_remote_retrieve_response_code$response ) )
            return 
false;

        
/**
         * Response should be an array with:
         *  'name' - string - A user friendly browser name
         *  'version' - string - The most recent version of the browser
         *  'current_version' - string - The version of the browser the user is using
         *  'upgrade' - boolean - Whether the browser needs an upgrade
         *  'insecure' - boolean - Whether the browser is deemed insecure
         *  'upgrade_url' - string - The url to visit to upgrade
         *  'img_src' - string - An image representing the browser
         *  'img_src_ssl' - string - An image (over SSL) representing the browser
         */
        
$response maybe_unserializewp_remote_retrieve_body$response ) );

        if ( ! 
is_array$response ) )
            return 
false;

        
set_site_transient'browser_' $key$response604800 ); // cache for 1 week
    
}

    return 
$response;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics