Changeset 10830 for trunk/src/bp-core/bp-core-template.php
- Timestamp:
- 05/31/2016 06:32:24 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-template.php
r10825 r10830 784 784 * http://book.cakephp.org/view/1469/Text#truncate-1625 785 785 * 786 * ### Options:787 *788 * - `ending` Will be used as Ending and appended to the trimmed string.789 * - `exact` If false, $text will not be cut mid-word.790 * - `html` If true, HTML tags would be handled correctly.791 * - `filter_shortcodes` If true, shortcodes will be stripped before truncating.792 *793 786 * @since 1.0.0 787 * @since 2.6.0 Added 'strip_tags' and 'remove_links' as $options args. 794 788 * 795 789 * @param string $text String to truncate. … … 806 800 * @type bool $filter_shortcodes If true, shortcodes will be stripped. 807 801 * Default: true. 802 * @type bool $strip_tags If true, HTML tags will be stripped. Default: false. 803 * Only applicable if $html is set to false. 804 * @type bool $remove_links If true, URLs will be stripped. Default: false. 805 * Only applicable if $html is set to false. 808 806 * } 809 807 * @return string Trimmed string. … … 818 816 'exact' => false, 819 817 'html' => true, 820 'filter_shortcodes' => $filter_shortcodes_default 818 'filter_shortcodes' => $filter_shortcodes_default, 819 'strip_tags' => false, 820 'remove_links' => false, 821 821 ), 'create_excerpt' ); 822 822 … … 904 904 } 905 905 } else { 906 // Strip HTML tags if necessary. 907 if ( ! empty( $r['strip_tags'] ) ) { 908 $text = strip_tags( $text ); 909 } 910 911 // Remove links if necessary. 912 if ( ! empty( $r['remove_links'] ) ) { 913 $text = preg_replace( '#^\s*(https?://[^\s"]+)\s*$#im', '', $text ); 914 } 915 906 916 if ( mb_strlen( $text ) <= $length ) { 907 return $text; 917 /** 918 * Filters the final generated excerpt. 919 * 920 * @since 1.1.0 921 * 922 * @param string $truncate Generated excerpt. 923 * @param string $original_text Original text provided. 924 * @param int $length Length of returned string, including ellipsis. 925 * @param array $options Array of HTML attributes and options. 926 */ 927 return apply_filters( 'bp_create_excerpt', $text, $original_text, $length, $options ); 908 928 } else { 909 929 $truncate = mb_substr( $text, 0, $length - mb_strlen( $ending ) ); … … 986 1006 } 987 1007 988 /** 989 * Filters the final generated excerpt. 990 * 991 * @since 1.1.0 992 * 993 * @param string $truncate Generated excerpt. 994 * @param string $original_text Original text provided. 995 * @param int $length Length of returned string, including ellipsis. 996 * @param array $options Array of HTML attributes and options. 997 */ 1008 /** This filter is documented in /bp-core/bp-core-template.php */ 998 1009 return apply_filters( 'bp_create_excerpt', $truncate, $original_text, $length, $options ); 999 1010 }
Note: See TracChangeset
for help on using the changeset viewer.