Home Forums ACF PRO WYSIWYG Toolbar filter not working


WYSIWYG Toolbar filter not working

  • I tried to use this code in my functions to create a custom toolbar as described in the tutorial. The weird thing is it always shows the basic toolbar. Even with the basic toolbar unset and the Very Simple toolbar selected in the custom field. It always show the basic toolbar.

    Any help would be welcome. Using ACF 5.1.4 with a licence.

    add_filter( 'acf/fields/wysiwyg/toolbars' , 'my_toolbars'  );
    function my_toolbars( $toolbars ) {
    	// remove the 'Basic' toolbar completely
    	unset( $toolbars['Basic'] );
    	unset( $toolbars['Full'] );
    	// 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' );
    	// return $toolbars - IMPORTANT!
    	return $toolbars;
  • Hi @jasperrooduijn

    Thank you for the question.

    I believe you have to make use of the array_search() function. It returns the key of the element it finds, which can be used to remove that element from the original array using unset()

    The code will look something like this:

    if( ($key = array_search('code' , $toolbars['Full' ][2])) !== false )
    	    unset( $toolbars['Full' ][2][$key] );
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘WYSIWYG Toolbar filter not working’ is closed to new replies.