I am working on a theme that uses dynamic in head CSS and gives admin an option to also place the same in a file. Problem is that I am not sure what WP folder is always writable. I originally added the CSS file creation to themename/css/ dir but since WP deletes the theme on update this has become an issue.

What do you think is the best way to approach this and what is the safest writable WP folder that I could use for this feature?

4 s
4

Best place is the uploads directory – it’ll be writable by the server, and it’s the defacto directory for storing any user-generated/uploaded files:

$dirs = wp_upload_dir();
$path = $dirs['basedir']; // /path/to/wordpress/wp-content/uploads

Leave a Reply

Your email address will not be published. Required fields are marked *