<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[24214] trunk: * Pass ellipsis as a parameter to wp_html_excerpt() instead of appending it manually.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/24214">24214</a></dd>
<dt>Author</dt> <dd>SergeyBiryukov</dd>
<dt>Date</dt> <dd>2013-05-09 00:22:02 +0000 (Thu, 09 May 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>* Pass ellipsis as a parameter to wp_html_excerpt() instead of appending it manually.
* Consolidate the logic to avoid appending ellipsis if the entire string is shown.
* Show ellipsis after truncated filenames and post titles.
props solarissmoke, bpetty, SergeyBiryukov. fixes <a href="http://core.trac.wordpress.org/ticket/11446">#11446</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminasyncuploadphp">trunk/wp-admin/async-upload.php</a></li>
<li><a href="#trunkwpadmineditcommentsphp">trunk/wp-admin/edit-comments.php</a></li>
<li><a href="#trunkwpadminincludesdashboardphp">trunk/wp-admin/includes/dashboard.php</a></li>
<li><a href="#trunkwpadminincludesmediaphp">trunk/wp-admin/includes/media.php</a></li>
<li><a href="#trunkwpadminincludesnavmenuphp">trunk/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunkwpadminnavmenusphp">trunk/wp-admin/nav-menus.php</a></li>
<li><a href="#trunkwpincludesadminbarphp">trunk/wp-includes/admin-bar.php</a></li>
<li><a href="#trunkwpincludesclasswpcustomizemanagerphp">trunk/wp-includes/class-wp-customize-manager.php</a></li>
<li><a href="#trunkwpincludescommentphp">trunk/wp-includes/comment.php</a></li>
<li><a href="#trunkwpincludesformattingphp">trunk/wp-includes/formatting.php</a></li>
<li><a href="#trunkwptrackbackphp">trunk/wp-trackback.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminasyncuploadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/async-upload.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/async-upload.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-admin/async-upload.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx"> echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
</span><span class="cx"> echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>';
</span><span class="cx"> $title = $post->post_title ? $post->post_title : wp_basename( $post->guid ); // title shouldn't ever be empty, but use filename just in cas.e
</span><del>- echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60 ) ) . '</span></div>';
</del><ins>+ echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60, '…' ) ) . '</span></div>';
</ins><span class="cx"> break;
</span><span class="cx"> case 2 :
</span><span class="cx"> add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
</span></span></pre></div>
<a id="trunkwpadmineditcommentsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-comments.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-comments.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-admin/edit-comments.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx"> enqueue_comment_hotkeys_js();
</span><span class="cx">
</span><span class="cx"> if ( $post_id )
</span><del>- $title = sprintf(__('Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
</del><ins>+ $title = sprintf( __( 'Comments on “%s”' ), wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ) );
</ins><span class="cx"> else
</span><span class="cx"> $title = __('Comments');
</span><span class="cx">
</span><span class="lines">@@ -143,17 +143,17 @@
</span><span class="cx"> <?php screen_icon(); ?>
</span><span class="cx"> <h2><?php
</span><span class="cx"> if ( $post_id )
</span><del>- echo sprintf(__('Comments on “%s”'),
- sprintf('<a href="%s">%s</a>',
- get_edit_post_link($post_id),
- wp_html_excerpt(_draft_or_post_title($post_id), 50)
</del><ins>+ echo sprintf( __( 'Comments on “%s”' ),
+ sprintf( '<a href="%s">%s</a>',
+ get_edit_post_link( $post_id ),
+ wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' )
</ins><span class="cx"> )
</span><span class="cx"> );
</span><span class="cx"> else
</span><span class="cx"> echo __('Comments');
</span><span class="cx">
</span><span class="cx"> if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
</span><del>- printf( '<span class="subtitle">' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50 ) ) . '</span>' ); ?>
</del><ins>+ printf( '<span class="subtitle">' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' ) ) . '</span>' ); ?>
</ins><span class="cx"> </h2>
</span><span class="cx">
</span><span class="cx"> <?php
</span></span></pre></div>
<a id="trunkwpadminincludesdashboardphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/dashboard.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/dashboard.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-admin/includes/dashboard.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -827,7 +827,7 @@
</span><span class="cx"> $publisher = "<strong>$publisher</strong>";
</span><span class="cx">
</span><span class="cx"> $content = $item->get_content();
</span><del>- $content = wp_html_excerpt($content, 50) . ' …';
</del><ins>+ $content = wp_html_excerpt( $content, 50, ' …' );
</ins><span class="cx">
</span><span class="cx"> if ( $link )
</span><span class="cx"> /* translators: incoming links feed, %1$s is other person, %3$s is content */
</span></span></pre></div>
<a id="trunkwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/media.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/media.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-admin/includes/media.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -1159,7 +1159,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
</span><del>- $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : '';
</del><ins>+ $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, '…' ) . "</span></div>" : '';
</ins><span class="cx">
</span><span class="cx"> $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
</span><span class="cx"> $order = '';
</span></span></pre></div>
<a id="trunkwpadminincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/nav-menu.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/nav-menu.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-admin/includes/nav-menu.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -515,10 +515,7 @@
</span><span class="cx"> <option value="0"></option>
</span><span class="cx"> <?php foreach ( $menus as $menu ) : ?>
</span><span class="cx"> <option<?php selected( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $menu->term_id ); ?>
</span><del>- value="<?php echo $menu->term_id; ?>"><?php
- $truncated_name = wp_html_excerpt( $menu->name, 40 );
- echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…';
- ?></option>
</del><ins>+ value="<?php echo $menu->term_id; ?>"><?php echo wp_html_excerpt( $menu->name, 40, '…' ); ?></option>
</ins><span class="cx"> <?php endforeach; ?>
</span><span class="cx"> </select>
</span><span class="cx"> </label>
</span></span></pre></div>
<a id="trunkwpadminnavmenusphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/nav-menus.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-admin/nav-menus.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -436,11 +436,7 @@
</span><span class="cx">
</span><span class="cx"> // Generate truncated menu names
</span><span class="cx"> foreach( (array) $nav_menus as $key => $_nav_menu ) {
</span><del>- $_nav_menu->truncated_name = trim( wp_html_excerpt( $_nav_menu->name, 40 ) );
- if ( $_nav_menu->truncated_name != $_nav_menu->name )
- $_nav_menu->truncated_name .= '…';
-
- $nav_menus[$key]->truncated_name = $_nav_menu->truncated_name;
</del><ins>+ $nav_menus[$key]->truncated_name = wp_html_excerpt( $_nav_menu->name, 40, '…' );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Retrieve menu locations
</span><span class="lines">@@ -572,8 +568,7 @@
</span><span class="cx"> <?php foreach ( $nav_menus as $menu ) : ?>
</span><span class="cx"> <?php $selected = isset( $menu_locations[$_location] ) && $menu_locations[$_location] == $menu->term_id; ?>
</span><span class="cx"> <option <?php if ( $selected ) echo 'data-orig="true"'; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>">
</span><del>- <?php $truncated_name = wp_html_excerpt( $menu->name, 40 );
- echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…'; ?>
</del><ins>+ <?php echo wp_html_excerpt( $menu->name, 40, '…' ); ?>
</ins><span class="cx"> </option>
</span><span class="cx"> <?php endforeach; ?>
</span><span class="cx"> </select>
</span></span></pre></div>
<a id="trunkwpincludesadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/admin-bar.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/admin-bar.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-includes/admin-bar.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -229,9 +229,7 @@
</span><span class="cx"> $blogname = sprintf( __('Global Dashboard: %s'), esc_html( $current_site->site_name ) );
</span><span class="cx"> }
</span><span class="cx">
</span><del>- $title = wp_html_excerpt( $blogname, 40 );
- if ( $title != $blogname )
- $title = trim( $title ) . '…';
</del><ins>+ $title = wp_html_excerpt( $blogname, 40, '…' );
</ins><span class="cx">
</span><span class="cx"> $wp_admin_bar->add_menu( array(
</span><span class="cx"> 'id' => 'site-name',
</span></span></pre></div>
<a id="trunkwpincludesclasswpcustomizemanagerphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-customize-manager.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-customize-manager.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-includes/class-wp-customize-manager.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -897,9 +897,7 @@
</span><span class="cx"> if ( $menus ) {
</span><span class="cx"> $choices = array( 0 => __( '— Select —' ) );
</span><span class="cx"> foreach ( $menus as $menu ) {
</span><del>- $truncated_name = wp_html_excerpt( $menu->name, 40 );
- $truncated_name = ( $truncated_name == $menu->name ) ? $menu->name : trim( $truncated_name ) . '…';
- $choices[ $menu->term_id ] = $truncated_name;
</del><ins>+ $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> foreach ( $locations as $location => $description ) {
</span></span></pre></div>
<a id="trunkwpincludescommentphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/comment.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/comment.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-includes/comment.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -1753,7 +1753,7 @@
</span><span class="cx"> else
</span><span class="cx"> $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
</span><span class="cx"> $excerpt = str_replace(']]>', ']]>', $excerpt);
</span><del>- $excerpt = wp_html_excerpt($excerpt, 252) . '…';
</del><ins>+ $excerpt = wp_html_excerpt($excerpt, 252, '…');
</ins><span class="cx">
</span><span class="cx"> $post_title = apply_filters('the_title', $post->post_title, $post->ID);
</span><span class="cx"> $post_title = strip_tags($post_title);
</span></span></pre></div>
<a id="trunkwpincludesformattingphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/formatting.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/formatting.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-includes/formatting.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -2199,7 +2199,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @param string $text Text to trim.
</span><span class="cx"> * @param int $num_words Number of words. Default 55.
</span><del>- * @param string $more What to append if $text needs to be trimmed. Default '…'.
</del><ins>+ * @param string $more Optional. What to append if $text needs to be trimmed. Default '…'.
</ins><span class="cx"> * @return string Trimmed text.
</span><span class="cx"> */
</span><span class="cx"> function wp_trim_words( $text, $num_words = 55, $more = null ) {
</span><span class="lines">@@ -3118,14 +3118,19 @@
</span><span class="cx"> *
</span><span class="cx"> * @param integer $str String to get the excerpt from.
</span><span class="cx"> * @param integer $count Maximum number of characters to take.
</span><ins>+ * @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string.
</ins><span class="cx"> * @return string The excerpt.
</span><span class="cx"> */
</span><del>-function wp_html_excerpt( $str, $count ) {
</del><ins>+function wp_html_excerpt( $str, $count, $more = null ) {
+ if ( null === $more )
+ $more = '';
</ins><span class="cx"> $str = wp_strip_all_tags( $str, true );
</span><del>- $str = mb_substr( $str, 0, $count );
</del><ins>+ $excerpt = mb_substr( $str, 0, $count );
</ins><span class="cx"> // remove part of an entity at the end
</span><del>- $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str );
- return $str;
</del><ins>+ $excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt );
+ if ( $str != $excerpt )
+ $excerpt = trim( $excerpt ) . $more;
+ return $excerpt;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwptrackbackphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-trackback.php (24213 => 24214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-trackback.php 2013-05-08 23:23:05 UTC (rev 24213)
+++ trunk/wp-trackback.php 2013-05-09 00:22:02 UTC (rev 24214)
</span><span class="lines">@@ -87,8 +87,8 @@
</span><span class="cx"> if ( !pings_open($tb_id) )
</span><span class="cx"> trackback_response(1, 'Sorry, trackbacks are closed for this item.');
</span><span class="cx">
</span><del>- $title = wp_html_excerpt( $title, 250 ) . '…';
- $excerpt = wp_html_excerpt( $excerpt, 252 ) . '…';
</del><ins>+ $title = wp_html_excerpt( $title, 250, '…' );
+ $excerpt = wp_html_excerpt( $excerpt, 252, '…' );
</ins><span class="cx">
</span><span class="cx"> $comment_post_ID = (int) $tb_id;
</span><span class="cx"> $comment_author = $blog_name;
</span></span></pre>
</div>
</div>
</body>
</html>