WordPress.org

Make WordPress Core

Ticket #11446: 11446.2.diff

File 11446.2.diff, 6.8 KB (added by solarissmoke, 7 years ago)
  • wp-includes/comment.php

     
    17041704        else
    17051705                $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
    17061706        $excerpt = str_replace(']]>', ']]>', $excerpt);
    1707         $excerpt = wp_html_excerpt($excerpt, 252) . '...';
     1707        $excerpt = wp_html_excerpt($excerpt, 252, true);
    17081708
    17091709        $post_title = apply_filters('the_title', $post->post_title);
    17101710        $post_title = strip_tags($post_title);
  • wp-includes/formatting.php

     
    27102710 *
    27112711 * @param integer $str String to get the excerpt from.
    27122712 * @param integer $count Maximum number of characters to take.
     2713 * @param bool $append_ellipsis optional Whether to append truncated string with an ellipsis. Defaults to false.
    27132714 * @return string The excerpt.
    27142715 */
    2715 function wp_html_excerpt( $str, $count ) {
     2716function wp_html_excerpt( $str, $count, $append_ellipsis = false ) {
    27162717        $str = wp_strip_all_tags( $str, true );
    2717         $str = mb_substr( $str, 0, $count );
     2718        $new_str = mb_substr( $str, 0, $count );
    27182719        // remove part of an entity at the end
    2719         $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str );
    2720         return $str;
     2720        $new_str = preg_replace( '/&[^;\s]{0,6}$/', '', $new_str );
     2721        if( $append_ellipsis && strlen( $new_str ) < strlen( $str ) )
     2722                $new_str .= '&hellip;';
     2723        return $new_str;
    27212724}
    27222725
    27232726/**
  • wp-trackback.php

     
    8787        if ( !pings_open($tb_id) )
    8888                trackback_response(1, 'Sorry, trackbacks are closed for this item.');
    8989
    90         $title =  wp_html_excerpt( $title, 250 ).'...';
    91         $excerpt = wp_html_excerpt( $excerpt, 252 ).'...';
     90        $title =  wp_html_excerpt( $title, 250, true );
     91        $excerpt = wp_html_excerpt( $excerpt, 252, true );
    9292
    9393        $comment_post_ID = (int) $tb_id;
    9494        $comment_author = $blog_name;
  • wp-admin/edit-comments.php

     
    111111enqueue_comment_hotkeys_js();
    112112
    113113if ( $post_id )
    114         $title = sprintf(__('Comments on &#8220;%s&#8221;'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
     114        $title = sprintf(__('Comments on &#8220;%s&#8221;'), wp_html_excerpt(_draft_or_post_title($post_id), 50, true));
    115115else
    116116        $title = __('Comments');
    117117
     
    139139        echo sprintf(__('Comments on &#8220;%s&#8221;'),
    140140                sprintf('<a href="%s">%s</a>',
    141141                        get_edit_post_link($post_id),
    142                         wp_html_excerpt(_draft_or_post_title($post_id), 50)
     142                        wp_html_excerpt(_draft_or_post_title($post_id), 50, true)
    143143                )
    144144        );
    145145else
    146146        echo __('Comments');
    147147
    148148if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
    149         printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ) . '</span>' ); ?>
     149        printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50, true ) ) . '</span>' ); ?>
    150150</h2>
    151151
    152152<?php
  • wp-admin/includes/dashboard.php

     
    824824                        $publisher = "<strong>$publisher</strong>";
    825825
    826826                $content = $item->get_content();
    827                 $content = wp_html_excerpt($content, 50) . ' ...';
     827                $content = wp_html_excerpt($content, 50, true);
    828828
    829829                if ( $link )
    830830                        /* translators: incoming links feed, %1$s is other person, %3$s is content */
  • wp-admin/includes/media.php

     
    12151215        }
    12161216
    12171217        $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
    1218         $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : '';
     1218        $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, true ) . "</span></div>" : '';
    12191219
    12201220        $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
    12211221        $order = '';
  • wp-admin/includes/nav-menu.php

     
    482482                                        <?php foreach ( $menus as $menu ) : ?>
    483483                                        <option<?php selected( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $menu->term_id ); ?>
    484484                                                value="<?php echo $menu->term_id; ?>"><?php
    485                                                 $truncated_name = wp_html_excerpt( $menu->name, 40 );
    486                                                 echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '&hellip;';
     485                                                echo wp_html_excerpt( $menu->name, 40, true );
    487486                                        ?></option>
    488487                                        <?php endforeach; ?>
    489488                                </select>
  • wp-admin/nav-menus.php

     
    420420
    421421// Generate truncated menu names
    422422foreach( (array) $nav_menus as $key => $_nav_menu ) {
    423         $_nav_menu->truncated_name = trim( wp_html_excerpt( $_nav_menu->name, 40 ) );
    424         if ( $_nav_menu->truncated_name != $_nav_menu->name )
    425                 $_nav_menu->truncated_name .= '&hellip;';
    426 
     423        $_nav_menu->truncated_name = trim( wp_html_excerpt( $_nav_menu->name, 40, true ) );
    427424        $nav_menus[$key]->truncated_name = $_nav_menu->truncated_name;
    428425}
    429426
  • wp-admin/admin-header.php

     
    113113        $blog_name = sprintf( __('%s Global Dashboard'), esc_html($current_site->site_name) );
    114114else
    115115        $blog_name = get_bloginfo('name', 'display');
    116 if ( '' == $blog_name ) {
     116if ( '' == $blog_name )
    117117        $blog_name = __( 'Visit Site' );
    118 } else {
    119         $blog_name_excerpt = wp_html_excerpt($blog_name, 40);
    120         if ( $blog_name != $blog_name_excerpt )
    121                 $blog_name_excerpt = trim($blog_name_excerpt) . '&hellip;';
    122         $blog_name = $blog_name_excerpt;
    123         unset($blog_name_excerpt);
    124 }
     118else
     119        $blog_name = wp_html_excerpt($blog_name, 40, true);
     120
    125121$title_class = '';
    126122if ( function_exists('mb_strlen') ) {
    127123        if ( mb_strlen($blog_name, 'UTF-8') > 30 )