<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[27864] trunk/src: Cleanups for audio/video metadata, see [27862].</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/27864">27864</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2014-03-30 21:07:04 +0000 (Sun, 30 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cleanups for audio/video metadata, see <a href="http://core.trac.wordpress.org/changeset/27862">[27862]</a>.

see <a href="http://core.trac.wordpress.org/ticket/27574">#27574</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmineditformadvancedphp">trunk/src/wp-admin/edit-form-advanced.php</a></li>
<li><a href="#trunksrcwpadminincludesmediaphp">trunk/src/wp-admin/includes/media.php</a></li>
<li><a href="#trunksrcwpadminincludesmetaboxesphp">trunk/src/wp-admin/includes/meta-boxes.php</a></li>
<li><a href="#trunksrcwpadminincludespostphp">trunk/src/wp-admin/includes/post.php</a></li>
<li><a href="#trunksrcwpincludesmediaphp">trunk/src/wp-includes/media.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/edit-form-advanced.php (27863 => 27864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/edit-form-advanced.php        2014-03-30 20:53:21 UTC (rev 27863)
+++ trunk/src/wp-admin/edit-form-advanced.php   2014-03-30 21:07:04 UTC (rev 27864)
</span><span class="lines">@@ -140,7 +140,7 @@
</span><span class="cx">  add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
</span><span class="cx">  add_action( 'edit_form_after_title', 'edit_form_image_editor' );
</span><span class="cx"> 
</span><del>-       if ( preg_match( '#^audio#', $post->post_mime_type ) ) {
</del><ins>+        if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) {
</ins><span class="cx">           add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' );
</span><span class="cx">  }
</span><span class="cx"> } else {
</span></span></pre></div>
<a id="trunksrcwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/media.php (27863 => 27864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/media.php    2014-03-30 20:53:21 UTC (rev 27863)
+++ trunk/src/wp-admin/includes/media.php       2014-03-30 21:07:04 UTC (rev 27864)
</span><span class="lines">@@ -2662,7 +2662,7 @@
</span><span class="cx">  <div class="wp_attachment_details edit-form-section">
</span><span class="cx">          <p>
</span><span class="cx">                  <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong><?php
</span><del>-                       if ( preg_match( '#^audio|video#', $post->post_mime_type ) ): ?>: <?php
</del><ins>+                        if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ): ?>: <?php
</ins><span class="cx">                           _e( "Custom label for item in a playlist. If empty, the file's available data is used." );
</span><span class="cx">                  endif ?></label><br />
</span><span class="cx">                  <textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
</span><span class="lines">@@ -2688,7 +2688,7 @@
</span><span class="cx">  ?>
</span><span class="cx"> 
</span><span class="cx">  <label for="content"><strong><?php _e( 'Description' ); ?></strong><?php
</span><del>-       if ( preg_match( '#^audio|video#', $post->post_mime_type ) ): ?>: <?php
</del><ins>+        if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ): ?>: <?php
</ins><span class="cx">           _e( 'Displayed on attachment pages.' );
</span><span class="cx">  endif ?></label>
</span><span class="cx">  <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
</span><span class="lines">@@ -2751,7 +2751,7 @@
</span><span class="cx">                  <?php
</span><span class="cx">          endif;
</span><span class="cx"> 
</span><del>-       if ( preg_match( '#^(audio|video)#', $post->post_mime_type ) ):
</del><ins>+        if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ):
</ins><span class="cx"> 
</span><span class="cx">          /**
</span><span class="cx">           * Filter the audio and video metadata fields to be shown in the publish meta box.
</span></span></pre></div>
<a id="trunksrcwpadminincludesmetaboxesphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/meta-boxes.php (27863 => 27864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/meta-boxes.php       2014-03-30 20:53:21 UTC (rev 27863)
+++ trunk/src/wp-admin/includes/meta-boxes.php  2014-03-30 21:07:04 UTC (rev 27864)
</span><span class="lines">@@ -1071,7 +1071,7 @@
</span><span class="cx">          $meta = wp_get_attachment_metadata( $post->ID );
</span><span class="cx">  }
</span><span class="cx"> 
</span><del>-       foreach ( wp_get_relevant_id3_keys() as $key => $label ): ?>
</del><ins>+        foreach ( wp_get_relevant_id3_keys( $post ) as $key => $label ): ?>
</ins><span class="cx">   <p>
</span><span class="cx">          <label for="title"><?php echo $label ?></label>
</span><span class="cx">          <input type="text" name="id3_<?php echo esc_attr( $key ) ?>" id="id3_<?php echo esc_attr( $key ) ?>" class="widefat" value="<?php
</span></span></pre></div>
<a id="trunksrcwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/post.php (27863 => 27864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/post.php     2014-03-30 20:53:21 UTC (rev 27863)
+++ trunk/src/wp-admin/includes/post.php        2014-03-30 21:07:04 UTC (rev 27864)
</span><span class="lines">@@ -237,19 +237,15 @@
</span><span class="cx">          }
</span><span class="cx">  }
</span><span class="cx"> 
</span><del>-       if ( 'attachment' === $post_data['post_type'] && preg_match( '#^audio|video#', $post_data['post_mime_type'] ) ) {
</del><ins>+        if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) {
</ins><span class="cx">           $id3data = wp_get_attachment_metadata( $post_ID );
</span><span class="cx">          if ( ! is_array( $id3data ) ) {
</span><span class="cx">                  $id3data = array();
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
</del><ins>+                foreach ( wp_get_relevant_id3_keys( $post ) as $key => $label ) {
</ins><span class="cx">                   if ( isset( $post_data[ 'id3_' . $key ] ) ) {
</span><del>-                               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 ] ) );
-                               }
</del><ins>+                                $id3data[ $key ] = sanitize_post_field( wp_unslash( $post_data[ 'id3_' . $key ] ) );
</ins><span class="cx">                   }
</span><span class="cx">          }
</span><span class="cx">          wp_update_attachment_metadata( $post_ID, $id3data );
</span></span></pre></div>
<a id="trunksrcwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/media.php (27863 => 27864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/media.php  2014-03-30 20:53:21 UTC (rev 27863)
+++ trunk/src/wp-includes/media.php     2014-03-30 21:07:04 UTC (rev 27864)
</span><span class="lines">@@ -1016,25 +1016,25 @@
</span><span class="cx"> ?>
</span><span class="cx"> <script type="text/html" id="tmpl-wp-playlist-current-item">
</span><span class="cx">  <# if ( data.image ) { #>
</span><del>-       <img src="{{{ data.thumb.src }}}"/>
</del><ins>+        <img src="{{ data.thumb.src }}"/>
</ins><span class="cx">   <# } #>
</span><span class="cx">  <div class="wp-playlist-caption">
</span><span class="cx">          <span class="wp-caption-meta wp-caption-title">&#8220;{{{ data.title }}}&#8221;</span>
</span><del>-               <# if ( data.meta.album ) { #><span class="wp-caption-meta wp-caption-album">{{{ data.meta.album }}}</span><# } #>
-               <# if ( data.meta.artist ) { #><span class="wp-caption-meta wp-caption-artist">{{{ data.meta.artist }}}</span><# } #>
</del><ins>+                <# if ( data.meta.album ) { #><span class="wp-caption-meta wp-caption-album">{{ data.meta.album }}</span><# } #>
+               <# if ( data.meta.artist ) { #><span class="wp-caption-meta wp-caption-artist">{{ data.meta.artist }}</span><# } #>
</ins><span class="cx">   </div>
</span><span class="cx"> </script>
</span><span class="cx"> <script type="text/html" id="tmpl-wp-playlist-item">
</span><span class="cx">  <div class="wp-playlist-item">
</span><span class="cx">          <div class="wp-playlist-caption">
</span><del>-                       {{{ data.index ? ( data.index + '.&nbsp;' ) : '' }}}
</del><ins>+                        {{ data.index ? ( data.index + '. ' ) : '' }}
</ins><span class="cx">                   <# if ( data.caption ) { #>
</span><span class="cx">                          {{{ data.caption }}}
</span><span class="cx">                  <# } else { #>
</span><span class="cx">                          <span class="wp-caption-title">&#8220;{{{ data.title }}}&#8221;</span>
</span><span class="cx">                          <# if ( data.artists && data.meta.artist ) { #>
</span><span class="cx">                          <span class="wp-caption-by"><?php _e( 'by' ) ?></span>
</span><del>-                               <span class="wp-caption-artist">{{{ data.meta.artist }}}</span>
</del><ins>+                                <span class="wp-caption-artist">{{ data.meta.artist }}</span>
</ins><span class="cx">                           <# } #>
</span><span class="cx">                  <# } #>
</span><span class="cx">          </div>
</span><span class="lines">@@ -1203,7 +1203,7 @@
</span><span class="cx">          $meta = wp_get_attachment_metadata( $attachment->ID );
</span><span class="cx">          if ( ! empty( $meta ) ) {
</span><span class="cx"> 
</span><del>-                       foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
</del><ins>+                        foreach ( wp_get_relevant_id3_keys( $attachment ) as $key => $label ) {
</ins><span class="cx">                           if ( ! empty( $meta[ $key ] ) ) {
</span><span class="cx">                                  $track['meta'][ $key ] = $meta[ $key ];
</span><span class="cx">                          }
</span><span class="lines">@@ -1317,9 +1317,10 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 3.9.0
</span><span class="cx">  *
</span><ins>+ * @param WP_Post $post The post in question, provided for context.
</ins><span class="cx">  * @return array
</span><span class="cx">  */
</span><del>-function wp_get_relevant_id3_keys() {
</del><ins>+function wp_get_relevant_id3_keys( $post ) {
</ins><span class="cx">   $fields = array(
</span><span class="cx">          'artist' => __( 'Artist' ),
</span><span class="cx">          'album' => __( 'Album' ),
</span><span class="lines">@@ -1327,14 +1328,16 @@
</span><span class="cx">          'year' => __( 'Year' ),
</span><span class="cx">          'length_formatted' => __( 'Formatted Length' )
</span><span class="cx">  );
</span><ins>+
</ins><span class="cx">   /**
</span><del>-        * Filter the editable list of keys to lookup data from an attachment's metadata
</del><ins>+         * Filter the editable list of keys to lookup data from an attachment's metadata.
</ins><span class="cx">    *
</span><span class="cx">   * @since 3.9.0
</span><span class="cx">   *
</span><del>-        * @param array $fields
</del><ins>+         * @param array   $fields Key/value pairs of field keys to labels.
+        * @param WP_Post $post   Post object.
</ins><span class="cx">    */
</span><del>-       return apply_filters( 'wp_get_relevant_id3_keys', $fields );
</del><ins>+        return apply_filters( 'wp_get_relevant_id3_keys', $fields, $post );
</ins><span class="cx"> }
</span><span class="cx"> /**
</span><span class="cx">  * The Audio shortcode.
</span><span class="lines">@@ -2331,7 +2334,7 @@
</span><span class="cx">                  $response['fileLength'] = $meta['length_formatted'];
</span><span class="cx"> 
</span><span class="cx">          $response['meta'] = array();
</span><del>-               foreach ( wp_get_relevant_id3_keys() as $key => $label ) {
</del><ins>+                foreach ( wp_get_relevant_id3_keys( $attachment ) as $key => $label ) {
</ins><span class="cx">                   if ( ! empty( $meta[ $key ] ) ) {
</span><span class="cx">                          $response['meta'][ $key ] = $meta[ $key ];
</span><span class="cx">                  }
</span></span></pre>
</div>
</div>

</body>
</html>