wordpress编辑器增加字体和文字大小的功能

wordpress网站默认的编辑器功能比较简单,一般是够用了,但如果需要编辑多样式的文章,还需要拓展编辑器功能才行的。

只需要在主题功能函数function.php中加入下面代码:

PHP
/*
Plugin Name: 编辑器增强
Author: nicetheme.cn
Author URI: https://www.nicetheme.cn
Description: 使默认的文本编辑器支持字体选择与字体大小设置等
Version: 1.0
*/
function nicetheme_add_editor_buttons($buttons) { $buttons[] = 'fontselect'; $buttons[] = 'fontsizeselect'; $buttons[] = 'cleanup'; $buttons[] = 'styleselect'; $buttons[] = 'del'; $buttons[] = 'sub'; $buttons[] = 'sup'; $buttons[] = 'copy'; $buttons[] = 'paste'; $buttons[] = 'cut'; $buttons[] = 'image'; $buttons[] = 'anchor'; $buttons[] = 'backcolor'; $buttons[] = 'wp_page'; $buttons[] = 'charmap'; return $buttons; } add_filter("mce_buttons_2", "nicetheme_add_editor_buttons"); function custum_fontfamily($initArray){ $initArray['font_formats'] = "微软雅黑=Microsoft YaHei,Microsoft JhengHei,黑体;宋体=SimSun;黑体=SimHei;楷体=kaiti,KaiTi_GB2312;隶书=LiSu;幼圆=幼圆;Impact=Impact;Arial=Arial;Verdana=Verdana;Tahoma=Tahoma"; return $initArray; } add_filter('tiny_mce_before_init', 'custum_fontfamily');

上面字体都可以替换的,根据自己的需求修改替换即可。

wordpress编辑器

猜你喜欢

转载自www.cnblogs.com/idid/p/12421767.html
今日推荐