Make WordPress Core

Ticket #12905: tmpl-argument-for-the-title-attribute.diff

File tmpl-argument-for-the-title-attribute.diff, 927 bytes (added by nbachiyski, 15 years ago)
  • wp-includes/post-template.php

     
    7777        if ( strlen($title) == 0 )
    7878                return;
    7979
    80         $defaults = array('before' => '', 'after' =>  '', 'echo' => true);
    81         $r = wp_parse_args($args, $defaults);
     80        $defaults = array('before' => '', 'after' =>  '', 'echo' => true, 'text' => '%s');
     81       
     82        if ( is_string( $args) && !preg_match( '/^('.implode( '|', array_keys( $defaults ) ).')=/', $args ) )
     83                $r = array_merge( $defaults, array( 'text' => $args ) );
     84        else
     85                $r = wp_parse_args( $args, $defaults );
     86               
    8287        extract( $r, EXTR_SKIP );
    8388
    8489
    85         $title = $before . $title . $after;
    86         $title = esc_attr(strip_tags($title));
     90        $title = $before . sprintf( $text, $title ) . $after;
     91        $title = esc_attr( strip_tags( $title ) );
    8792
    8893        if ( $echo )
    8994                echo $title;