| @@ -13,8 +13,12 @@ | ||
| 13 | 13 | * |
| 14 | 14 | * @package automattic/jetpack |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 18 | + exit( 0 ); | |
| 19 | +} | |
| 20 | + | |
| 17 | 21 | /** |
| 18 | 22 | * Extract Vimeo ID from shortcode. |
| 19 | 23 | * |
| 20 | 24 | * @param array $atts Shortcode attributes. |
| @@ -341,10 +345,13 @@ | ||
| 341 | 345 | } |
| 342 | 346 | |
| 343 | 347 | return $content; |
| 344 | 348 | } |
| 345 | -add_filter( 'pre_kses', 'vimeo_embed_to_shortcode' ); | |
| 346 | 349 | |
| 350 | +if ( jetpack_shortcodes_should_hook_pre_kses() ) { | |
| 351 | + add_filter( 'pre_kses', 'vimeo_embed_to_shortcode' ); | |
| 352 | +} | |
| 353 | + | |
| 347 | 354 | /** |
| 348 | 355 | * Replaces shortcodes and plain-text URLs to Vimeo videos with Vimeo embeds. |
| 349 | 356 | * Covers shortcode usage [vimeo 1234] | [vimeo https://vimeo.com/1234] | [vimeo http://vimeo.com/1234] |
| 350 | 357 | * Or plain text URLs https://vimeo.com/1234 | vimeo.com/1234 | //vimeo.com/1234 |
| @@ -397,9 +404,9 @@ | ||
| 397 | 404 | * @param array $matches An array containing a Vimeo URL. |
| 398 | 405 | * @return string The Vimeo HTML embed code. |
| 399 | 406 | */ |
| 400 | 407 | function vimeo_link_callback( $matches ) { |
| 401 | - $id = isset( $matches[2] ) ? $matches[2] : $matches[1]; | |
| 408 | + $id = $matches[2] ?? $matches[1]; | |
| 402 | 409 | if ( isset( $id ) && ctype_digit( $id ) ) { |
| 403 | 410 | return "\n" . vimeo_shortcode( array( 'id' => $id ) ) . "\n"; |
| 404 | 411 | } |
| 405 | 412 | return $matches[0]; |