Skip to:
Content

BuddyPress.org

Changeset 3610


Ignore:
Timestamp:
12/29/2010 03:22:44 PM (16 years ago)
Author:
boonebgorges
Message:

Changes bp_create_excerpt() so that excerpts are generated using character counts rather than word counts. Modifies excerpt_length throughout BP to account for the change. Fixes #1222

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-templatetags.php

    r3600 r3610  
    863863                        return false;
    864864
    865                 $latest_update = '"' . apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], 40 ) ) ) ) . '"';
     865                $latest_update = '"' . apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], 180 ) ) ) ) . '"';
    866866                $latest_update .= ' &middot; <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $update['id'] . '/"> ' . __( 'View', 'buddypress' ) . '</a>';
    867867
    … …  
    11021102
    11031103                if ( 'activity_update' == $activities_template->activity->type )
    1104                         $title .= ': ' . strip_tags( bp_create_excerpt( $activities_template->activity->content, 15 ) );
     1104                        $title .= ': ' . strip_tags( bp_create_excerpt( $activities_template->activity->content, 70 ) );
    11051105
    11061106                return apply_filters( 'bp_get_activity_feed_item_title', $title );
  • trunk/bp-core/bp-core-templatetags.php

    r3607 r3610  
    375375
    376376                $defaults = array(
    377                         'length' => 15
     377                        'length' => 70
    378378                );
    379379
    … …  
    11161116 * @return str The excerpt text
    11171117 */
    1118 function bp_create_excerpt( $text, $excerpt_length = 55, $filter_shortcodes = true ) { // Fakes an excerpt if needed
     1118function bp_create_excerpt( $text, $excerpt_length = 225, $filter_shortcodes = true ) { // Fakes an excerpt if needed
    11191119        $original_text = $text;
    11201120        $text = str_replace(']]>', ']]&gt;', $text);
    … …  
    11231123                $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
    11241124
    1125         $words = preg_split(
    1126                 "%\s*((?:<[^>]+>)+\S*)\s*|\s+%s",
    1127                 $text,
    1128                 $excerpt_length + 1,
    1129                 PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
    1130         );
    1131 
    1132         if (count($words) > $excerpt_length) {
    1133                 array_pop($words);
    1134                 array_push($words, '[...]');
    1135                 $text = implode(' ', $words);
    1136         }
    1137 
     1125        preg_match( "%\s*((?:<[^>]+>)+\S*)\s*|\s+%s", $text, $matches, PREG_OFFSET_CAPTURE, $excerpt_length );
     1126       
     1127        if ( !empty( $matches ) ) {
     1128                $pos = array_pop( array_pop( $matches ) );     
     1129                $text = substr( $text, 0, $pos ) . ' [...]';
     1130        }
     1131       
    11381132        return apply_filters( 'bp_create_excerpt', $text, $original_text );
    11391133}
  • trunk/bp-forums/bp-forums-templatetags.php

    r3561 r3610  
    520520
    521521                $defaults = array(
    522                         'length' => 10
     522                        'length' => 45
    523523                );
    524524
  • trunk/bp-messages/bp-messages-templatetags.php

    r3592 r3610  
    214214                global $messages_template;
    215215
    216                 return apply_filters( 'bp_get_message_thread_excerpt', strip_tags( bp_create_excerpt( $messages_template->thread->last_message_content, 10 ) ) );
     216                return apply_filters( 'bp_get_message_thread_excerpt', strip_tags( bp_create_excerpt( $messages_template->thread->last_message_content, 75 ) ) );
    217217        }
    218218
Note: See TracChangeset for help on using the changeset viewer.