As a follow up from this, I’ve tested by changing my theme to stop loading JS at the footer, and just enqueuing it standard out of the box, and the plugin works.
So your raw output of <script> tag that sets all of the options, is just being echoed out on the page, and not making use of wp_add_inline_script Which is what you should be using, as you can then always follow the initial jQuery enqueue call.
I shouldn’t have to revert my theme code to a really simple way of loading in order for this to work. Can you please change your plugin so it correctly enqueues?
By default, WordPress enqueues jQuery in the
<head> if your theme does not, then it’s been altered, and would be incompatible.
Therefore what I’m doing with this plugin works perfectly fine. Tested with WP 2021 Theme and others. See https://i.stack.imgur.com/wKNh3.gif for an example.
I’m currently using this plugin on at least 25 sites that I’ve developed. Additionally, with over 2000 installs, there doesn’t seem to be issues for them.
The reason that I’m not doing as you suggest is because you can’t do that with a shortcode output. By having each script inline (which they wait for jQuery to be fully loaded before running) – it allows users to include multiple carousels on a single page.
So, I’m not going to make changes to this free plugin for one instance where it doesn’t work. Sorry.
This reply was modified 1 year, 6 months ago by thehowarde.
By default, WordPress enqueues jQuery in the <head> if your theme does not, then it’s been altered, and would be incompatible.
My theme has not been altered, it’s been developed… by me. I created my theme from scratch. I’ve used the WordPress Developer docs correctly, and have utilised features that are on there to adjust for example the placement of the loading of scripts.
Nothing that I’m doing is by any means incorrect usage. The fact that your plugin works with out of the box stuff is irrelevant. I’m telling you that your plugin doesn’t work correctly because you’re not correctly enqueuing your inline script, or else this wouldn’t be an issue.
There is nothing wrong with what I’m doing, and your plugin should be able to work with this, but it doesn’t because you are hard coding echoing out to the page (which is very bad practice).
What you should be doing is re-working your plugin code so that it correctly loads all of it’s assets (CSS and JS) using the enqueue methods, or you will find that many others will have issues using plugins that optimise the loading of assets, or any other optimisation tools (as these all work on the basis that plugins utilise the correct enqueue procedures).
The fact you are refusing to do anything proves to me that you are not a confident WordPress developer, and perhaps do not understand enough about the WordPress ecosystem to be bothered enough to fix your plugin.
I think I’ll just uninstall it then if this is how you think you should be programming.
Note: I discourage anyone from using this plugin now.
The fact that I’m not willing to do anything is because I’m too busy, and quite frankly, you’re wrong.
Plugins aren’t designed to be custom crafted code to suit each fringe case. Plugins are supposed to work with WordPress out of the box… which my plugin does.
If you don’t want to use my plugin, oh well.
I’m sorry, but you are wrong. Plugins should be created so that the widely available features to every developer, still work.
You cannot just output hard coded script to a page, this should never be done in WordPress.
I’ve now given you a two star rating because of your attitude, and will be vocally discouraging the use of your plugin.
PS for anyone reading this: This issue is not resolved, and never will be apparently.
Oh no… You’re going to ruin my day.
@leecollings If you want to make a pull request – the code is hosted in github as well. However, you’ll probably find that you can’t do what you’re suggesting… but knock yourself out.
I don’t need a lecture on how to develop in WordPress. WordPress plugins are by design – made to work with default installations of WordPress. If you’re after custom development, you can hire me. I’ll do what you want.
As for free plugins, developers aren’t required to modify their free plugin to suit the need of one user who developed his own theme, that may or may not conform to WordPress standards.
I have nothing more to say here… Have a nice day.