Skip to content

WYSIWYG Toolbars

The WYSIWYG_Toolbars class lets you define custom TinyMCE toolbar presets that can be used across WYSIWYG fields in your modules and post type fields. This controls which formatting buttons are available to content editors.


functions/project/config/wysiwyg-toolbars_config.php

<?php
return [
'basic' => [
'formatselect', 'bold', 'italic', 'link', 'unlink',
'bullist', 'numlist', 'removeformat',
],
'standard' => [
'formatselect', 'bold', 'italic', 'underline',
'link', 'unlink', 'bullist', 'numlist',
'blockquote', 'removeformat', 'pastetext',
],
'minimal' => [
'bold', 'italic', 'link', 'unlink',
],
];

When defining a WYSIWYG field with ACF_Builder, reference the toolbar name:

<?php
ACF_Builder::wysiwyg(['name' => 'content', 'toolbar' => 'basic'])
ACF_Builder::wysiwyg(['name' => 'rich_content', 'toolbar' => 'standard'])
ACF_Builder::wysiwyg(['name' => 'note', 'toolbar' => 'minimal'])

Common TinyMCE buttons you can include:

ButtonDescription
formatselectHeading dropdown (H1-H6, Paragraph)
boldBold text
italicItalic text
underlineUnderline text
linkInsert link
unlinkRemove link
bullistUnordered list
numlistOrdered list
blockquoteBlockquote
removeformatRemove formatting
pastetextPaste as plain text
alignleftAlign left
aligncenterAlign center
hrHorizontal rule
charmapSpecial characters

Knowledge Check

Test your understanding of this section

Loading questions...