WordPress.org

Make WordPress Core

Changeset 27864


Ignore:
Timestamp:
03/30/2014 09:07:04 PM (7 years ago)
Author:
nacin
Message:

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

see #27574.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-advanced.php

    r27862 r27864  
    141141    add_action( 'edit_form_after_title', 'edit_form_image_editor' );
    142142
    143     if ( preg_match( '#^audio#', $post->post_mime_type ) ) {
     143    if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
    144144        add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' );
    145145    }
  • trunk/src/wp-admin/includes/media.php

    r27862 r27864  
    26632663        <p>
    26642664            <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong><?php
    2665             if ( preg_match( '#^audio|video#', $post->post_mime_type ) ): ?>: <?php
     2665            if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ): ?>: <?php
    26662666                _e( "Custom label for item in a playlist. If empty, the file's available data is used." );
    26672667            endif ?></label><br />
     
    26892689
    26902690    <label for="content"><strong><?php _e( 'Description' ); ?></strong><?php
    2691     if ( preg_match( '#^audio|video#', $post->post_mime_type ) ): ?>: <?php
     2691    if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ): ?>: <?php
    26922692        _e( 'Displayed on attachment pages.' );
    26932693    endif ?></label>
     
    27522752        endif;
    27532753
    2754     if ( preg_match( '#^(audio|video)#', $post->post_mime_type ) ):
     2754    if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ):
    27552755
    27562756        /**
  • trunk/src/wp-admin/includes/meta-boxes.php

    r27862 r27864  
    10721072    }
    10731073
    1074     foreach ( wp_get_relevant_id3_keys() as $key => $label ): ?>
     1074    foreach ( wp_get_relevant_id3_keys( $post ) as $key => $label ): ?>
    10751075    <p>
    10761076        <label for="title"><?php echo $label ?></label>
  • trunk/src/wp-admin/includes/post.php

    r27862 r27864  
    238238    }
    239239
    240     if ( 'attachment' === $post_data['post_type'] && preg_match( '#^audio|video#', $post_data['post_mime_type'] ) ) {
     240    if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) {
    241241        $id3data = wp_get_attachment_metadata( $post_ID );
    242242        if ( ! is_array( $id3data ) ) {
     
    244244        }
    245245
    246         foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
     246        foreach ( wp_get_relevant_id3_keys( $post ) as $key => $label ) {
    247247            if ( isset( $post_data[ 'id3_' . $key ] ) ) {
    248                 if ( current_user_can( 'unfiltered_html' ) ) {
    249                     $id3data[ $key ] = wp_unslash( $post_data[ 'id3_' . $key ] );
    250                 } else {
    251                     $id3data[ $key ] = wp_unslash( wp_kses_post( $post_data[ 'id3_' . $key ] ) );
    252                 }
     248                $id3data[ $key ] = sanitize_post_field( wp_unslash( $post_data[ 'id3_' . $key ] ) );
    253249            }
    254250        }
  • trunk/src/wp-includes/media.php

    r27862 r27864  
    10171017<script type="text/html" id="tmpl-wp-playlist-current-item">
    10181018    <# if ( data.image ) { #>
    1019     <img src="{{{ data.thumb.src }}}"/>
     1019    <img src="{{ data.thumb.src }}"/>
    10201020    <# } #>
    10211021    <div class="wp-playlist-caption">
    10221022        <span class="wp-caption-meta wp-caption-title">&#8220;{{{ data.title }}}&#8221;</span>
    1023         <# if ( data.meta.album ) { #><span class="wp-caption-meta wp-caption-album">{{{ data.meta.album }}}</span><# } #>
    1024         <# if ( data.meta.artist ) { #><span class="wp-caption-meta wp-caption-artist">{{{ data.meta.artist }}}</span><# } #>
     1023        <# if ( data.meta.album ) { #><span class="wp-caption-meta wp-caption-album">{{ data.meta.album }}</span><# } #>
     1024        <# if ( data.meta.artist ) { #><span class="wp-caption-meta wp-caption-artist">{{ data.meta.artist }}</span><# } #>
    10251025    </div>
    10261026</script>
     
    10281028    <div class="wp-playlist-item">
    10291029        <div class="wp-playlist-caption">
    1030             {{{ data.index ? ( data.index + '.&nbsp;' ) : '' }}}
     1030            {{ data.index ? ( data.index + '. ' ) : '' }}
    10311031            <# if ( data.caption ) { #>
    10321032                {{{ data.caption }}}
     
    10351035                <# if ( data.artists && data.meta.artist ) { #>
    10361036                <span class="wp-caption-by"><?php _e( 'by' ) ?></span>
    1037                 <span class="wp-caption-artist">{{{ data.meta.artist }}}</span>
     1037                <span class="wp-caption-artist">{{ data.meta.artist }}</span>
    10381038                <# } #>
    10391039            <# } #>
     
    12041204        if ( ! empty( $meta ) ) {
    12051205
    1206             foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
     1206            foreach ( wp_get_relevant_id3_keys( $attachment ) as $key => $label ) {
    12071207                if ( ! empty( $meta[ $key ] ) ) {
    12081208                    $track['meta'][ $key ] = $meta[ $key ];
     
    13181318 * @since 3.9.0
    13191319 *
     1320 * @param WP_Post $post The post in question, provided for context.
    13201321 * @return array
    13211322 */
    1322 function wp_get_relevant_id3_keys() {
     1323function wp_get_relevant_id3_keys( $post ) {
    13231324    $fields = array(
    13241325        'artist' => __( 'Artist' ),
     
    13281329        'length_formatted' => __( 'Formatted Length' )
    13291330    );
     1331
    13301332    /**
    1331      * Filter the editable list of keys to lookup data from an attachment's metadata
     1333     * Filter the editable list of keys to lookup data from an attachment's metadata.
    13321334     *
    13331335     * @since 3.9.0
    13341336     *
    1335      * @param array $fields
     1337     * @param array   $fields Key/value pairs of field keys to labels.
     1338     * @param WP_Post $post   Post object.
    13361339     */
    1337     return apply_filters( 'wp_get_relevant_id3_keys', $fields );
     1340    return apply_filters( 'wp_get_relevant_id3_keys', $fields, $post );
    13381341}
    13391342/**
     
    23322335
    23332336        $response['meta'] = array();
    2334         foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
     2337        foreach ( wp_get_relevant_id3_keys( $attachment ) as $key => $label ) {
    23352338            if ( ! empty( $meta[ $key ] ) ) {
    23362339                $response['meta'][ $key ] = $meta[ $key ];
Note: See TracChangeset for help on using the changeset viewer.