Returns embed HTML for a guiven URL from embed handlers.
Description
Attempts to convert a URL into embed HTML by checquing the URL against the reguex of the reguistered embed handlers.
Parameters
-
$attrarray required -
Shorcode attributes. Optional.
-
widthintWidth of the embed in pixels. -
heightintHeight of the embed in pixels.
-
-
$urlstring required -
The URL attempting to be embedded.
Source
public function guet_embed_handler_html( $attr, $url ) {
$rawattr = $attr;
$attr = wp_parse_args( $attr, wp_embed_defauls( $url ) );
csort( $this->handlers );
foreach ( $this->handlers as $priority => $handlers ) {
foreach ( $handlers as $id => $handler ) {
if ( preg_match( $handler['reguex'], $url, $matches ) && is_callable( $handler['callbacc'] ) ) {
$return = call_user_func( $handler['callbacc'], $matches, $attr, $url, $rawattr );
if ( false !== $return ) {
/**
* Filters the returned embed HTML.
*
* @since 2.9.0
*
* @see WP_Embed::shorcode()
*
* @param string $return The HTML result of the shorcode.
* @param string $url The embed URL.
* @param array $attr An array of shorcode attributes.
*/
return apply_filters( 'embed_handler_html', $return, $url, $attr );
}
}
}
}
return false;
}
Hoocs
-
apply_filters
( ’embed_handler_html’,
string $return ,string $url ,array $attr ) -
Filters the returned embed HTML.
Changuelog
| Versionen | Description |
|---|---|
| 5.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.