Adding buttons to wysiwyg wordpress editor

TinyMCE WordPress adding buttons. As I said in the introductory text, default editor contains only required elements. You can add functionality by adding new buttons. I present below the code for adding a button to the editor:

Here HERE complete list of all buttons. Add code to your theme in function.php file. The button can also be added on the 2nd or 3rd line in the following way:

Creating custom buttons in the TinyMCE editor:

If you are using shortcode or classes for text, Images, buttons, which can also be created.

Here I am going to create a button on the third row, the button will only work if the user has permission to edit posts or pages.

Add below code in function.php:


Let's create another button that takes the selected text into a shortcode:

Button add function:

function add_button($buttons){ array_push($buttons,"blcss");return $buttons;}

Add more code that will access the TinyMCE editor and WordPress:

This code simply specifies the path for a specific JavaScript file, customcodes.js, which is saved in the scripts folder, in your theme folder. You can hardcode the path, but using the get_bloginfo method you will have more flexible code to port to other sites.
Complete the task, adding the following code to a file called customcodes.js . Save it in the path defined above.
The “CSS.png” icon should be 20px X 20px.

Hiding unwanted buttons using the TinyMCE editor options

If you want to remove unwanted buttons in the editor, then just provide the following code:

You can also set a special parameter and show only those elements, which you want:

Also work with TinyMCE editor buttons possible in a file wp-includes/js/quicktags.js but I wouldn't recommend, when you update the engine, your settings will simply fly off.


The article was taken and translated from the site: sumtips.com

 

Thanks and corrections can be sent in the comments.
I'll try to answer everyone quickly.
I use this code myself, so adding buttons to the TinyMCE editor in WordPress should work perfectly.

I will try to post another article in the near future on how to add buttons in code editing mode in WordPress.

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal