Title: _make_url_clickable_cb
Published: April 25, 2014
Last modified: August 20, 2026

---

# _make_url_clickable_cb( array $matches ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#changelog)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Callback to convert URI match to HTML A element.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#description)󠁿

This function was backported from 2.5.0 to 2.3.2. Regex callback for [make_clickable()](https://developer.wordpress.org/reference/functions/make_clickable/).

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#parameters)󠁿

 `$matches`arrayrequired

Single Regex Match.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#return)󠁿

 string HTML A element with URI address.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#source)󠁿

    ```php
    function _make_url_clickable_cb( $matches ) {
    	$url = $matches[2];

    	if ( ')' === $matches[3] && strpos( $url, '(' ) ) {
    		/*
    		 * If the trailing character is a closing parenthesis, and the URL has an opening parenthesis in it,
    		 * add the closing parenthesis to the URL. Then we can let the parenthesis balancer do its thing below.
    		 */
    		$url   .= $matches[3];
    		$suffix = '';
    	} else {
    		$suffix = $matches[3];
    	}

    	if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) {
    		$url .= $matches[4];
    	}

    	// Include parentheses in the URL only if paired.
    	while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
    		$suffix = strrchr( $url, ')' ) . $suffix;
    		$url    = substr( $url, 0, strrpos( $url, ')' ) );
    	}

    	$url = esc_url( $url );
    	if ( empty( $url ) ) {
    		return $matches[0];
    	}

    	$rel_attr = _make_clickable_rel_attr( $url );

    	return $matches[1] . "<a href=\"{$url}\"{$rel_attr}>{$url}</a>" . $suffix;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/formatting.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/formatting.php#L3012)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/formatting.php#L3012-L3044)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#related)󠁿

| Uses | Description | 
| [_make_clickable_rel_attr()](https://developer.wordpress.org/reference/functions/_make_clickable_rel_attr/)`wp-includes/formatting.php` |

Helper function used to build the “rel” attribute for a URL when creating an anchor using [make_clickable()](https://developer.wordpress.org/reference/functions/make_clickable/) .

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_make_url_clickable_cb/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.3.2](https://developer.wordpress.org/reference/since/2.3.2/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_make_url_clickable_cb%2F)
before being able to contribute a note or feedback.