the_title_attribute(). Props Nazgul. fixes #4731

git-svn-id: https://develop.svn.wordpress.org/trunk@6132 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2007-09-18 22:50:59 +00:00
parent 421356b6b8
commit ec05e6cfd7
6 changed files with 25 additions and 6 deletions

View File

@@ -19,7 +19,7 @@ function get_the_ID() {
function the_title($before = '', $after = '', $echo = true) {
$title = get_the_title();
if ( strlen($title) <= 0 )
if ( strlen($title) == 0 )
return;
$title = $before . $title . $after;
@@ -30,6 +30,25 @@ function the_title($before = '', $after = '', $echo = true) {
return $title;
}
function the_title_attribute( $args = '' ) {
$title = get_the_title();
if ( strlen($title) == 0 )
return;
$defaults = array('before' => '', 'after' => '', 'echo' => true);
$r = wp_parse_args($args, $defaults);
extract( $r, EXTR_SKIP );
$title = $before . $title . $after;
$title = attribute_escape(strip_tags($title));
if ( $echo )
echo $title;
else
return $title;
}
function get_the_title( $id = 0 ) {
$post = &get_post($id);