• Resolved monkeyhouse

    (@monkeyhouse)


    Hey Ulf,

    Been enjoying the plug-in, though there are a few quirks to sort out here and there. The latest version is much improved– good work!

    I noticed today that the wp_head() kept enqueuing a Google APIs copy of jQuery 1.4.2, whereas in functions.php I had explicitly de- and re-registered it to load the copy from jQuery’s own CDN, version 1.4.4.

    After going through the “deactivate all plug-ins and reactivate one at a time” process, I discovered WP-dTree 4.2 to be the culprit.

    I had a quick poke in the code to see if I could figure out where it was coming from, but I came up a bit short, so I’m not sure what the fix is. For that matter, the fact that I couldn’t even find text in the .js or .php files for “google” (to find the line of code calling ajax.googleapis.com) made me at first think I was wrong and that it’s not WP-dTree. But if I deactivate again, the problem goes away. Re-activate and it’s back. It can only be the plug-in and the way its dependencies are resolved.

    Just thought you should know!

    https://www.ads-software.com/extend/plugins/wp-dtree-30/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter monkeyhouse

    (@monkeyhouse)

    Now that I’m digging a bit deeper, I see that there’s a wpdt cache. I suspect it’s actually the caching mechanism that’s causing the headache.

    If there’s no way to change the enqueue method, perhaps a button to clear the cache on demand, without needing to update the site to do so?

    Thread Starter monkeyhouse

    (@monkeyhouse)

    OK, I’m stumped. ?? I poked around a bit and found a method that drops the tables when there’s a change. Simple, it gets the DB, retrieves the DB name, and then issues a DROP.

    I mimic this by going into MySQL, finding the table, and dropping it. The Google 1.4.2 still appears on refresh.

    Wish I could have been more help!

    Thread Starter monkeyhouse

    (@monkeyhouse)

    Still didn’t give up yet… I’m hoping I can find the solution so that I don’t have to burden you with it… but coming up short.

    I’m using only one of the widgets, and it turns out that it didn’t even have cache enabled. So maybe the cache is barking up the wrong tree again?

    Thread Starter monkeyhouse

    (@monkeyhouse)

    Well I guess I’m a stubborn so-and-so, but I found it. Looks like my search tools just didn’t find the text string I was searching for. Not sure why I trusted Desktop search instead of just firing up Notepad++ or an IDE.

    In any event, the problem is in this function in the main file (wp-dtree.php):

    function wpdt_js() {
    	if(is_admin() || is_feed()){return;}
    	$opt = get_option('wpdt_options');
    	$deps = array();
    	if($opt['animate']){
    		wp_deregister_script('jquery');
    		wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
    		wp_enqueue_script('jquery', '', array(), '1.4.2', true);
    		$deps = array('jquery');

    You can see that if the animation option is true (selected), the plugin will deregister, reregister, and enqueue jquery. What the original developer or Ulf may not have taken into account is that if the end-user is using enqueue for their other scripts (and they SHOULD be), this version will always take precedence.

    The way to handle it is to simply enqueue jQuery, full-stop. I imagine there could theoretically be an ‘if’ statement somewhere that tests for jQuery first, but I think that would be a waste of cycles since jQuery is already enqueued to the ‘internal’ version, and the place to deregister and re-register it is typically in functions.php. In other words, someone has to actually go out of their way to have no jQuery, in which case they’re probably not using the animate function of this plugin anyhow.

    I can’t claim to be an enqueue expert, so I’m not sure if there’s any value in passing the optional parameters, either, so I’m only passing it the ‘jquery’ handle for enqueuing.

    The resulting code should simply be this:

    function wpdt_js() {
    	if(is_admin() || is_feed()){return;}
    	$opt = get_option('wpdt_options');
    	$deps = array();
    	if($opt['animate']){
    		wp_enqueue_script('jquery');
    		$deps = array('jquery');

    Hope this helps somebody some day. ??

    Yes, you helped me!

    I also had this issue. I couldn’t use another plugin while this was enabled.

    I made the tweak you suggested above, keeping the other variables, and everything works now.

    Awesome, thank you monkey. Also, I had been in contact with Ulf about a different issue with his plugin (active post highlighting) and he was responsive. So, I sent him this link.

    Thanks again,

    Plugin Author ulfben

    (@ulfben)

    It’s weird how this thread never appeared on the plugin page! Sorry about that.

    I’m aware of the problems of forcing the Google CDN on people – the correct behaviour is of course be to let users register this preference themselves through their functions.php.

    So yeah – this has been adressed and is fixed in the next release.

    EDIT. seems like tags are case sensitive? WP-dTree != wp-dtree according to www.ads-software.com forums.

    Thread Starter monkeyhouse

    (@monkeyhouse)

    citizenchan: glad to have helped!

    ulf: the forum itself has some answerin’ to do. ??

    Ulf,

    The plugin page is called wp-dtree-30 so when we tag the post with a new version number it will not show up on the plugin page.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: WP-dTree] Breaks proper script enqueue’ is closed to new replies.