Support

Account

Home Forums General Issues Create a new WYSIWYG toolbar

Helping

Create a new WYSIWYG toolbar

  • I’ve been trying to follow all tutorials with no success. I simply want to create a new WYSIWYG toolbar. The code I have put in the mu-plugin below, brings back the full toolbar instead of creating my simple toolbar. What’s wrong?

    <?php
    
    add_filter( 'acf/fields/wysiwyg/toolbars' , 'my_toolbars'  );
    function my_toolbars( $toolbars )
    {
    	// Uncomment to view format of $toolbars
    	/*
    	echo '< pre >';
    		print_r($toolbars);
    	echo '< /pre >';
    	die;
    	*/
    
    	// Add a new toolbar called "Very Simple"
    	// - this toolbar has only 1 row of buttons
    	$toolbars['Very Simple' ] = array();
    	$toolbars['Very Simple' ][1] = array('bold' , 'italic' , 'underline' );
    
     
    	unset( $toolbars['Basic' ] );
    	unset( $toolbars['Full' ] );
    
    	// return $toolbars - IMPORTANT!
    	return $toolbars;
    }

    many thanks for your help in advance,
    Andrew

  • It too confused me at first since the filter kind of sounds like it’s editing the active toolbar but in the documentation of the hook it says:

    Once a new toolbar is added to the list, it will then appear in the WYSIWYG field’s options when editing the field group.

    So I added the code in your question and sure enough if I go back to edit the Field Group in Custom Fields there’s a new radio button on the WYSIWYG Field labeled ‘Very Simple’ and when selected will only display a toolbar with bold, italic, and underline buttons on it.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Create a new WYSIWYG toolbar’ is closed to new replies.