1

I've done some searching and can't seem to find the appropriate solution for a particular problem I'm having. I've created an option within one of my themes that allows the user to edit any element such as h1, p, divs, etc. The user can also add styling and I basically just build up a string of identifiers and the styling that the user has chosen.

What's the best way to load this css string? Is it best to just have it as a function call before , or should I programmatically create a 'custom.css' file that then gets enqueued after 'style.css'? I worry about creating a 'custom.css' file just in case permissions become an issue.

1

Well one option you could do, is wrap them in style tag and stuff them into the header via a filter. It's dirty, but it would work. I'd honestly do that, over forcing inline styling on elements, because they won't get cached. Plus anyone who wants to do their own styling to override those elements will hate you.

The cleanest way WOULD be in fact to create a custom.css file dynamically. File Permissions shouldn't be an issue within a theme or plugin environment in MOST installs, however in cases where it is, you can issue a warning to the site admin about it. If you opt for this route, you could do a file permissions check before hand, and default to one of the other methods in the event you don't have adequate permissions. That'd be the most fail-safe way of doing it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.