Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
I need to intercept the scripts that are added in the footer and head through the wp_footer()
and wp_head()
functions, something like add_filter('wp_footer', my_function)
and then in my_function
, I would check the name of the registered script and then perform an action, in that case would read the contents of the script.js
file and insert it inline, something like this:
Before intercept (this is showing on footer or head):
script type="text/javascript" src="mywp/wp-content/plugins/plugin-name/script.js"
After intercept, I want to show inline script like this:
script
// this is content of plugin script.js or other intercepted scripts...
var content_is_here = ....
function() {
// content inline etc
...
}
/script
Is possible do this? On intercepting, i need name of script and path to read the content and insert inline, this I know how to do, but I don't have idea of how to intercept scripts...
If is possible to intercept CSS files too would be very good!
Thanks in advance!
Topic request-filter wp-query php plugins Wordpress javascript
Category Web