Adding Buttons to the Visual Editor

Wordpress PHP net

adding button

Adding more buttons to the editor is easy by adding this snippett to your functions.php file.

buttons function.php

The following are available WYSWYG button codes. Just add them to the above function:

underline
strikethrough
justifyleft
justifycenter
justifyright
justifyfull
bullist
numlist
outdent
indent
cut
copy

paste
undo
redo
link
unlink
image
cleanup
help
hr
removeformat
formatselect
fontselect

fontsizeselect
styleselect
sub
sup
forecolor
backcolor
charmap
visualaid
anchor
newdocument
separator

 

Adding a Custom TinyMCE Button

Let’s add a custom FaceBook button to the Visual editor. So now, in your functions.php or core-functions.php, we’ll first add the function that will insert the button:

<?php
/** Add Youtube Button to Visual Editor */
function dh_add_youtube_button() {
if ( ! current_user_can( ‘edit_posts’ ) && ! current_user_can( ‘edit_pages’ ) )
return;
if ( get_user_option(‘rich_editing’) == ‘true’) {
add_filter( ‘mce_external_plugins’, ‘add_youtube_tinymce_plugin’ );
add_filter( ‘mce_buttons’, ‘register_youtube_button’ );
}
}
add_action( ‘init’, ‘dh_add_youtube_button’ );