Add class to wordpress TinyMCE

Some times need to add custom classes in wordpress tinymce editor. This is simple solution to do this:

add_filter('tiny_mce_before_init', 'oi_tinymce');
function oi_tinymce($settings) {
	$new_styles = array(
		array(
			'title' => 'None',
			'value'	=> ''
		),
		array(
			'title'	=> 'Table',
			'value'	=> 'table',
		),
	);
	$settings['table_class_list'] = json_encode( $new_styles );
	return $settings;
}

Leave a Reply

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

5 × 1 =