Support

Account

Home Forums Reply To:

  • I’m trying to create a new toolbar to use for WYSWIYG fields, called “Editorial”. Initially I would like to only have the formatselect, bold and italic in its toolbar. I also want to remove the default toolbars.

    I’ve created it according to the documentation and the filter looks like this:

    
    add_filter( 'acf/fields/wysiwyg/toolbars' , 'kh_toolbars'  );
    function kh_toolbars( $toolbars )
    {
        // Uncomment to view format of $toolbars
        /*
        echo '< pre >';
            print_r($toolbars);
        echo '< /pre >';
        die;
        */
    
        // Add a new toolbar called "Editorial", with limited options
        $toolbars['Editorial' ] = array();
        $toolbars['Editorial' ][1] = array( 'formatselect', 'bold' , 'italic' , 'underline' );
    
        // remove the default toolbars completely
        unset( $toolbars['Basic' ] );
        unset( $toolbars['Full' ] );
    
        // return $toolbars - IMPORTANT!
        return $toolbars;
    }
    

    The toolbar is possible to select when editing the field, so I select “Editorial” there as it’s the only option after removing the default ones.

    When looking at the WYSIWYG field in the editor though, the toolbar is populated with the default buttons as well. I can also try to remove ‘italic’ for example in the array of the filter, but the italic button is still there after that.

    I would also like to know the best solution for limiting the selection of block_formats within the formatselect for a specific toolbar.

    Any idea what I’m doing wrong here?