This post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.
jQuery itself is automatically loaded by ClassicPress so we don’t need to do anything to load this ourselves in a plugin; it is just our own jQuery script which we need to register and enqueue. There is two ways in which scripts can be loaded in a plugin; I will cover them both, but will note first of all that I typically use the second approach; there is an argument that the first approach is the “correct” one.
The first thing to do when you are loading a script is to register it. This is done using the
wp_register_script function which ClassicPress provides.
wp_register_script(string $handle, string|bool $src, string $deps = array(), string|bool|null $ver = false, bool $in_footer = false)