欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WordPress中讓W(xué)idget 標(biāo)題支持簡(jiǎn)單的HTML標(biāo)簽

  發(fā)布時(shí)間:2014-02-03 12:26:19   作者:佚名   我要評(píng)論
在默認(rèn)情況下,WordPress 的 Widget 標(biāo)題是不支持任何 HTML 標(biāo)簽的,下面的技巧教你使用簡(jiǎn)單的代碼替換實(shí)現(xiàn)在 Widget 標(biāo)題實(shí)現(xiàn)支持 HTML 標(biāo)簽


復(fù)制代碼
代碼如下:

<?php
/*
Plugin Name: WPJAM HTML Widget Title
Description: 讓 Widget 標(biāo)題支持簡(jiǎn)單的 HTML 標(biāo)簽
Version: 0.1
Author: Denis
*/
add_filter( 'widget_title', 'wpjam_html_widget_title' );
function wpjam_html_widget_title( $title ) {
//HTML tag opening/closing brackets
$title = str_replace( '[', '<', $title );
$title = str_replace( '[/', '</', $title );</p> <p> //<strong></strong>
$title = str_replace( 's]', 'strong>', $title );
//<em></em>
$title = str_replace( 'e]', 'em>', $title );</p> <p> return $title;
}
?>

把上面的代碼復(fù)制到當(dāng)前主題的 functions.php 文件或者直接保存插件上傳之后,就可以在 Widget 標(biāo)題輸入類似的代碼:“測(cè)試[s]粗體[/s]和[e]斜體[/e]”實(shí)現(xiàn)粗體和斜體的 HTML 標(biāo)簽。上面的代碼讓 Widget 標(biāo)題僅僅支持加粗和斜體兩種 HTML 標(biāo)簽,但是我們可以通過(guò)相同的方法非常容易自己添加其他的 HTML 標(biāo)簽支持。

如果是普通的php中想讓標(biāo)題支持html標(biāo)簽可以使用如下的代碼


復(fù)制代碼
代碼如下:

$title = str_replace( '<', '&lt;', $title);
$title = str_replace( '>', '&gt;', $title);
$title = cn_substr($title,80);

相關(guān)文章

最新評(píng)論