wordpress wp_enqueue_script() not working

You need to be hooking the function that calls the enqueue, personally I actually like to register scripts and enqueue them separately, rather than just enqueueing them, as it allows the flexibilty to enqueue conditionally and can save keystrokes down the line at little to no performance penalty. The code you are going to need … Read more

How do I Import / Upload Files with jQuery AJAX?

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

how to make my website secured

It may possible that he is trying to hack. I am sure you are storing form data after escaping/sanitizing the content which eliminate the risk of Sql injection and since user can submit empty form it mean you haven done the server side validation. what you need to check is First check that weather field … Read more

Why isn’t wp_enqueue_script(‘jquery-masonry’) working?

jQuery’s Masonry is bundled with WordPress. All you should need is wp_enqueue_script(‘jquery-masonry’); but note that the “slug” is jquery-masonry, not jquery_masonry. And be sure your are enqueueing on the wp_enqueue_scripts hook or later. function enqueue_masonry() { wp_enqueue_script(‘jquery-masonry’); } add_action(‘wp_enqueue_scripts’,’enqueue_masonry’); I’d guess that your problem has something to do with when you register/enqueue because loading core … Read more

Call a javascript function from another file

The issue you have is that Slider is not accessible outside of its scope as that’s defined by the .ready() though you’ve used shorthand for that. The function needs to be available in the global scope: file1.js function Slider() { this.nb_ele = 10; } jQuery(function($) { // … }); file2.js jQuery(function($) { var slider = … Read more

How can I remove the WordPress-Version (?ver=5.x) from my plugin

Change the 4th parameter from false to null. wp_enqueue_script( ‘myID’, $url, array( ‘jquery’ ), null, true ); From the wp_enqueue_script() documentation: $ver (string|bool|null) (Optional) String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version … Read more

Plugin – Make sure jquery is loaded in my settings page plus my JS file

First use add_options_page() – shorter wrapper, better practice. Second you need to save its return in some (global or static) variable. That is often used thingie and confusingly referenced by different names in documentation. Global $hook_suffix holds such value for current page. function create_admin_pages() { global $my_page; $my_page = add_options_page(… From there it is something … Read more