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

see #27574.


git-svn-id: https://develop.svn.wordpress.org/trunk@27864 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2014-03-30 21:07:04 +00:00
parent 2846655164
commit 877ffc087f
5 changed files with 22 additions and 23 deletions

View File

@@ -140,7 +140,7 @@ if ( 'attachment' == $post_type ) {
add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
add_action( 'edit_form_after_title', 'edit_form_image_editor' );
if ( preg_match( '#^audio#', $post->post_mime_type ) ) {
if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' );
}
} else {

View File

@@ -2662,7 +2662,7 @@ function edit_form_image_editor( $post ) {
<div class="wp_attachment_details edit-form-section">
<p>
<label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong><?php
if ( preg_match( '#^audio|video#', $post->post_mime_type ) ): ?>: <?php
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ): ?>: <?php
_e( "Custom label for item in a playlist. If empty, the file's available data is used." );
endif ?></label><br />
<textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
@@ -2688,7 +2688,7 @@ function edit_form_image_editor( $post ) {
?>
<label for="content"><strong><?php _e( 'Description' ); ?></strong><?php
if ( preg_match( '#^audio|video#', $post->post_mime_type ) ): ?>: <?php
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ): ?>: <?php
_e( 'Displayed on attachment pages.' );
endif ?></label>
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
@@ -2751,7 +2751,7 @@ function attachment_submitbox_metadata() {
<?php
endif;
if ( preg_match( '#^(audio|video)#', $post->post_mime_type ) ):
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ):
/**
* Filter the audio and video metadata fields to be shown in the publish meta box.

View File

@@ -1071,7 +1071,7 @@ function attachment_id3_data_meta_box( $post ) {
$meta = wp_get_attachment_metadata( $post->ID );
}
foreach ( wp_get_relevant_id3_keys() as $key => $label ): ?>
foreach ( wp_get_relevant_id3_keys( $post ) as $key => $label ): ?>
<p>
<label for="title"><?php echo $label ?></label>
<input type="text" name="id3_<?php echo esc_attr( $key ) ?>" id="id3_<?php echo esc_attr( $key ) ?>" class="widefat" value="<?php

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 );