Forked from thierrypigot/tp-tinymce-background-color.php
Created
October 10, 2017 10:17
-
-
Save jahir07/b862c471d12a5a5fe70bb1f10a87d79d to your computer and use it in GitHub Desktop.
Add Background Color (Highlight) Option in WordPress Editor TinyMCE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Hook to init */ | |
add_action( 'init', 'tp_editor_background_color' ); | |
/** | |
* Add TinyMCE Button | |
*/ | |
function tp_editor_background_color() | |
{ | |
/* Add the button/option in second row */ | |
add_filter( 'mce_buttons_2', 'tp_editor_background_color_button', 1, 2 ); // 2nd row | |
} | |
/** | |
* Modify 2nd Row in TinyMCE and Add Background Color After Text Color Option | |
*/ | |
function tp_editor_background_color_button( $buttons, $id ) | |
{ | |
/* Only add this for content editor, you can remove this line to activate in all editor instance */ | |
if ( 'content' != $id ) | |
return $buttons; | |
/* Add the button/option after 4th item */ | |
array_splice( $buttons, 4, 0, 'backcolor' ); | |
return $buttons; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment