We include the version for the same reason as before so that the user’s cache can be cleared if we update the stylesheet. We have a unique handle, the URL to the stylesheet, dependencies (in this case we have none), and the version of the stylesheet. Settings for this function are similar to wp_register_script. Stylesheets can easily be added using wp_enqueue_style. We use this so that other plugins or the site owner can remove our script if they want to without having to touch our plugin’s code. The wp_enqueue_script() function is what allows WordPress to process your script and output it where it is needed. In Footer: This indicates whether or not our script is loaded in the footer.If you leave this off, a user’s browser could have the old version cached, and may not see the changes until they clear their cache. If you ever update the plugin and change the contents of your script.js file, you can increment the version number (1.1, 2.0, or whatever) to force browsers to fetch a new version of the file. The version number helps with caching the script file.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |