• In selection-sharer.php the script get’s added with

    wp_enqueue_script( 'selection-sharer-js', plugins_url('/js/selection-sharer.js', __FILE__), false, '0.1');

    But it has jQuery as a dependency so it should be

    wp_enqueue_script( 'selection-sharer-js', plugins_url('/js/selection-sharer.js', __FILE__), array('jquery'), '0.1');

    Also, the init script does get added right after and ignores the jQuery dependency. In my case this lead to the line being added before jQuery was loaded. An undefined error was thrown. I managed to modify the plugin to make it work in my case but this should really be fixed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author jcvangent

    (@jcvangent)

    Hey @mxmtsk,

    thanks for the remarks, will make a small update around this and update it with the code you supplied here.

    Does that undefined error still happen when you change this line?

    Thread Starter mxmtsk

    (@mxmtsk)

    Hi @jcvangent,

    for the script it resolves the error yes, but the line below where you simple echo the initialization does not work. You would need to add the line

    jQuery(document).ready(function ($) { $('p').selectionSharer();});

    to the plugins JS file (seems a bit dirty for me but I could live with it) or in a new file (another request, not very efficient) or find a way to print inline script that is aware of the dependency. I’m not sure that there is a method for this in WordPress.

    I removed the line and put it in my own custom js file but that is of course not applicable for normal users. I would go with the first solution.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin does ignore jQuery dependency’ is closed to new replies.