_make_clickable_rel_attr( string $url ): string
- Since
- 6.2.0
- Source
wp-includes/formatting.php:3104
Compatibility
- WordPress
- since 6.2.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$urlstring- The URL.
Return value
string- The rel attribute for the anchor or an empty string if no rel attribute should be added.
Performance profile
How much work a call to _make_clickable_rel_attr() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 36–47
- Plugin surface
- 1 hook
- Called by
- 2
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 48.
Third-party callbacks on 'make_clickable_rel' run inside this call, and their cost is not bounded by anything here.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost _make_clickable_rel_attr() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!$rel_parts | 36–42 | wp_parse_url(), strtolower(), wp_allowed_protocols(), array_intersect(), wp_is_internal_link(), current_filter(), apply_filters() |
$rel_parts | 41–47 | wp_parse_url(), strtolower(), wp_allowed_protocols(), array_intersect(), wp_is_internal_link(), current_filter(), apply_filters(), esc_attr() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 48 | 36–47 | 4 | |
| 8.5 | 48 | 36–47 | 4 | |
| 8.4 | 48 | 36–47 | 4 | 7 fewer instructions than PHP 8.3 |
| 8.3 | 55 | 40–54 | 4 | |
| 8.2 | 55 | 40–54 | 4 | |
| 8.1 | 55 | 40–54 | 4 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 56 | 40–55 | 4 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while _make_clickable_rel_attr() runs, in this order:
- apply_filters( make_clickable_rel )filterline 3129 (+25 into the body)
Filters the rel value that is added to URL matches converted to links.
Uses · 6
- wp_parse_url()A wrapper for PHP's parse_url() function that handles consistency in the return values across PHP versions.
- wp_allowed_protocols()Retrieves a list of protocols to allow in HTML attributes.
- wp_is_internal_link()Determines whether or not the specified URL is of a host included in the internal hosts list.
- current_filter()Retrieves the name of the current filter hook.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- esc_attr()Escaping for HTML attributes.
Used by · 2
- _make_url_clickable_cb()Callback to convert URI match to HTML A element.
- _make_web_ftp_clickable_cb()Callback to convert URL match to HTML A element.
Source code
function _make_clickable_rel_attr( $url ) { $rel_parts = array(); $scheme = strtolower( wp_parse_url( $url, PHP_URL_SCHEME ) ); $nofollow_schemes = array_intersect( wp_allowed_protocols(), array( 'https', 'http' ) ); // Apply "nofollow" to external links with qualifying URL schemes (mailto:, tel:, etc... shouldn't be followed). if ( ! wp_is_internal_link( $url ) && in_array( $scheme, $nofollow_schemes, true ) ) { $rel_parts[] = 'nofollow'; } // Apply "ugc" when in comment context. if ( 'comment_text' === current_filter() ) { $rel_parts[] = 'ugc'; } $rel = implode( ' ', $rel_parts ); /** * Filters the rel value that is added to URL matches converted to links. * * @since 5.3.0 * * @param string $rel The rel value. * @param string $url The matched URL being converted to a link tag. */ $rel = apply_filters( 'make_clickable_rel', $rel, $url ); $rel_attr = $rel ? ' rel="' . esc_attr( $rel ) . '"' : ''; return $rel_attr;}Changelog
Introduced in 6.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/formatting.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.