From ec94944ae4b5af2c2dda675711b627d98a72a2b0 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 29 Aug 2023 15:33:43 +0000 Subject: [PATCH] Media: Prevent warning if `[caption]` shortcode is used without attributes. Props maltfield, aslamdoctor. Fixes #59206. git-svn-id: https://develop.svn.wordpress.org/trunk@56488 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/media.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index e037a0608b..d365e0b1e1 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -2361,6 +2361,10 @@ add_shortcode( 'caption', 'img_caption_shortcode' ); * @return string HTML content to display the caption. */ function img_caption_shortcode( $attr, $content = '' ) { + if ( ! $attr ) { + $attr = array(); + } + // New-style shortcode with the caption inside the shortcode with the link and image tags. if ( ! isset( $attr['caption'] ) ) { if ( preg_match( '#((?:]+>\s*)?]+>(?:\s*)?)(.*)#is', $content, $matches ) ) {