Make WordPress Core


Ignore:
Timestamp:
07/11/2014 08:54:13 PM (12 years ago)
Author:
wonderboymusic
Message:

Media Grid, for audio files:

  • Show artist and album fields in the Edit Attachment modal
  • Sync their values on change

See #28839.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r29037 r29104  
    22192219    }
    22202220
     2221    if ( 0 === strpos( $post['post_mime_type'], 'audio/' ) ) {
     2222        $changed = false;
     2223        $id3data = wp_get_attachment_metadata( $post['ID'] );
     2224        if ( ! is_array( $id3data ) ) {
     2225            $changed = true;
     2226            $id3data = array();
     2227        }
     2228        foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) {
     2229            if ( isset( $changes[ $key ] ) ) {
     2230                $changed = true;
     2231                $id3data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) );
     2232            }
     2233        }
     2234
     2235        if ( $changed ) {
     2236            wp_update_attachment_metadata( $id, $id3data );
     2237        }
     2238    }
     2239
    22212240    wp_update_post( $post );
    22222241    wp_send_json_success();
Note: See TracChangeset for help on using the changeset viewer.