From ee48cca207fa28757e85a25a6e91c121a1701f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helen=20Hou-Sand=C3=AD?= Date: Mon, 16 Nov 2020 19:20:09 +0000 Subject: [PATCH] Media: Avoid fatal error in `wp_prepare_attachment_for_js(). In certain contexts, in particular on the front-end, `get_media_states()` is not availble. Props rebasaurus. Fixes #51791. Built from https://develop.svn.wordpress.org/trunk@49613 git-svn-id: http://core.svn.wordpress.org/trunk@49351 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 8 +++++--- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 8b8b862e5d..3d8507ff90 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -4029,9 +4029,11 @@ function wp_prepare_attachment_for_js( $attachment ) { $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'in_modal' => true ) ); } - $media_states = get_media_states( $attachment ); - if ( ! empty( $media_states ) ) { - $response['mediaStates'] = implode( ', ', $media_states ); + if ( function_exists( 'get_media_states' ) ) { + $media_states = get_media_states( $attachment ); + if ( ! empty( $media_states ) ) { + $response['mediaStates'] = implode( ', ', $media_states ); + } } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index b87bbc1b28..344a968f57 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-beta4-49612'; +$wp_version = '5.6-beta4-49613'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.