is_offline_mode() ) { return $provider; } $oembed_proxy_url = esc_url_raw( sprintf( '%s/wpcom/v2/oembed-proxy', JETPACK__WPCOM_JSON_API_BASE, Jetpack_Options::get_option( 'id' ) ) ); add_filter( 'oembed_remote_get_args', 'jetpack_twitter_oembed_remote_get_args', 10, 2 ); } return str_replace( 'https://publish.twitter.com/oembed', $oembed_proxy_url, $provider ); } add_filter( 'oembed_fetch_url', 'jetpack_proxy_twitter_oembed_provider', 10 ); /** * Add JP auth headers if we're proxying through WP.com. * * @param array $args oEmbed remote get arguments. * @param string $url URL to be inspected. */ function jetpack_twitter_oembed_remote_get_args( $args, $url ) { if ( ! wp_startswith( $url, Constants::get_constant( 'JETPACK__WPCOM_JSON_API_BASE' ) ) ) { return $args; } $method = 'GET'; $signed_request = Client::build_signed_request( compact( 'url', 'method' ) ); if ( is_wp_error( $signed_request ) ) { return $args; } return $signed_request['request']; }