1

I recently downloaded the WP Mobile Detect plugin and integrated it to my theme (the original mobile detect library I include from the theme folder and the matching WP-functions I pasted directly into functions.php).

Now I have one Social Share Plug-In I only want to appear when the site gets requested by desktop devices. So I tried modifying the core files of that plugin, wrapping the output function inside a condition of WP Mobile Detect, like:

if ( ! wpmd_is_phone() ) { // output my share buttons }

Unfortunately, this will return a Call to undefined function. How can I fix this?

1

You either have to include/require the WPMD file that includes the function(s) you are using, or just use the globally defined $detect object, like so:

global $detect;
if (! $detect->isMobile() || $detect->isTablet()) {
    // output your share buttons
}

// EDIT
The above conditional is the equivalent of your ! wpmd_is_phone() conditional. However, if you want to restrict this to desktop devices only, you should use the following:

global $detect;
if (! ($detect->isMobile() || $detect->isTablet())) {
    // output your share buttons
}
  • 1
    That's what I needed! Thank you very much for this! Sorry for honoring that late — my holidays came up ;-) – Circuit Circus Sep 16 '13 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.