How to wp_enqueue_script jQuery inside a Plugin
jQuery is included in noConflict mode in WordPress, so you can’t use the shorthand $, but must write jQuery(this).html(jQuery(this).html().replace(rx, ‘<b>$&</b>’));
jQuery is included in noConflict mode in WordPress, so you can’t use the shorthand $, but must write jQuery(this).html(jQuery(this).html().replace(rx, ‘<b>$&</b>’));
Try and call method `prettyPhoto’ when DOM is ready, replace your code: jQuery.noConflict() jQuery(function(){ jQuery(“a[rel^=’prettyPhoto’]”).prettyPhoto(); }); with this: jQuery(document).ready(function($) { $(“a[rel^=’prettyPhoto’]”).prettyPhoto(); }); Also ‘Paid Downloads’ plugins enqueues latest version of jQuery used by WordPress it’s 1.6.1, it would be better if you register same version of jQuery from Google-CDN as WordPress does
On the front end (i.e. in a Theme) don’t enqueue jQuery or jQuery UI unless you actually need to use either of them. On the back end (i.e. in the Admin area), both will already be enqueued, since core uses them. Whatever the case, if you use a core-bundled script, you should always use the … Read more
If all three plugins load jQuery properly using wp_enqueue_script(“jquery”) then only one copy of jquery will be used. If you are seeing three copies then some plugins are not playing nice.
You really shouldn’t do it, it’s not a good practice. You should always use the jQuery version supplied with WordPress package. If you use your own jQuery version in your own file you would have to update it manually every time the jQuery gets updated in WordPress package. If you really insist on doing that, … Read more
I haven’t tried but i think you need to add FormData object directly as data parameter. Something like this var ajaxData = new FormData(); ajaxData.append( ‘action’, ‘ajax_handler_import’ ); ajaxData.append( ‘_ajax_nonce’, importNonce ); // or maybe skip the nonce for now jQuery.each($(‘#fileImportData’)[0].files, function(i, file) { ajaxData.append(‘file-‘+i, file); }); The rest of your code goes as it … Read more
First, don’t unregister and reregister jQuery. There’s no reason to do that at all. Second, you’re enqueuing on the wrong hook. Instead, use this in your functions file: // Enqueue Scripts function wpse78227_enqueue_scripts() { wp_enqueue_script( ‘jquery’ ); } add_action( ‘wp_enqueue_scripts’, ‘wpse78227_enqueue_scripts’ ); Now, to include that script you need to do a couple of things. … Read more
Your Theme is enqueueing jQuery 1.7.2: <script type=”text/javascript” src=”http://dayfun.ir/wp-content/themes/Sparks/lib/js/jquery.min.1.7.2.js”></script> And WordPress is enqueueing jQuery 1.8.3: <script type=”text/javascript” src=”http://dayfun.ir/wp-includes/js/jquery/jquery.js?ver=1.8.3″></script> See also, Frank’s answer regarding jQuery no-conflict mode. Edit WordPress bundles a version of jQuery. You will inevitably encounter problems if your Theme (or a Plugin) enqueues a separate version of jQuery – whether by enqueueing that … Read more
The post editor is really not meant for inserting functional code like JavaScript into the page. Anything you put through the post editor will get run through wpautop() before output, which is what adds the paragraph tags — even if you enter it via the Text mode. I’d suggest outputting your JavaScript via a hook … Read more
The Good Answer The only good answer to this question is don’t do it – simple as that. Software in general expect things to work certain ways and libraries that are constantly evolving can have breaking changes. That means the change will cause another piece of software to stop working correctly which may be limited … Read more