Hi,
OK I have one theme options panel in my WP dashboard.
Now from this admin section I want to save data in CSS and JS file.
Let say I have a slider options whose slide timings are coming from its JS file. Now from the WP dashboard I want to edit and save time (say 3sec) in the JS file…
Can anybody please give me a direction or a idea on how to achieve it. I am not asking for a full tutorial but a direction or some concepts.
It is a bad idea to save into theme files, and there is no real need to do it. If you need to add some JS/CSS that depends on settings, you should embed it into HTML.
This is could be done by many and many ways, Will give you some ideas on how that could be done:
lets start with the js data:
1- you could use the wordpress function wp_localize_script this function adds a global variable in your footer or your header and then in your js file you could use this variable.search for it and you will see many tutorials.
2- you can save your js data using normal html attributes for example in your wp dashboard you have a custom option to change slider time i will call this option my_slider_time and of course you have a custom html div for your slider in that div add html5 attribute in this way <div class="slider-holder" data-slider-time="<? echo my_slider_time ?>">
now in your js file get this attribute by using the jquery function data example: $( "div.slider-holder" ).data( "slider-time" )