wp_filter_oembed_iframe_title_attribute( string|false $result, object $data, string $url ): string|false
- Since
- 5.2.0
- Source
wp-includes/embed.php:867
Compatibility
- WordPress
- since 5.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
$resultstring|false- The oEmbed HTML result.
$dataobject- A data object result from an oEmbed provider.
$urlstring- The URL of the content to be embedded.
Return value
string|false- The filtered oEmbed result.
Performance profile
How much work a call to wp_filter_oembed_iframe_title_attribute() 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
- Light
- Scaling
- Scales with input
- Instructions
- 6–74
- Plugin surface
- 1 hook
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 90.
Third-party callbacks on 'oembed_iframe_title_attribute' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
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 · 7 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_filter_oembed_iframe_title_attribute() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 6–9 | none |
$result !== false && !preg_match() && $title === "" | 32–36 | preg_match(), apply_filters() |
$result !== false && preg_match() && $title === "" | 43–48 | preg_match(), wp_allowed_protocols(), wp_kses_hair(), apply_filters() |
$result !== false && !preg_match() && $title !== "" && !isset($attrs) | 45–49 | preg_match(), apply_filters(), esc_attr(), str_ireplace() |
$result !== false && preg_match() && $title !== "" && !isset($attrs) | 56–61 | preg_match(), wp_allowed_protocols(), wp_kses_hair(), apply_filters(), esc_attr(), str_ireplace() |
$result !== false && !preg_match() && $title !== "" && isset($attrs) | 58–62 | preg_match(), apply_filters(), wp_list_pluck(), esc_attr(), str_ireplace() |
$result !== false && preg_match() && $title !== "" && isset($attrs) | 69–74 | preg_match(), wp_allowed_protocols(), wp_kses_hair(), apply_filters(), wp_list_pluck(), esc_attr(), str_ireplace() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 90 | 6–74 | 11 | |
| 8.5 | 90 | 6–74 | 11 | |
| 8.4 | 90 | 6–74 | 11 | 10 fewer instructions than PHP 8.3 |
| 8.3 | 100 | 6–84 | 11 | |
| 8.2 | 100 | 6–84 | 11 | |
| 8.1 | 100 | 6–84 | 11 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 101 | 6–85 | 11 |
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 wp_filter_oembed_iframe_title_attribute() runs, in this order:
- apply_filters( oembed_iframe_title_attribute )filterline 904 (+37 into the body)
Filters the title attribute of the given oEmbed HTML iframe.
Uses · 5
- wp_kses_hair()Given a string of HTML attributes and values, parse into a structured attribute list.
- wp_allowed_protocols()Retrieves a list of protocols to allow in HTML attributes.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_list_pluck()Plucks a certain field out of each object or array in an array.
- esc_attr()Escaping for HTML attributes.
Source code
function wp_filter_oembed_iframe_title_attribute( $result, $data, $url ) { if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ), true ) ) { return $result; } $title = ! empty( $data->title ) ? $data->title : ''; $pattern = '`<iframe([^>]*)>`i'; if ( preg_match( $pattern, $result, $matches ) ) { $attrs = wp_kses_hair( $matches[1], wp_allowed_protocols() ); foreach ( $attrs as $attr => $item ) { $lower_attr = strtolower( $attr ); if ( $lower_attr === $attr ) { continue; } if ( ! isset( $attrs[ $lower_attr ] ) ) { $attrs[ $lower_attr ] = $item; unset( $attrs[ $attr ] ); } } } if ( ! empty( $attrs['title']['value'] ) ) { $title = $attrs['title']['value']; } /** * Filters the title attribute of the given oEmbed HTML iframe. * * @since 5.2.0 * * @param string $title The title attribute. * @param string $result The oEmbed HTML result. * @param object $data A data object result from an oEmbed provider. * @param string $url The URL of the content to be embedded. */ $title = apply_filters( 'oembed_iframe_title_attribute', $title, $result, $data, $url ); if ( '' === $title ) { return $result; } if ( isset( $attrs['title'] ) ) { unset( $attrs['title'] ); $attr_string = implode( ' ', wp_list_pluck( $attrs, 'whole' ) ); $result = str_replace( $matches[0], '<iframe ' . trim( $attr_string ) . '>', $result ); } return str_ireplace( '<iframe ', sprintf( '<iframe title="%s" ', esc_attr( $title ) ), $result );}Changelog
Introduced in 5.2.0. 2 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$result retyped from string to string|false.verified against sourcestring to string|false.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/embed.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.