Cleanups for audio/video metadata, see [27862].

see #27574.

Built from https://develop.svn.wordpress.org/trunk@27864


git-svn-id: http://core.svn.wordpress.org/trunk@27695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin
2014-03-30 21:08:14 +00:00
parent 7eb24edf4e
commit c95f232727
5 changed files with 22 additions and 23 deletions

View File

@@ -237,19 +237,15 @@ function edit_post( $post_data = null ) {
}
}
if ( 'attachment' === $post_data['post_type'] && preg_match( '#^audio|video#', $post_data['post_mime_type'] ) ) {
if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) {
$id3data = wp_get_attachment_metadata( $post_ID );
if ( ! is_array( $id3data ) ) {
$id3data = array();
}
foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
foreach ( wp_get_relevant_id3_keys( $post ) as $key => $label ) {
if ( isset( $post_data[ 'id3_' . $key ] ) ) {
if ( current_user_can( 'unfiltered_html' ) ) {
$id3data[ $key ] = wp_unslash( $post_data[ 'id3_' . $key ] );
} else {
$id3data[ $key ] = wp_unslash( wp_kses_post( $post_data[ 'id3_' . $key ] ) );
}
$id3data[ $key ] = sanitize_post_field( wp_unslash( $post_data[ 'id3_' . $key ] ) );
}
}
wp_update_attachment_metadata( $post_ID, $id3data );