From 66d775eeec308ed58b7e81d1476cdd7059d946b3 Mon Sep 17 00:00:00 2001 From: arthur Date: Tue, 27 Aug 2024 19:32:56 +0900 Subject: [PATCH] Shortcode: Get rid of custom shortcodes for Youtube and Vimeo in favor of Core --- .../jetpack/modules/shortcodes/vimeo.php | 47 ------------------- .../jetpack/modules/shortcodes/youtube.php | 20 -------- 2 files changed, 67 deletions(-) diff --git a/projects/plugins/jetpack/modules/shortcodes/vimeo.php b/projects/plugins/jetpack/modules/shortcodes/vimeo.php index b462c9a09fab9..0799361dc1d8d 100644 --- a/projects/plugins/jetpack/modules/shortcodes/vimeo.php +++ b/projects/plugins/jetpack/modules/shortcodes/vimeo.php @@ -246,53 +246,6 @@ class_exists( 'Jetpack_AMP_Support' ) } add_shortcode( 'vimeo', 'vimeo_shortcode' ); -/** - * Callback to modify output of embedded Vimeo video using Jetpack's shortcode. - * - * @since 3.9 - * - * @param array $matches Regex partial matches against the URL passed. - * @param array $attr Attributes received in embed response. - * @param array $url Requested URL to be embedded. - * - * @return string Return output of Vimeo shortcode with the proper markup. - */ -function wpcom_vimeo_embed_url( $matches, $attr, $url ) { - $vimeo_info = array( $url ); - - // If we are able to extract a video ID, use it in the shortcode instead of the full URL. - if ( ! empty( $matches['video_id'] ) ) { - $vimeo_info = array( 'id' => $matches['video_id'] ); - } - - return vimeo_shortcode( $vimeo_info ); -} - -/** - * For bare URLs on their own line of the form. - * - * Accepted formats: - * https://vimeo.com/289091934/cd1f466bcc - * https://vimeo.com/album/2838732/video/6342264 - * https://vimeo.com/6342264 - * http://player.vimeo.com/video/18427511 - * - * @since 3.9 - * - * @uses wpcom_vimeo_embed_url - */ -function wpcom_vimeo_embed_url_init() { - wp_embed_register_handler( 'wpcom_vimeo_embed_url', '#https?://(?:[^/]+\.)?vimeo\.com/(?:album/(?\d+)/)?(?:video/)?(?\d+)(?:/.*)?$#i', 'wpcom_vimeo_embed_url' ); -} - -/* - * Register handler to modify Vimeo embeds using Jetpack's shortcode output. - * This does not happen on WordPress.com, since embeds are handled by core there. - */ -if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) { - add_action( 'init', 'wpcom_vimeo_embed_url_init' ); -} - /** * Transform a Vimeo embed iFrame into a Vimeo shortcode. * diff --git a/projects/plugins/jetpack/modules/shortcodes/youtube.php b/projects/plugins/jetpack/modules/shortcodes/youtube.php index 14acabc318087..b1e991ec6f2c3 100644 --- a/projects/plugins/jetpack/modules/shortcodes/youtube.php +++ b/projects/plugins/jetpack/modules/shortcodes/youtube.php @@ -523,26 +523,6 @@ function jetpack_shortcode_youtube_dimensions( $query_args ) { return array( $w, $h ); } -/** - * For bare URLs on their own line of the form - * http://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US - * - * @param array $matches Regex partial matches against the URL passed. - * @param array $attr Attributes received in embed response. - * @param array $url Requested URL to be embedded. - */ -function wpcom_youtube_embed_crazy_url( $matches, $attr, $url ) { - return youtube_id( $url ); -} - -/** - * Add a new handler to automatically transform custom Youtube URLs (like playlists) into embeds. - */ -function wpcom_youtube_embed_crazy_url_init() { - wp_embed_register_handler( 'wpcom_youtube_embed_crazy_url', '#https?://(?:www\.)?(?:youtube.com/(?:v/|playlist|watch[/\#?])|youtu\.be/).*#i', 'wpcom_youtube_embed_crazy_url' ); -} -add_action( 'init', 'wpcom_youtube_embed_crazy_url_init' ); - if ( ! is_admin() /**