Ticket #32992: ticket#32992.patch
File ticket#32992.patch, 1.1 KB (added by , 10 years ago) |
---|
-
formatting.php
2014 2014 * @since 0.71 2015 2015 * 2016 2016 * @param string $text Content to convert URIs. 2017 * @param boolean $target_blank Open the link in a new tab/window or not. 2017 2018 * @return string Content with converted URIs. 2018 2019 */ 2019 function make_clickable( $text ) {2020 function make_clickable( $text, $target_blank = false ) { 2020 2021 $r = ''; 2021 2022 $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags 2022 2023 $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code> … … 2071 2072 } 2072 2073 2073 2074 // Cleanup of accidental links within links 2074 return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r ); 2075 $r = preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r ); 2076 2077 // Add target attribute with value "_blank" if needed 2078 if ( $target_blank === true ) { 2079 $r = str_replace( '<a ', '<a target="_blank" ', $r ); 2080 } 2081 2082 return $r; 2075 2083 } 2076 2084 2077 2085 /**