给wordpress默认编辑器增强添加h1h2h3等常用标签


前面测速网讲过怎样增强wordpress默认编辑器,为怎样修改wordpess编辑器中文章内容字体的字号大小今天给大家讲下怎样给wp编辑器添加h1h2h3常用标签,其实方法都是一样的,只是改变了标签的类型说明而已。

1617181920212223242526272829303132//添加HTML编辑器自定义快捷标签按钮add_action('after_wp_tiny_mce', 'add_button_mce');function add_button_mce($mce_settings) {?><script type="text/javascript">QTags.addButton( 'hr', 'hr', "n<hr />n", "" );QTags.addButton( 'h1', 'h1', "n<h1>", "</h1>n" );QTags.addButton( 'h2', 'h2', "n<h2>", "</h2>n" );QTags.addButton( 'h3', 'h3', "n<h3>", "</h3>n" );QTags.addButton( 'pre', 'pre', "n<pre>n", "n</pre>n" );</script><?php}//pre防html转义代码 // convert htmlentity for pre tag add_filter('the_content', 'htmlspecialchars_pre', 12); add_filter('get_comment_text', 'htmlspecialchars_pre'); function htmlspecialchars_pre ($content) { return preg_replace_callback ("<pre>(.*?)<\/pre>/si", create_function('$matches','return "<"."pre".">" . htmls_pecial_chars($matches[1]) ."<"."/pre>";'),$content); } function htmls_pecial_chars($content=''){$content = str_replace("<","<",$content);$content = str_replace(">",">",$content);$content = str_replace("&","&",$content);$content = str_replace('"',""",$content);$content = str_replace("'","'",$content);$content = str_replace(" ","?",$content); return $content; }

wordpress增加h1h2自定义标签办法:找到wp主题的functions.php文件,路径为:/home/wp-content/themes/主题文件夹/functions.php,然后将以下代码添加<?php 之后:即可,但是需要注册的是pre作用代码添加标签,在前端会自动转义,我们还需要在下面添加以下代码来防止转义,


上一篇:激活wordpress后台的options.php”隐藏全部设置”选项

下一篇:关于编辑文件报错发现错误wordpress后台自动回滚问题


Copyright © 2002-2019 测速网 www.inhv.cn 皖ICP备2023010105号
测速城市 测速地区 测速街道 网速测试城市 网速测试地区 网速测试街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!

热门搜索 城市网站建设 地区网站制作 街道网页设计 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器