How WordPress devs deal with inline styles ?

Hello,
In my themes developed with Unyson, I have a ‘Menu’ shortcode. It has options to add custom colors and typography to menu which is being added using this shortcode.
The problem is that I need somehow to enqueue custom css which is created when user adds custom colors or typography to this menu.
Using wp_add_inline_style seems to fail, because wp_head action is being called BEFORE actual menu is generated and shortcode options are read to generate css.
Creating a < style > tag right after menu is rendered used to do the job, but it is not allowed, explaining situation to reviewers did not help. (strange, because most of themes with page builder add inline styles in this way)
How should I handle inline styles in this situation ?


Fixed, just had to create a function that takes some css as parameter, adds it via wp_add_inline_style. Just had to remove a hook to wp_enqueue_scripts, tagging to same function.
Closed.

1 Like