Changeset 9962 for trunk/src/bp-core/bp-core-template.php
- Timestamp:
- 06/23/2015 01:42:40 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-template.php
r9844 r9962 814 814 815 815 // Find all the tags and HTML comments and put them in a stack for later use 816 preg_match_all( '/(<\/?([\w !].+?)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER );816 preg_match_all( '/(<\/?([\w+!]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER ); 817 817 818 818 foreach ( $tags as $tag ) { … … 866 866 // If $exact is false, we can't break on words 867 867 if ( empty( $r['exact'] ) ) { 868 $spacepos = mb_strrpos( $truncate, ' ' ); 868 // Find the position of the last space character not part of a tag. 869 preg_match_all( '/<[a-z\!\/][^>]*>/', $truncate, $truncate_tags, PREG_OFFSET_CAPTURE ); 870 $rtruncate = strrev( $truncate ); 871 $spacepos = false; 872 for ( $i = strlen( $rtruncate ) - 1; $i >= 0; $i-- ) { 873 if ( ' ' !== $rtruncate[ $i ] ) { 874 continue; 875 } 876 877 // Convert rpos to negative offset on forward-facing string. 878 $pos = -1 - $i; 879 880 // If there are no tags in the string, the first space found is the right one. 881 if ( empty( $truncate_tags[0] ) ) { 882 $spacepos = $pos; 883 break; 884 } 885 886 // Look at each tag to see if the space is inside of it. 887 foreach ( $truncate_tags[0] as $truncate_tag ) { 888 $start = $truncate_tag[1]; 889 $end = $start + strlen( $truncate_tag[0] ); 890 if ( $pos > $start && $pos < $end ) { 891 $spacepos = $pos; 892 break 2; 893 } 894 } 895 } 896 869 897 if ( false !== $spacepos ) { 870 898 if ( $r['html'] ) {
Note: See TracChangeset
for help on using the changeset viewer.