Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
public-topic
Where to place enqueue scripts?
Avatar
Timothy Burton
Member
sp_UserOfflineSmall Offline
Jul 15, 2015 - 11:26 am
sp_QuotePost Quote

I know support is for members, but I've subscribed a couple times already in the past just to download plugins, and I think this is my first support question ever, so hopefully you all can point me in the right direction. 

I'm not super savvy with WordPress so bear with me. I'm trying to enqueue a script into my wordpress site. I figured out how to do this last night, and it works on the site. 

However, it doesn't work on our forums, which is where I need the script to work. I'm assuming the script needs to be enqueued in the SP plugins itself, but I have no idea where. I tried sticking it in various places in the SP phps, but you can probably guess it just broke things. 

I just need to know the proper way to enqueue scripts into SP. 

Thanks. Btw love SP. I swear by it. People even wanted me to use other forums on my site like vbulletin, but I defend my choice in SP every time! 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 15, 2015 - 4:59 pm
sp_QuotePost Quote

Which version of SP are you currently using?

andy-signature.png
YELLOW
SWORDFISH
Avatar
Timothy Burton
Member
sp_UserOfflineSmall Offline
Jul 15, 2015 - 5:52 pm
sp_QuotePost Quote

Version 5.5.8

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 15, 2015 - 6:48 pm
sp_QuotePost Quote

do you know how to use WordPress action hooks? If you ONLY want your script to run on the page the forum displays on then you can use our hook.

Create a an empty php file called 'sp-user-functions.php' and place it in the wp-content folder.

Then use the action - 'sph_scripts_end' - which we define after the SP scripts are enqueued. This action hook passes one argument which is true if the scripts are to be loaded on the footer or else false if header.

The beauty of the file in wp-content is that we or anything else will never try and update or change it so it is future-proof. It was introduced in 5.5.8.

Hope that helps.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Timothy Burton
Member
sp_UserOfflineSmall Offline
Jul 15, 2015 - 10:17 pm
sp_QuotePost Quote

Thank you very much! That worked just fine. However, and this is my fault, but I couldn't get it to work initially. Basically my scripts allow users to utilize bbcode to add special links in their posts that create tooltip popups when mousing over them. Well, I had my profile set to use rich text editor and not bbcode, so it kept reformatting my bbcode, lol!

Anyways, thanks for the help! It works now.

You can see it in action, if you like =D

Just mouse over the text. Cheers!

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 15, 2015 - 10:36 pm
sp_QuotePost Quote

Glad to hear all is working!

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626