• cyb2org3

    (@cyb2org3)


    Hi there,

    I’m trying to add Styles to the Editor but is not Working:

    I’ve Version WordPress 5.2 active.

    I tryed with adding to function.php the following:

    / Callback function to insert 'styleselect' into the $buttons array
    function my_mce_buttons_2( $buttons ) {
    	array_unshift( $buttons, 'styleselect' );
    	return $buttons;
    }
    // Register our callback to the appropriate filter
    add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );
    
    // Callback function to filter the MCE settings
    function my_mce_before_init_insert_formats( $init_array ) {  
    	// Define the style_formats array
    	$style_formats = array(  
    		// Each array child is a format with it's own settings
    		array(  
    			'title' => '.translation',  
    			'block' => 'blockquote',  
    			'classes' => 'translation',
    			'wrapper' => true,
    		)
    	);  
    	// Insert the array, JSON ENCODED, into 'style_formats'
    	$init_array['style_formats'] = wp_json_encode( $style_formats );  
    	
    	return $init_array;  
      
    } 
    // Attach callback to 'tiny_mce_before_init' 
    add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Adding Style to Editor is not working’ is closed to new replies.