• Resolved Justin Tadlock

    (@greenshady)


    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' ). It’s output via PHP.

    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 inserting that into the visual editor. Any help would be greatly appreciated.

Viewing 2 replies - 16 through 17 (of 17 total)
  • OriginalEXE

    (@originalexe)

    Awesome, the solution you went with is really smart way, no js needed (looks like I was wrong).

    Thread Starter Justin Tadlock

    (@greenshady)

    Just letting everyone that saw this thread that the solution is posted on the WPSE link above. Thanks for the feedback and help.

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Custom/Dynamic CSS in TinyMCE’ is closed to new replies.