For the WYSIWYG field type I was interested both in creating a custom toolbar and adding additional buttons to the existing basic toolbar. I found this excellent article which explains most of what I am looking to do (https://www.advancedcustomfields.com/resources/customize-the-wysiwyg-toolbars/), however I have four follow up questions I am hoping you could help out with:
1. I would like to create a custom toolbar which includes the special character button. From the Tiny MCE button the special character button is part of the character map plugin which appears to be loaded by default. Can I add the button simply by adding charmap to the array for my custom toolbar (same array where the bold italic etc are added in the support article)?
2. For my custom toolbar I would also like to add the paste as text button. From the Tiny MCE documentation this button is part of the paste plugin. What syntax would I use to add this button to the array for my custom toolbar?
3. How do I add buttons to the existing basic toolbar? The support article shows how to remove a button, just want to make sure I understand how to add a button.
4. When I add the filter for modifying the toolbars I wanted to confirm that none of the existing data entered in any of the WYSIWYG fields used on my theme would be lost? Just wanted to be sure it was safe to add additional buttons to the basic toolbar without losing data.
Thanks for your help! Apologies in advance if any of these questions have already been answered (I haven’t had a chance to look at the array structure yet with the code you can uncomment in the support article).
I was able to figure out answers for all of my questions from my previous post above by looking at the array structure for the toolbars provided in the documentation for the toolbars filter. Thanks again for providing the detailed information in this documentation which allowed me to answer my questions about modifying the toolbars.
For those who might need a similar solution, here are the answers to my questions:
1. The special character button can be added in the same manner as the bold, italic, underline buttons as outlined in the documentation. Just add “charmap” to the array.
2. Similarly the paste as text button can be added in the same manner as outlined in the documentation. Just add “pasteastext” to the array.
3. Additional buttons can be added to the Basic toolbar simply by adding the code for the button to the end of the array for the row in the toolbar you want to add the button to. For example to add the special character button to the first row of buttons for the Basic toolbar:
$toolbars['Basic' ] = 'charmap';
4. Data is not lost when editing the toolbar options, whether adding a new toolbar or modifying an existing toolbar.
Thanks again for the excellent documentation provided here on the ACF site!
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Built an Advanced Custom Fields code generator Chrome extension. It's free, open source and you can find it on both Github and the Chrome Web Store.— Rostislav Melkumyan (@RostiMelk) March 23, 2020
New updates and more modularity on the way as well!https://t.co/woFJDMgwUF#acf #wordpress @wp_acf
© 2020 Advanced Custom Fields. Subscribe