', 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 && ! empty( $_POST['action'] ) && 'parse-embed' == $_POST['action'] ) { 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; } } add_shortcode( 'facebook', 'jetpack_facebook_shortcode_handler' ); 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'] ); }