Make WordPress Core

Ticket #32992: ticket#32992.patch

File ticket#32992.patch, 1.1 KB (added by nicolamustone, 10 years ago)
  • formatting.php

     
    20142014 * @since 0.71
    20152015 *
    20162016 * @param string $text Content to convert URIs.
     2017 * @param boolean $target_blank Open the link in a new tab/window or not.
    20172018 * @return string Content with converted URIs.
    20182019 */
    2019 function make_clickable( $text ) {
     2020function make_clickable( $text, $target_blank = false ) {
    20202021        $r = '';
    20212022        $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags
    20222023        $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
     
    20712072        }
    20722073
    20732074        // 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;
    20752083}
    20762084
    20772085/**