WordPress.org

Ready to get started?Download WordPress

Forums

YAK for WordPress
fix jquery-tools dependence (patch proposed) (7 posts)

  1. schleusse
    Member
    Posted 1 year ago #

    Hi,
    Currently, YAK causes jQuery Tools to be loaded on all WP admin pages, thereby breaking an important Drag & Drop functionality in NextGEN gallery.

    I have temporarily solved this problem by replacing the line 1420 in yak-for-wordpress.php, which was

    wp_enqueue_script('jquery-tools', "$yakurl/jquery.tools.min.js");

    by

    $url = $_SERVER["REQUEST_URI"];
    if (yak_str_contains($url, 'yak'))
    {
    wp_enqueue_script('jquery-tools', "$yakurl/jquery.tools.min.js", null, null);
    }

    One can certainly do better, i.e. do the same for other files that need to be loaded only when visiting the YAK settings pages, or provide a better way of checking whether we are on the YAK settings page.

    Note that I also changed the wp_enqueue_script line, because with the old line, WordPress would append its version string to the jquery.tools.min.js file, such that it could not be found anymore.

    http://wordpress.org/extend/plugins/yak-for-wordpress/

  2. schleusse
    Member
    Posted 1 year ago #

    By the way, thanks for this great plugin!

  3. nolongeractive
    Member
    Plugin Author

    Posted 1 year ago #

    Which version of YAK are you using? Because this check has been in place for quite a while -- the logic is arguably in the wrong place (it's in yak-admin.php, rather than yak-for-wordpress), but it's working as expected (I just double-checked).

    jquery.tools.min.js is currently loaded on all YAK admin pages, and also on the edit/add post pages - but nothing else. If the NextGEN drag-and-drop functionality is on the edit/add screens, I guess that's why it's failing.

    That said, I can't think of anything I use in jquery tools on the edit post, so perhaps that was overkill. Let me know and I'll amend the code accordingly.

  4. schleusse
    Member
    Posted 1 year ago #

    Thanks for the quick reply. I use YAK 3.4.8.

    jquery tools is loaded on many more WP admin pages than those you mention, among them the NextGEN settings pages. The reason is the check at line 1034 of yak-admin.php

    $url = $_SERVER["REQUEST_URI"];
    if (yak_str_contains($_REQUEST['page'], 'yak') || yak_str_contains($url, 'post') || yak_str_contains($url, 'page'))

    It lets through requests such as

    http://mysite/wp-admin/admin.php?page=nextgen-gallery

    presumably because they contain the string "page" (are the GET parameters included in the URI? )

    Maybe you want to check for the string "post_type=page" instead.

    If would be nice by the way to be able to specify the (custom) post types where the YAK interface is loaded.

    Thanks and keep up the good work!

  5. nolongeractive
    Member
    Plugin Author

    Posted 1 year ago #

    Ah good point. Not sure why I didn't see that when testing. Will update for the next release.

  6. schleusse
    Member
    Posted 1 year ago #

    Cool, that's great.

    Maybe you didn't see it because of different implementations of the $_SERVER variable? (I am new to PHP, I don't know about it)

    Please also add then the two null parameters to the wp_enqueue_script function. Although it seems to me that even without them the inclusion of jtools used to work at some point, it currently does not on my system, which is the behaviour predicted by the wp_enqueue_script documentation.

    Will you also add support for choosing the custom post types where the YAK interface is loaded? I could help you on this if you wish.

    I would also be happy to have a look at your changes before you release the new version.

  7. nolongeractive
    Member
    Plugin Author

    Posted 1 year ago #

    This should be fixed in the latest release btw.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.