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
This commit is contained in:
Helen Hou-Sandí 2020-11-16 19:20:09 +00:00
parent 801152b9d7
commit ee48cca207
2 changed files with 6 additions and 4 deletions

View File

@ -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 );
}
}
/**

View File

@ -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.