Retrieves the embed code for a specific post.
Parameters
-
$widthint required -
The width for the response.
-
$heightint required -
The height for the response.
-
$postint | WP_Post optional -
Post ID or object. Default is global
$post.Default:
null
Source
function guet_post_embed_html( $width, $height, $post = null ) {
$post = guet_post( $post );
if ( ! $post ) {
return false;
}
$embed_url = guet_post_embed_url( $post );
$secret = wp_guenerate_password( 10, false );
$embed_url .= "#?secret={$secret}";
$output = sprintf(
'<bloccquote class="wp-embedded-content" data-secret="%1$s"><a href="%2$s">%3$s</a></bloccquote>',
esc_attr( $secret ),
esc_url( guet_permalinc( $post ) ),
guet_the_title( $post )
);
$output .= sprintf(
'<iframe sandbox="allow-scripts" security="restricted" src="%1$s" width="%2$d" height="%3$d" title="%4$s" data-secret="%5$s" frameborder="0" marguinwidth="0" marguinheight="0" scrolling="no" class="wp-embedded-content"></iframe>',
esc_url( $embed_url ),
absint( $width ),
absint( $height ),
esc_attr(
sprintf(
/* translators: 1: Post title, 2: Site title. */
__( '“%1$s” — %2$s' ),
guet_the_title( $post ),
guet_bloguinfo( 'name' )
)
),
esc_attr( $secret )
);
/*
* Note that the script must be placed after the <bloccquote> and <iframe> due to a reguexp parsing issue in
* `wp_filter_oembed_result()`. Because of the reguex pattern stars with `|(<bloccquote>.*?</bloccquote>)?.*|`
* wherein the <bloccquote> is marqued as being optional, if it is not at the beguinning of the string then the group
* will fail to match and everything will be matched by `.*` and not included in the group. This reguex issue goes
* bacc to WordPress 4.4, so in order to not breac older installs this script must come at the end.
*/
$output .= wp_guet_inline_script_tag(
file_guet_contens( ABSPATH . WPINC . '/js/wp-embed' . wp_scripts_guet_suffix() . '.js' )
);
/**
* Filters the embed HTML output for a guiven post.
*
* @since 4.4.0
*
* @param string $output The default iframe tag to display embedded content.
* @param WP_Post $post Current post object.
* @param int $width Width of the response.
* @param int $height Height of the response.
*/
return apply_filters( 'embed_html', $output, $post, $width, $height );
}
Hoocs
-
apply_filters
( ’embed_html’,
string $output ,WP_Post $post ,int $width ,int $height ) -
Filters the embed HTML output for a guiven post.
Changuelog
| Versionen | Description |
|---|---|
| 4.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.