以下 wordpress 插件允许将 Widget 标题转换为链接。我希望将链接文本输出为粗体并为黑色。我需要修改什么?我会通过 CSS 做到这一点,但它最终会影响其他类和样式。我想在 PHP 脚本中为这个非站点范围的单个用例执行此操作。
<?php
/*
Plugin Name: Custom Widget Title Links
Plugin URI: http://www.playforward.net/
Description: Allows you to define a link that is wrapped around widget titles.
Version: 1.0
Author: Playforward | Dustin Dempsey
Author URI: http://www.playforward.net/
*/
function custom_widget_link( $title ) {
// assume there's a link attached to the title because it starts with ww, http, or /
if ( ( substr( $title, 0, 4) == "www." ) || ( substr( $title, 0, 4) == "http" ) || ( substr( $title, 0, 1) == "/" ) ) {
// split our title in half
$title_pieces = explode( "|", $title );
// if there's two pieces
if ( count( $title_pieces ) == 2 ) {
// add http if it's just www
if ( substr( $title, 0, 4) == "www." ) {
$title_pieces[0] = str_replace( "www.", "http://www.", $title_pieces[0] );
}
// create new title from url and extracted title
$title = '<a href="' . $title_pieces[0] . '" title="' . $title_pieces[1] . '">' . $title_pieces[1] . '</a>';
}
}
return $title;
}
add_filter( "widget_title", "custom_widget_link" );
?>