Git Product home page Git Product logo

Comments (5)

christianwach avatar christianwach commented on July 30, 2024

Your $detect variable is out of scope. Add:

global $detect;

before your code in both files

HTH, Christian

from mobile-detect.

 avatar commented on July 30, 2024

Perfect thanks.

I added to my functions.php file

include("includes/Mobile_Detect.php"); global $detect; $detect = new Mobile_Detect;

I actually didn't need to add global $detect; in my header.php file to get it working.

Should I include it anyway to be safe?

from mobile-detect.

shawnsandy avatar shawnsandy commented on July 30, 2024

Your include path is seems wrong should read

include ('get_template_directory().'/includes/Mobile_Detect.php') ;

from mobile-detect.

serbanghita avatar serbanghita commented on July 30, 2024

Haven't worked with Wordpress in a while but it looks like you should use a plugin. Modifying functions.php will make it hard to update Wordpress.

Maybe you can get some inspiration from http://wordpress.org/extend/plugins/wp-mobile-detect/ which uses Mobile_Detect class.

from mobile-detect.

 avatar commented on July 30, 2024

Your plugin is working fine for me in Wordpress so far. I like staying away from WP plugins.

Anyways, so far so good.

Thanks!

from mobile-detect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.