Simple HTML in widget title

By default all HTML tags are being stripped down for widget titles in WordPress. This bit of code makes it easy to use simple HTML tags replacements in those titles like so: “Testing [s]strong[/s] and [e]emphasized[/e]”.

The snippet makes it possible to use (type [s] and [/s] in widget title) and (type [e] and [/e] in widget title) tags only but other HTML tags can be added easily.

Code Snippet:

function html_widget_title( $title ) {
	//HTML tag opening/closing brackets
	$title = str_replace( '&#91;', '<', $title );
	$title = str_replace( '&#91;/', '</', $title );

	$title = str_replace( 's]', 'strong>', $title );
	$title = str_replace( 'e]', 'em>', $title );

	return $title;
add_filter( 'widget_title', 'html_widget_title' );

Posted in Admin area, Pure hacks