I'm trying to add custom CSS (set via theme options) to the TinyMCE visual editor in WordPress. On the front end, the theme generates this CSS and outputs it on the wp_head
hook. The problem I'm running into is being able to add that CSS output to the editor.
This can't be done with add_editor_style( 'editor-style.css' )
because we need to use PHP to access the theme option.
As an example of how it works on the front end:
add_action( 'wp_head', 'my_custom_colors' );
function my_custom_colors() {
$color_1 = get_theme_mod( 'color_1', 'cc4a00' );
echo "<style type='text/css'>a { color: #{$color_1}; }";
}
I need a method for getting that custom style into the visual editor. Any help would be greatly appreciated.
editor-style.css
, which is theme territory.