WordPress.org

Ready to get started?Download WordPress

Forums

Mobile Client Detection Plugin
[resolved] Fix for usage device recognition funcs (2 posts)

  1. Laurens Offereins
    Member
    Posted 2 years ago #

    Currently the is_desktop(), is_mobile() and is_tablet() are defined from the query_vars that are set in this plugin. When you want to use these functions before the initiation of WP_Query they return false, because the query_vars aren't set yet. I suggest to change the functions (bottom of mobile_client_detection.php) as follows, from

    function is_desktop(){return((get_query_var('platform')=='desktop')? true : false);}
    function is_mobile(){return((get_query_var('platform')=='mobile')? true : false);}
    function is_tablet(){return((get_query_var('platform')=='tablet')? true : false);}
    

    to

    function is_desktop(){return((mcd_get_platform()=='desktop')? true : false);}
    function is_mobile(){return((mcd_get_platform()=='mobile')? true : false);}
    function is_tablet(){return((mcd_get_platform()=='tablet')? true : false);}
    

    where I use the mcd_get_platform function, called in this plugin to read the $_SERVER['HTTP_USER_AGENT'] variable.

    Using these changes, you're able to use these functions in, for example, the wp_enqueue_scripts hook that's used in the wp_head() to set device specific scripts.

    http://wordpress.org/extend/plugins/mobile-client-detection-plugin/

  2. syslogic
    Member
    Plugin Author

    Posted 2 years ago #

    I'd have to see, just currently pretty busy and no donations at all yet.

    I'm really not intending to starve from GPL idealism,
    when I can choose daily from several commercial projects.
    It's like "What do you want to code today?" :)

    Nevertheless, thanks for pointing that out, will commit once verified.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic