• Resolved welshhuw

    (@welshhuw)


    Hi,

    I have setup some custom tinymce formats, one of which is for White Text. The design of the theme requires some sections to have white text on top of a coloured background. The issue with this is that when in the visual editor(page, post etc), once the text has been selected as white, it can no longer be seen because the background is also white in the editor.

    Is there a way to declare a coloured highlight, once the text has been selected as White Text; and for this highlight to only show up in the editor and not on the front end?

    Here’s my code:

    add_filter( 'tiny_mce_before_init', 'fb_mce_before_init' );
        function fb_mce_before_init( $settings ) {
    
    $style_formats = array(
        		array(
        			'title' => 'White Text',
        			'inline' => 'span',
        			'styles' => array(
        				'color' => '#ffffff'
        			)
        		)
    );
    
        $settings['style_formats'] = json_encode( $style_formats );
        return $settings;
    }

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • To make this work, I would assign a CSS class to the ‘White Text’ style, then use either WordPress’s Editor Style feature or TinyMCE’s content_css option to load in a custom stylesheet for styles within the editor itself.

    Edit:
    This page gives some examples which include applying classes to TinyMCE custom styles.

    Thread Starter welshhuw

    (@welshhuw)

    Resolved…. So simple but you know how it goes once your 3 weeks deep into a project!

    Thanks again James.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘White text in Editor: Client Request’ is closed to new replies.