WPIntell

Source evidence

Plugin does ignore jQuery dependency

Selection Sharer by Hans van Gent · support · 2017-03-19T22:44:00+00:00

complaintsentiment
mediumseverity
0.8relevance
2replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 31 rows with source links

16.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

26 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
mxmtsk unresolved
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. 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? 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.

Comments

2 shown
jcvangent 2017-03-20T09:34:00+00:00

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?

mxmtsk 2017-03-20T10:44:00+00:00

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.