OS : Linux
PHP Version : 7.4.33
Software :
', esc_url( $url ) );
} else {
$width = 552; // As of 01/2017, the default width of Facebook embeds when no width attribute provided.
global $content_width;
if ( isset( $content_width ) ) {
$width = min( $width, $content_width );
}
$embed = sprintf( '
', esc_url( $url ), esc_attr( $width ) );
}
// since Facebook is a faux embed, we need to load the JS SDK in the wpview embed iframe.
if (
defined( 'DOING_AJAX' )
&& DOING_AJAX
// No need to check for a nonce here, that's already handled by Core further up.
&& ! empty( $_POST['action'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
&& 'parse-embed' === $_POST['action'] // phpcs:ignore WordPress.Security.NonceVerification.Missing
) {
ob_start();
wp_scripts()->do_items( array( 'jetpack-facebook-embed' ) );
$scripts = ob_get_clean();
return $embed . $scripts;
} else {
wp_enqueue_script( 'jetpack-facebook-embed' );
return $embed;
}
}
/**
* Shortcode handler.
*
* @param array $atts Shortcode attributes.
*/
function jetpack_facebook_shortcode_handler( $atts ) {
global $wp_embed;
if ( empty( $atts['url'] ) ) {
return;
}
if ( ! preg_match( JETPACK_FACEBOOK_EMBED_REGEX, $atts['url'] )
&& ! preg_match( JETPACK_FACEBOOK_PHOTO_EMBED_REGEX, $atts['url'] )
&& ! preg_match( JETPACK_FACEBOOK_VIDEO_EMBED_REGEX, $atts['url'] )
&& ! preg_match( JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX, $atts['url'] ) ) {
return;
}
return $wp_embed->shortcode( $atts, $atts['url'] );
}
add_shortcode( 'facebook', 'jetpack_facebook_shortcode_handler' );