I’m dealing with an SSL issue and I would like to strip the domain from all scripts and styles being output via wp_enqueue_scripts. This would result in all scripts and styles being displayed with a relative path from the domain root.
I imagine there is a hook that I can use to fileter this, however, I am not sure which one, nor how to go about it.
Similar to Wyck’s answer, but using str_replace instead of regex.
script_loader_src
andstyle_loader_src
are the hooks you want.You could also start the script/style URLs with a double slash
//
(a “network path reference“). Which might be safer (?): still has the full path, but uses the scheme/protocol of the current page.Yes, i think its possible. See on the filter hook
script_loader_src
; there get the string and you can filter this for your requirements.The same is possible for stylesheets, ther load via
wp_enqueue_style
with filterstyle_loader_src
.Another way, which I think I got from the roots theme, maybe a bit ghetto but has some smart handling on when to use relative urls (tested only on dev site). The benefit is it can be uses as a filter on many other built in urls that WordPress uses. This example only shows style and script enqueue filter.