ThemeForest

Question to WP plugin developers from WP plugin developer

21 posts
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 1-2 years
  • Russian Federation
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Exclusive Author
Yatek says

Hello WP plugin developers,

How do you deal with jQuery?

Normally any plugin / theme have to check if jQuery was already included and include it’s own “jquery.js” only if newer version is required ( but first call wp_deregister_script(‘jquery’); )

In real life there are too many poorly written plugins / themes which doesn’t do any checks and just throw in their own “jquery.js” which causes conflicts.

So what is the best way to deal with that when you create a WP plugin which uses 10 jQuery plugins which depend on jQuery, let’s say 1.7.2.

I know about $my_jQuery = jQuery.noConflict(); method but it isn’t too useful when you have 10 jQuery 3rd party plugins used by your WP plugin. Each is wrapped into function($) ... (jQuery) so they won’t work with $my_jQuery. I don’t want to edit all 3rd party plugins changing them to function($) ... ($my_jQuery) I hope you understand this.

687 posts
  • Sold between 5 000 and 10 000 dollars
  • Exclusive Author
  • Croatia
  • Bought between 10 and 49 items
  • Has been a member for 1-2 years
OriginalEXE says

If a client is using fault plugins, that is their fault and not yours. I never include jQuery as WordPress loads it by default. If for some reason things don’t work, then you know it’s not your fault but of 3rd party.

You can’t (and shouldn’t) fix others mistakes.

362 posts
  • Elite Author
  • Author had a File in an Envato Bundle
  • Microlancer Beta Tester
  • Exclusive Author
  • Most Wanted Bounty Winner
  • Attended a Community Meetup
  • Bought between 100 and 499 items
+4 more
RightHere says

@Yatek it is definitely a bad idea to include your own jQuery or force the use of a specific version. As OriginalEXE says WordPress includes its own jQuery.

This is one of the most common errors we experience with plugins and themes. Whether you want to help your client and fix the error, so your plugin works is up to you!

We do help our customers even though the error is not in our plugin ;)

21 posts
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 1-2 years
  • Russian Federation
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Exclusive Author
Yatek says

thanks @OriginalEXE & @RightHere :) Good points you made

278 posts
  • Microlancer Beta Tester
  • Bought between 10 and 49 items
  • Sold between 1 000 and 5 000 dollars
  • Europe
  • Has been a member for 0-1 years
  • Exclusive Author
greenline says
I have the same problem. In my plugin, do I have to include the default jquery loaded by wordpress or not? Like below:
wp_deregister_script('jquery');

Because I know Wordpress includes jquery only from version 3.5….So what about the old wordpress versions? I want to make my plugin campatible with older versions too.

Please if someone knows the correct way the jquery without interfering with theme’s jquery …please let me know.

1763 posts
  • Microlancer Beta Tester
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Austria
  • Exclusive Author
  • Referred between 200 and 499 users
+2 more
revaxarts says
I’ve added a filter so peaople can remove the jQuery verison if it’S already there:
wp_register_script('mymail-form', MYMAIL_URI . '/assets/js/form.js', apply_filters('mymail_no_jquery', array('jquery')), MYMAIL_VERSION, true);
this way you can
function my_remove_jquery(){
   return array ();
}
add_filter('mymail_no_jquery', 'my_remove_jquery');
This doesn’t help if the falsely used jQuery version is below your required version
59 posts
  • Exclusive Author
  • Has been a member for 1-2 years
  • Referred between 100 and 199 users
  • Sold between 10 000 and 50 000 dollars
ichurakov says
I always use only WP native jQuery:
wp_enqueue_script("jquery");
278 posts
  • Microlancer Beta Tester
  • Bought between 10 and 49 items
  • Sold between 1 000 and 5 000 dollars
  • Europe
  • Has been a member for 0-1 years
  • Exclusive Author
greenline says

I always use only WP native jQuery:
wp_enqueue_script("jquery");
I also used that, but I have a soft rejected item. One of the issues specified in the rejection email is
Please do not deregister or ignore the default version of jQuery being used by the theme and load a custom version.

So what shoud I do to make it the correct way?

212 posts
  • Has been a member for 0-1 years
  • Exclusive Author
  • Microlancer Beta Tester
  • Sold between 5 000 and 10 000 dollars
  • India
  • Bought between 1 and 9 items
nCrafts says

I am not sure it’s a good idea to rely on WP for jQuery. As someone pointed out, WP loads jQuery by default only after a certain version.

I deregister jQuery and then enqueue it.
As far as noconflict is concerned, I use jQuery.noConflict(); and then use jQuery(’#id’) instead of $(’#id’)
I like this thread. I really hope we can come up with an ideal standard.

278 posts
  • Microlancer Beta Tester
  • Bought between 10 and 49 items
  • Sold between 1 000 and 5 000 dollars
  • Europe
  • Has been a member for 0-1 years
  • Exclusive Author
greenline says

Thanks for the answers… But is there any developer online who used a correct include in a plugin which was accepted on CC? Can he/she please tell us the exact way of doing this? I am still confused how should I include the jquery js at the begiing of my plugin withour breaking other plugins or the theme. Thanks

by
by
by
by
by