As I told in an earlier question is have a theme with hundreds of mods, which I gather in one mod so I don't have to loop through all mods at every pageload.
Now, the codex has you dump customizer styles directly in the head, which isn't very elegant. There is
wp_add_inline_style to add css in an orderly way to an existing style sheet. This looks like this and it works fine:
$style = get_theme_mod ('all-mods'); wp_add_inline_style ('my-main-style',$style);
There's one problem, however. If I build a child theme, the inline styles are still added directly after the parent styles. This causes them to be overruled by the child theme css, which is loaded after the parent's to make sure it overrides those styles. This is not what the user expects.
The customizer styles should have the highest priority, so in some way I must make sure they are the last ones to be loaded in the head. I can detect if there's a child theme active, but cannot know the handle of the child style to add the inline styles to it.
At this moment I have simply defined an empty css file, which I enqueue right at the end of the head, and then add the inline styles. But this is far from elegant, which is why I took this path in the first place. Does anybody know of a smarter approach?