Right now, I’m able to dynamically generate js and css, based on my theme options
To do that i set up a query var, that if present redirects to a php file, which then loads itself as a javascript file. Afterwhich it then takes the jqpostID, and and grabs any options i need to generate my js.
I basically have to include a script link that references a location portion of my html http://mywordpress.com/?dynamic=js&jqpostid=130
I’d like to make it more readable, and less apparent that it is being dynamically generated. maybe like this…
http://mywordpress.com/dynamic/js/123
i suppose this would even be better…
http://mywordpress.com/dynamic/js/123.js
I figure i have to hook into the rewrite engine of wordpress somehow. And add a new rule. Any help, or references to other articles would be great, or some sample code would be awesome.
adding these functions should do the trick.
First things first, add this line to functions.php while you are working on this:
What that code will do is constantly flush the rewrite rules, it makes this easier to test while you are working on it, instead of having to go in and manually reset them after every little change you make to the rewrite rules.
MAKE SURE you remove this when you are done and satisfied that everything is working.
Next, this function will create the rewrite rules you want.
I took a stab at what maybe the CSS rule would look like as well, you may have to adjust it for your needs, I just figured it would be formatted in a way similar to what you described for the javascript. These may cause some strange behavior when it tries to rewrite the URL into a file extension, and it may not work at all. In that case, just remove the .js and .css from the end of the first part of the associative array entries.
Basically all this does is sets up the URL to look for and the string it runs in its place. The first part of the array entry has a regular expression that looks for numbers only, the portion in parenthesis. (this can be adjusted to look for a specific number of digits, if needed) The match of which is passed into the second part of the array entry as what will be returned in the string.
I hope this helps you, feel free to contact me if you have any problems.