Make WordPress Core

Ticket #4731: the_title_attribute.diff

File the_title_attribute.diff, 5.1 KB (added by ryan, 16 years ago)
  • wp-includes/post-template.php

     
    3030                return $title;
    3131}
    3232
     33function the_title_attribute( $args = '' ) {
     34        $title = get_the_title();
    3335
     36        if ( strlen($title) <= 0 )
     37                return;
     38
     39        $defaults = array('before' => '', 'after' =>  '', 'echo' => true);
     40        $r = wp_parse_args($args, $defaults);
     41        extract( $r, EXTR_SKIP );
     42
     43
     44        $title = $before . $title . $after;
     45        $title = attribute_escape(strip_tags($title));
     46
     47        if ( $echo )
     48                echo $title;
     49        else
     50                return $title;
     51}
     52
    3453function get_the_title( $id = 0 ) {
    3554        $post = &get_post($id);
    3655
  • wp-content/themes/default/search.php

     
    1515                <?php while (have_posts()) : the_post(); ?>
    1616
    1717                        <div class="post">
    18                                 <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
     18                                <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    1919                                <small><?php the_time('l, F jS, Y') ?></small>
    2020
    2121                                <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
  • wp-content/themes/default/index.php

     
    77                <?php while (have_posts()) : the_post(); ?>
    88
    99                        <div class="post" id="post-<?php the_ID(); ?>">
    10                                 <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
     10                                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    1111                                <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    1212
    1313                                <div class="entry">
  • wp-content/themes/default/archive.php

     
    2929
    3030                <?php while (have_posts()) : the_post(); ?>
    3131                <div class="post">
    32                                 <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
     32                                <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    3333                                <small><?php the_time('l, F jS, Y') ?></small>
    3434
    3535                                <div class="entry">
  • wp-content/themes/default/single.php

     
    1010                </div>
    1111
    1212                <div class="post" id="post-<?php the_ID(); ?>">
    13                         <h2><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
     13                        <h2><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    1414
    1515                        <div class="entry">
    1616                                <?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
  • wp-content/themes/default/attachment.php

     
    1111<?php $attachment_link = get_the_attachment_link($post->ID, true, array(450, 800)); // This also populates the iconsize for the next line ?>
    1212<?php $_post = &get_post($post->ID); $classname = ($_post->iconsize[0] <= 128 ? 'small' : '') . 'attachment'; // This lets us style narrow icons specially ?>
    1313                <div class="post" id="post-<?php the_ID(); ?>">
    14                         <h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> &raquo; <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
     14                        <h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> &raquo; <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    1515                        <div class="entry">
    1616                                <p class="<?php echo $classname; ?>"><?php echo $attachment_link; ?><br /><?php echo basename($post->guid); ?></p>
    1717