GC_Embed::get_embed_handler_html()
最后更新于:2021-11-27 14:40:35
GC_Embed::get_embed_handler_html( array$attr, string$url)响应s embed HTML for a given URL from embed handlers.
参数
- $attr
-
(array) (Required) Shortcode attributes. Optional.
-
‘width’
(int) Width of the embed in pixels. -
‘height’
(int) Height of the embed in pixels.
-
‘width’
- $url
-
(string) (Required) The URL attempting to be embedded.
响应
(string|false) The embed HTML on success, false otherwise.
源文件
文件: gc-includes/class-gc-embed.php
public function get_embed_handler_html( $attr, $url ) {
$rawattr = $attr;
$attr = gc_parse_args( $attr, gc_embed_defaults( $url ) );
ksort( $this->handlers );
foreach ( $this->handlers as $priority => $handlers ) {
foreach ( $handlers as $id => $handler ) {
if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
$return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr );
if ( false !== $return ) {
/**
* Filters the returned embed HTML.
*
* @since 2.9.0
*
* @see GC_Embed::shortcode()
*
* @param string|false $return The HTML result of the shortcode, or false on failure.
* @param string $url The embed URL.
* @param array $attr An array of shortcode attributes.
*/
return apply_filters( 'embed_handler_html', $return, $url, $attr );
}
}
}
}
return false;
}