WordPress.org

Make WordPress Core

Ticket #11446: 11446.3.patch

File 11446.3.patch, 6.8 KB (added by bpetty, 5 years ago)
  • wp-admin/edit-comments.php

    diff --git wp-admin/edit-comments.php wp-admin/edit-comments.php
    index 174cd9a..1cacb0d 100644
    wp_enqueue_script('admin-comments'); 
    105105enqueue_comment_hotkeys_js();
    106106
    107107if ( $post_id )
    108         $title = sprintf(__('Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
     108        $title = sprintf(__('Comments on “%s”'),
     109                                         wp_html_excerpt( _draft_or_post_title($post_id), 50,
     110                                                                          array( 'append_ellipsis' => true ) ) );
    109111else
    110112        $title = __('Comments');
    111113
    if ( $post_id ) 
    146148        echo sprintf(__('Comments on “%s”'),
    147149                sprintf('<a href="%s">%s</a>',
    148150                        get_edit_post_link($post_id),
    149                         wp_html_excerpt(_draft_or_post_title($post_id), 50)
     151                        wp_html_excerpt( _draft_or_post_title($post_id), 50,
     152                                                         array( 'append_ellipsis' => true ) )
    150153                )
    151154        );
    152155else
    153156        echo __('Comments');
    154157
    155158if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
    156         printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ) . '</span>' ); ?>
     159        printf( '<span class="subtitle">' .
     160                        sprintf( __( 'Search results for &#8220;%s&#8221;' ),
     161                                         wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50,
     162                                                                          array( 'append_ellipsis' => true ) ) ) .
     163                        '</span>' ); ?>
    157164</h2>
    158165
    159166<?php
  • wp-admin/includes/dashboard.php

    diff --git wp-admin/includes/dashboard.php wp-admin/includes/dashboard.php
    index 0df8109..59a7539 100644
    function wp_dashboard_incoming_links_output() { 
    827827                        $publisher = "<strong>$publisher</strong>";
    828828
    829829                $content = $item->get_content();
    830                 $content = wp_html_excerpt($content, 50) . ' ...';
     830                $content = wp_html_excerpt( $content, 50, array( 'append_ellipsis' => true ) );
    831831
    832832                if ( $link )
    833833                        /* translators: incoming links feed, %1$s is other person, %3$s is content */
  • wp-admin/includes/media.php

    diff --git wp-admin/includes/media.php wp-admin/includes/media.php
    index beb3dcc..f531442 100644
    function get_media_item( $attachment_id, $args = null ) { 
    11081108        }
    11091109
    11101110        $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
    1111         $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : '';
     1111        $display_title = "<div class='filename new'><span class='title'>" .
     1112                                         wp_html_excerpt( $display_title, 60,
     1113                                                                          array( 'append_ellipsis' => true ) ) .
     1114                                         "</span></div>";
     1115        if ( ! $show_title ) {
     1116                $display_title = '';
     1117        }
    11121118
    11131119        $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
    11141120        $order = '';
  • wp-admin/includes/nav-menu.php

    diff --git wp-admin/includes/nav-menu.php wp-admin/includes/nav-menu.php
    index 6064462..9b4247e 100644
    function wp_nav_menu_locations_meta_box() { 
    501501                                        <?php foreach ( $menus as $menu ) : ?>
    502502                                        <option<?php selected( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $menu->term_id ); ?>
    503503                                                value="<?php echo $menu->term_id; ?>"><?php
    504                                                 $truncated_name = wp_html_excerpt( $menu->name, 40 );
    505                                                 echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '&hellip;';
     504                                                echo wp_html_excerpt( $menu->name, 40, array( 'append_ellipsis' => true ) );
    506505                                        ?></option>
    507506                                        <?php endforeach; ?>
    508507                                </select>
  • wp-admin/nav-menus.php

    diff --git wp-admin/nav-menus.php wp-admin/nav-menus.php
    index 361d0f6..50d2e68 100644
    if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) { 
    405405
    406406// Generate truncated menu names
    407407foreach( (array) $nav_menus as $key => $_nav_menu ) {
    408         $_nav_menu->truncated_name = trim( wp_html_excerpt( $_nav_menu->name, 40 ) );
    409         if ( $_nav_menu->truncated_name != $_nav_menu->name )
    410                 $_nav_menu->truncated_name .= '&hellip;';
    411 
     408        $_nav_menu->truncated_name = trim( wp_html_excerpt( $_nav_menu->name, 40, array( 'append_ellipsis' => true ) ) );
    412409        $nav_menus[$key]->truncated_name = $_nav_menu->truncated_name;
    413410}
    414411
  • wp-includes/comment.php

    diff --git wp-includes/comment.php wp-includes/comment.php
    index 09bad3c..1d043ad 100644
    function do_trackbacks($post_id) { 
    17561756        else
    17571757                $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
    17581758        $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
    1759         $excerpt = wp_html_excerpt($excerpt, 252) . '...';
     1759        $excerpt = wp_html_excerpt( $excerpt, 252, array( 'append_ellipsis' => true ) );
    17601760
    17611761        $post_title = apply_filters('the_title', $post->post_title, $post->ID);
    17621762        $post_title = strip_tags($post_title);
  • wp-includes/formatting.php

    diff --git wp-includes/formatting.php wp-includes/formatting.php
    index a0e9994..69be2e9 100644
    function wp_sprintf_l($pattern, $args) { 
    30843084 * be counted as one character. For example &amp; will be counted as 4, &lt; as
    30853085 * 3, etc.
    30863086 *
     3087 * The list of arguments that $options can contain, which will overwrite the
     3088 * defaults:
     3089 *
     3090 * append_ellipsis - Whether to append truncated string with an ellipsis.
     3091 * Defaults to false.
     3092 *
    30873093 * @since 2.5.0
    30883094 *
    30893095 * @param integer $str String to get the excerpt from.
    30903096 * @param integer $count Maximum number of characters to take.
     3097 * @param string|array $options Additional options affecting extracted output.
    30913098 * @return string The excerpt.
    30923099 */
    3093 function wp_html_excerpt( $str, $count ) {
     3100function wp_html_excerpt( $str, $count, $options = '' ) {
     3101        $defaults = array(
     3102                'append_ellipsis' => false
     3103        );
     3104        $options = wp_parse_args( $options, $defaults );
    30943105        $str = wp_strip_all_tags( $str, true );
    3095         $str = mb_substr( $str, 0, $count );
     3106        $new_str = mb_substr( $str, 0, $count );
    30963107        // remove part of an entity at the end
    3097         $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str );
    3098         return $str;
     3108        $new_str = preg_replace( '/&[^;\s]{0,6}$/', '', $new_str );
     3109        if( $options['append_ellipsis'] && strlen( $new_str ) < strlen( $str ) )
     3110                $new_str .= '&hellip;';
     3111        return $new_str;
    30993112}
    31003113
    31013114/**
  • wp-trackback.php

    diff --git wp-trackback.php wp-trackback.php
    index 06e4750..d31b21e 100644
    if ( !empty($tb_url) && !empty($title) ) { 
    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, array( 'append_ellipsis' => true ) );
     91        $excerpt = wp_html_excerpt( $excerpt, 252, array( 'append_ellipsis' => true ) );
    9292
    9393        $comment_post_ID = (int) $tb_id;
    9494        $comment_author = $blog_name;