', esc_url( $url ) ); } else { $embed = sprintf( '', esc_url( $url ) ); } // 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'] ) { return $embed . wp_scripts()->do_items( array( 'jetpack-facebook-embed' ) ); } 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'] ); }