Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Problems Incorporating with WordPress #18

Open
isGabe opened this issue May 31, 2013 · 4 comments
Open

Problems Incorporating with WordPress #18

isGabe opened this issue May 31, 2013 · 4 comments

Comments

@isGabe
Copy link

isGabe commented May 31, 2013

I know you can't support all possible platforms, but WordPress is a pretty popular PHP based platform, so perhaps you have some ideas.

I did find and try this plugin, which is just a simple wrapper to include, in addition to trying to manually include Detector.

Here is what I found:

Detector WordPress issues

Notes

  • Local Install
  • WordPress 3.5.1
  • All other plugins deactivated
  • Twenty Twelve Theme
  • Using ServerPress - DesktopServer
  • PHP version 5.3.1
  • set permissions to 777 on all files in Detector directory

1) Plugin - As - Is

  • http://wordpress.org/plugins/detector/
  • Last updated: 9/10/2012
  • Installed as is I get the following PHP warning:
    Warning: Invalid argument supplied for foreach() in /[path_to_wp_install]/wp-content/plugins/detector/lib/Detector/Detector.php on line 77
    Detector.php line 77:
    ```// populate some standard variables out of the config
    foreach ($config as $key => $value) {
    self::$$key = $value;
    }
- Below the warning, the rest fo the site appears to load normally

#### 2) Plugin - replacing entire /lib/Detector/ directory with current version from github
https://github.com/dmolsen/Detector/
- When I replace the /lib/Detector/ directory with the most current version I get a similar PHP warning
- `Warning: Invalid argument supplied for foreach() in /[path_to_wp_install]/wp-content/plugins/detector/lib/Detector/Detector.php on line 70`
- Detector.php line 70:
    ```// populate some standard variables out of the config
       foreach ($config as $key => $value) {
        self::$$key = $value;
       }
  • in addition, below the PHP warning I get a page full of raw code, and the rest of the site does not load.
  • screenshot http://d.pr/i/tRe7
  • It appears to break and print the raw code of Detector.php after line 380, which is within the buildTestPage() function.

3) Manually include latest version from github

https://github.com/dmolsen/Detector/

@dmolsen
Copy link
Owner

dmolsen commented Jun 11, 2013

You can try two things. First, manually move config.ini.default to config.ini. Second, on line #65 it should say:

$config = @parse_ini_file(__DIR__."/config/config.ini");

Take out the @ symbol. I suspect it'll throw an error which will give you a better idea of why the foreach is blowing up.

@isGabe
Copy link
Author

isGabe commented Jun 11, 2013

Hey, thanks for the reply. Not sure about the first thing, since config.ini and config.default.ini appear to be identical. Even so, I went ahead and removed config.ini, then renamed config.ini.default to config.ini, at which point I only got the "Please make sure config.ini.default exists before trying to have Detector build the config.ini file automagically."

As for the second thing, removing the @ symbol did indeed allow a new error message to come through:
Warning: syntax error, unexpected BOOL_FALSE in ~/detector/lib/Detector/config/config.ini on line 26

The weird thing is that line 26 is a comment line:
// do we show a default family for those browsers that don't support JavaScript, by default NO

I played around and discovered that somehow the word NO was triggering it. if I remove NO, then the unexpected BOOL_FALSE error goes away every time. If I put NO back in, the error comes back every time.

The bad news is that when I got rid of the BOOL_FALSE error, 3 new things pop up:

Notice: Undefined property: stdClass::$csstranforms in ~/lib/Detector/lib/feature-family/featureFamily.php on line 158

Warning: Cannot modify header information - headers already sent by (output started at ~/lib/Detector/lib/feature-family/featureFamily.php:158) in ~/wp-includes/option.php on line 568

Warning: Cannot modify header information - headers already sent by (output started at ~/wp-content/plugins/detector/lib/Detector/lib/feature-family/featureFamily.php:158) in /Users/hal/Documents/ArtFiles/web/Locality/wpajax.dev/wp-includes/option.php on line 569

I was ready to give up, but I noticed the typo "$csstranforms" (should be "$csstransforms"). I hunted that down to line 7 of /config/families.json and families.json.default. I corrected it and all of the notices went away except for a WordPress error: The plugin generated 10217 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

So I finally have a chance to use it! Still some unexpected behavior, but I'll play with it some more and see how it works. In the meantime I may submit a pull request for that typo...

@afryer
Copy link

afryer commented Aug 22, 2013

I put the folders in the root directory of wordpress and included

require_once('library/detector/lib/Detector/Detector.php');

in the root index file as the first call, I can then use detector in all themes.

Not sure if that is right or wrong to put in root, need to remember if updating wordpress but it works for me.

@michaelschofield
Copy link

I didn't have a problem dropping the Detector directory into into my theme and then requiring it from functions.php. Everything seemed to work fine except for an XMLRPC issue, for which I am going to open a separate issue - but I just wanted to comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants