WordPress小技巧 纯代码为文章编辑添加彩色美化框及彩色按钮

文章目录
  • 一、效果展示
  • 二、实现方法
WordPress的文本编辑功能确实很平常,没有什么新意或者说是亮点,之前本站为大家简介过比较实用的表格插件(WordPress简便实用的表格插件推荐 WP Tabel Tag Gen汉化版)和纯代码添加下载按钮(WordPress小技巧 通过纯代码为文章编辑添加链接按钮),都是个人在使用过程当中绝得好用才分享给大家的。WP Tabel Tag Gen可以根据自己的需要往文章内插入表格、纯代码添加下载按钮可以让你文章的下载按钮更美观。此次本站再为大家分享一个WordPress美化小技巧,纯代码为文章添加彩色美化框、及闪光按钮,并且在撰写新文章文本编辑模式添加相关按钮,后续直接点击按钮插入即可。

一、效果展示

使用本文中简介的方法,大家都可以达到以下效果。

1、撰写新文章的文本编辑按钮展示。

2、文本彩色美化框展示。

绿色提示框 红色提示框 黄色提示框 灰色提示框 蓝色提示框 黑色提示框 虚线提示框 绿边提示框 红边提示框

3、按钮展示。

[sgbtn_blue href=”]点击购买[/sgbtn_blue]

[sgbtn_red href=”]点击购买[/sgbtn_red]

[sgbtn_orange href=”]点击购买[/sgbtn_orange]

[sgbtn_lv href=”]点击购买[/sgbtn_lv]

[gb href=”]点击购买[/gb]

[bb href=”]点击购买[/bb]

[yb href=”]点击购买[/yb]

二、实现方法

1、在主题functions.php文件中添加下面两段代码。

/*彩色文本框 开始 本站 www.wn789.com*/ function toz($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_notice','toz'); function toa($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_error','toa'); function toc($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_warn','toc'); function tob($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_tips','tob'); function tod($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_blue','tod'); function toe($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_black','toe'); function tof($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_xuk','tof'); function tog($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_lvb','tog'); function toh($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_redb','toh'); function toi($atts, $content=null){ return '
'.$content.'
'; } add_shortcode('v_orange','toi'); /*彩色文本框 结束 本站 www.wn789.com*/ /*闪光按钮 开始 本站 www.wn789.com*/ /*添加蓝色闪光按钮*/ function sg_blue($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('sgbtn_blue', 'sg_blue'); /*添加红色闪光按钮*/ function sg_red($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('sgbtn_red', 'sg_red'); /*添加橙色闪光按钮*/ function sg_orange($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('sgbtn_orange', 'sg_orange'); /*添加绿色闪光按钮*/ function sg_lv($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); return '' . $content . ''; } add_shortcode('sgbtn_lv', 'sg_lv'); /*闪光按钮 结束 本站 www.wn789.com*/ /*彩色按钮 开始 本站 www.wn789.com*/ /*蓝色按钮*/ function toj($atts, $content=null) { extract(shortcode_atts(array("href" => 'http://'), $atts)); return '' .$content.''; } add_shortcode('bb' , 'toj' ); /*黄色按钮*/ function tok($atts, $content=null) { extract(shortcode_atts(array("href" => 'http://'), $atts)); return '' .$content.''; } add_shortcode('yb' , 'tok' ); /*绿色按钮*/ function tol($atts, $content=null) { extract(shortcode_atts(array("href" => 'http://'), $atts)); return '' .$content.''; } add_shortcode('gb' , 'tol' ); /*彩色按钮 结束 本站 www.wn789.com*/ 注意:复制后请修改下面代码中的“【”为“[”,否则按钮部分无效。 /*添加文本编辑自定义快捷标签按钮 开始 本站 www.wn789.com*/ add_action('after_wp_tiny_mce', 'bolo_after_wp_tiny_mce'); function bolo_after_wp_tiny_mce($mce_settings) { ?> QTags.addButton( 'v_notice', '绿框', '
绿色提示框
\n', "" ); QTags.addButton( 'v_error', '红框', '
红色提示框
\n', "" ); QTags.addButton( 'v_warn', '黄框', '
黄色提示框
\n', "" ); QTags.addButton( 'v_tips', '灰框', '
灰色提示框
\n', "" ); QTags.addButton( 'v_blue', '蓝框', '
蓝色提示框
\n', "" ); QTags.addButton( 'v_black', '黑框', '
黑色提示框
\n', "" ); QTags.addButton( 'v_xuk', '虚线', '
虚线提示框
\n', "" ); QTags.addButton( 'v_lvb', '绿边', '
绿边提示框
\n', "" ); QTags.addButton( 'v_redb', '红边', '
红边提示框
\n', "" ); QTags.addButton( 'sgbtn_blue', '蓝色闪光', "【sgbtn_blue href='']点击购买", "[/sgbtn_blue]" ); QTags.addButton( 'sgbtn_red', '红色闪光', "【sgbtn_red href='']点击购买", "[/sgbtn_red]" ); QTags.addButton( 'sgbtn_orange', '黄色闪光', "【sgbtn_orange href='']点击购买", "[/sgbtn_orange]" ); QTags.addButton( 'sgbtn_lv', '绿色闪光', "【sgbtn_lv href='']点击购买", "[/sgbtn_lv]" ); QTags.addButton( 'gb', '绿色按钮', "【gb href='']点击购买", "[/gb]" ); QTags.addButton( 'bb', '蓝色按钮', "【bb href='']点击购买", "[/bb]" ); QTags.addButton( 'yb', '黄色按钮', "【yb href='']点击购买", "[/yb]" ); function bolo_QTnextpage_arg1() { }