I am creating a Wordpress plugin.
I created the basis for this, and everything is set up correctly.
I tried looking at this and this to find out if I can request and get all the scripts (.js files) from the header and footer.
I thought this was the best feature, but the result is not happening correctly.
I basically want to get JS and CSS files and replace with another line.
So let this be my page:
<!DOCTYPE html> <html> <head> <title>Page</title> <link rel="stylesheet" href="http://www.example.com/mycss.css" /> </head> <body> <script type="text/javascript" src="http://www.example.com/myscript.js"></script> <script type="text/javascript" src="http://www.example.com/another_script.js"></script> </body> </html>
My function should look for .css and .js files and replace the string with others. To get the result:
<!DOCTYPE html> <html> <head> <title>Page</title> <mytag>Here was contained a CSS from http://www.example.com/mycss.css</mytag> </head> <body> <mytag>Here were contained 2 JS from http://www.example.com/myscript.js and http://www.example.com/another_script.js</mytag> </body> </html>
EDIT I really need to get a name and path for these files.
I think I can use a regex, but I donβt know how to load it with get_header and get_footer (if these are the correct functions)
source share