1 (edited by shellwe 2015-04-12 08:01:24)

Topic: Juicebox not working with underscores wordpress theme [SOLVED]

Have any of you had any issues with using the popular underscores with juicebox?

I remember last Fall when I installed a fresh copy of the underscores theme, before I did any editing, and it didn't work, but when I switched to twenty fourteen it worked fine.

If anyone would be willing to take a look you can see an example here:

http://greatplainslandscapes.com/testpr … ebox-test/

You will see there is no juicebox gallery... but if you inspect the element for the text "testing123" you will see it is right above it in the code. Something is preventing it from showing and I am too new with wordpress development to even begin to find the culprit. I don't have any other plugins on.

I would love to use juicebox for this since I paid for a 5 user pro license but I am so far vested into using underscores I can't start over with something else.

If it helps to see some setting I have on the PHP side you are welcome to check out the repository for my theme at:
https://github.com/shellwe/Great-Plains-Landscaping-WP/

Re: Juicebox not working with underscores wordpress theme [SOLVED]

WP-Juicebox loads the 'juicebox.js' file in the web page only if it is required (if a Juicebox shortcode is discovered on the page).
However, for some reason, the 'juicebox.js' file is not being loaded in your web page.
I do not know why this might be but you can ensure that the 'juicebox.js' file is loaded into all your web pages by opening the 'wp-juicebox.php' file in a plain text editor and changing line 31 from:

add_action('the_posts', array(&$this, 'shortcode_check'));

... to:

add_action('wp_enqueue_scripts', array(&$this, 'add_scripts_wp_core'));

3 (edited by shellwe 2015-04-12 19:25:36)

Re: Juicebox not working with underscores wordpress theme [SOLVED]

At 215 kb I am not a fan of having the juicebox.js always load when I don't need it, especially initial site load but it will need to be a fix until I can find the problem or find an alternate gallery application.

At least the box shows but now I get an issue where it is saying "Config XML file not found". On your FAQ there is a line saying "Make sure the config.xml file is in the gallery folder" but I don't see a gallery folder.

Is this something that should have been generated but just didn't generate correctly because the JS wasn't loading when I created it?

I looked in the original wp plugin and didn't see any gallery folder in there either.
http://www.juicebox.net/release/wp-juicebox.zip

Thank you for your help so far! I am eager to get this working I just wish I tested this earlier on in development so I could verify it wasn't something I did.

Edit: I tried to turn off and turn on the plugin and create a new gallery (it says gallery 3 now) but that still didn't load any gallery folder or xml. Does Juicebox require jquery? I ask because I don't think I have jquery loaded.

Re: Juicebox not working with underscores wordpress theme [SOLVED]

It looks like your problems may be due to your custom theme introducing whitespace in certain places.

Your theme inserts whitespace before the Gallery Id in the Juicebox shortcode which results in the search for a valid shortcode failing (which, in turn, results in the 'juicebox.js' file not being loaded).
For example, a Juicebox shortcode should look like this:

[juicebox gallery_id="1"]

... but yours looks like this:

[juicebox gallery_id=" 1"]

... (note the space before the '1').

Also, your theme inserts four blank lines at the top of your gallery's XML file which appear before the XML declaration resulting in the following error (which may be the reason for the "Config XML file not found" message being displayed).

XML Parsing Error: XML or text declaration not at start of entity

WP-Juicebox cannot prevent against your theme adding whitespace.
(There are also four blank lines above the Doctype Declaration on your main page. These are likely to be coming from the same source.)

Check your theme's PHP files and make sure that there is no whitespace which might be output when the files are loaded. For example, you have blank lines at the top and bottom of your 'functions.php' file which are likely to be the cause of the XML file problem.

I'll try to clarify a couple of other issues from your post above.

On your FAQ there is a line saying "Make sure the config.xml file is in the gallery folder" but I don't see a gallery folder.

WP-Juicebox galleries dare not structured like regular galleries are.
There are no gallery folders for galleries created by WP-Juicebox. All WP-Juicebox galleries share a common 'jbcore' folder (in the 'wp-content/plugins/wp-juicebox/' directory), the images are stored in the Media Library and the XML files for WP-Juicebox galleries are created dynamically when the galleries are displayed.

Does Juicebox require jquery?

Juicebox itself comes with its own version of jQuery (bundled within the 'juicebox.js' JavaScript file) so there is no need to load a separate version of jQuery into your web page.
WP-Juicebox requires jQuery but it uses the version which comes bundled with WordPress, so again, there is no need to load a separate version of jQuery into your web page.

Re: Juicebox not working with underscores wordpress theme [SOLVED]

I am using the underscores theme. When I created a fresh copy of underscores and loaded that, the gallery worked perfectly. This further validated what you are saying about something in my code is injecting the 4 lines.

Worst case (and this would not be pleasant) would just be to move my changes line by line over to a fresh copy until it breaks again.

Thanks for your master sleuthing with this, I will run it by the kind people at the wordpress.org forum and go from there.

Re: Juicebox not working with underscores wordpress theme [SOLVED]

I've done some further testing and it looks like if you remove the two blank lines at the top of your 'functions.php' file and the two blank lines at the bottom of it, everything should be fine.
The whitespace should no longer appear at the top of your HTML or dynamically-generated XML pages or before the Gallery Ids in the Juicebox shortcodes.

Re: Juicebox not working with underscores wordpress theme [SOLVED]

Okay that is seriously cool of you! I had posted the same question on the wordpress sub-reddit and someone was kind enough to do a pull request to fix it. For some reason I didn't get an e-mail saying you had sent a reply this morning, I had just come on here to say it is resolved
I didn't think whitespace in my functions.php would cause so much damage. I will be careful from now on. But now that it is working I will take advantage of git if it ever breaks again!
Thanks for all of your help!

Re: Juicebox not working with underscores wordpress theme [SOLVED]

I'm glad it turned out to be a relatively easy fix.

Thanks for all of your help!

You're welcome!