seagyn / the-social-links

A basic WordPress plugin that adds social icons with links to your social profiles.
GNU General Public License v2.0
5 stars 3 forks source link

Fix asset enqueuing #32

Closed jbboynton closed 2 years ago

jbboynton commented 3 years ago

Enqueue assets on the front end. It looks like this bug was introduced in the 2.0 release. Prior to the version bump, [assets were being enqueued] from the admin_init and init hooks. However, after the update, front end assets were no longer being enqueued.

This commit reimplements the original behavior so that assets are enqueued on the front end. Additionally, this commit prefixes style and script handles with tsl, and moves a bit of JavaScript out of a template and into a dedicated file. In general, I tried to make everything related to asset enqueuing as conventional and as possible.

seagyn commented 2 years ago

@jbboynton so the enqueueing happens when the links are displayed. I missed it on the template tag but here is an example on the shortcode: https://github.com/seagyn/the-social-links/blob/0c310e9ad38c958d9f37afec6d3c010f2c118918/src/boot.php#L66

The main idea is to limit loading assets to only pages that require it. I'll explore it a bit more and see if I can fix it.