<!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>[20358] trunk: Allow selecting custom header and background images from the media library.</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, #logmsg > ol { margin-left: 0; 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/20358">20358</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2012-04-05 00:20:28 +0000 (Thu, 05 Apr 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow selecting custom header and background images from the media library. Props aaroncampbell, sabreuse, greuben. fixes <a href="http://core.trac.wordpress.org/ticket/19840">#19840</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincustombackgroundphp">trunk/wp-admin/custom-background.php</a></li>
<li><a href="#trunkwpadmincustomheaderphp">trunk/wp-admin/custom-header.php</a></li>
<li><a href="#trunkwpadminincludesmediaphp">trunk/wp-admin/includes/media.php</a></li>
<li><a href="#trunkwpadminmediauploadphp">trunk/wp-admin/media-upload.php</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincustombackgroundphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/custom-background.php (20357 => 20358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-background.php        2012-04-04 23:58:25 UTC (rev 20357)
+++ trunk/wp-admin/custom-background.php        2012-04-05 00:20:28 UTC (rev 20358)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx">                 $this-&gt;admin_image_div_callback = $admin_image_div_callback;
</span><span class="cx"> 
</span><span class="cx">                 add_action( 'admin_menu', array( $this, 'init' ) );
</span><ins>+                add_action( 'wp_ajax_set-background-image', array( $this, 'wp_set_background_image' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -71,6 +72,8 @@
</span><span class="cx">                 add_action(&quot;load-$page&quot;, array(&amp;$this, 'admin_load'));
</span><span class="cx">                 add_action(&quot;load-$page&quot;, array(&amp;$this, 'take_action'), 49);
</span><span class="cx">                 add_action(&quot;load-$page&quot;, array(&amp;$this, 'handle_upload'), 49);
</span><ins>+                add_filter( 'attachment_fields_to_edit', array( $this, 'attachment_fields_to_edit' ), 10, 2 );
+                add_filter( 'media_upload_tabs', array( $this, 'filter_upload_tabs' ) );
</ins><span class="cx"> 
</span><span class="cx">                 if ( $this-&gt;admin_header_callback )
</span><span class="cx">                         add_action(&quot;admin_head-$page&quot;, $this-&gt;admin_header_callback, 51);
</span><span class="lines">@@ -98,6 +101,8 @@
</span><span class="cx">                         '&lt;p&gt;' . __( '&lt;a href=&quot;http://wordpress.org/support/&quot; target=&quot;_blank&quot;&gt;Support Forums&lt;/a&gt;' ) . '&lt;/p&gt;'
</span><span class="cx">                 );
</span><span class="cx"> 
</span><ins>+                add_thickbox();
+                wp_enqueue_script('media-upload');
</ins><span class="cx">                 wp_enqueue_script('custom-background');
</span><span class="cx">                 wp_enqueue_style('farbtastic');
</span><span class="cx">         }
</span><span class="lines">@@ -126,6 +131,7 @@
</span><span class="cx">                         set_theme_mod('background_image', '');
</span><span class="cx">                         set_theme_mod('background_image_thumb', '');
</span><span class="cx">                         $this-&gt;updated = true;
</span><ins>+                        wp_safe_redirect( $_POST['_wp_http_referer'] );
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -248,7 +254,13 @@
</span><span class="cx"> &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;save&quot; /&gt;
</span><span class="cx"> &lt;?php wp_nonce_field('custom-background-upload', '_wpnonce-custom-background-upload') ?&gt;
</span><span class="cx"> &lt;?php submit_button( __( 'Upload' ), 'button', 'submit', false ); ?&gt;
</span><del>-&lt;/form&gt;
</del><ins>+&lt;?php
+        $image_library_url = get_upload_iframe_src( 'image', null, 'library' );
+        $image_library_url = remove_query_arg( 'TB_iframe', $image_library_url );
+        $image_library_url = add_query_arg( array( 'context' =&gt; 'custom-background', 'TB_iframe' =&gt; 1 ), $image_library_url );
+?&gt;
+        &lt;/form&gt;
+        &lt;span class=&quot;howto&quot;&gt;&lt;?php _ex( 'or', 'Custom Background: Choose an image from your computer - or - Choose from image library' ); ?&gt;&lt;/span&gt; &lt;a class=&quot;thickbox&quot; href=&quot;&lt;?php echo $image_library_url; ?&gt;&quot;&gt;&lt;?php _e( 'Choose from image library' ); ?&gt;&lt;/a&gt;
</ins><span class="cx"> &lt;/td&gt;
</span><span class="cx"> &lt;/tr&gt;
</span><span class="cx"> &lt;/tbody&gt;
</span><span class="lines">@@ -368,4 +380,36 @@
</span><span class="cx">                 $this-&gt;updated = true;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function attachment_fields_to_edit( $form_fields, $post ) {
+                if ( isset( $_REQUEST['context'] ) &amp;&amp; $_REQUEST['context'] == 'custom-background' ) {
+                        $form_fields = array( 'image-size' =&gt; $form_fields['image-size'] );
+                        $form_fields['buttons'] = array( 'tr' =&gt; '&lt;tr class=&quot;submit&quot;&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;a data-attachment-id=&quot;' . $post-&gt;ID . '&quot; class=&quot;wp-set-background&quot;&gt;' . _( 'Set as background' ) . '&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;' );
+                        $form_fields['context'] = array( 'input' =&gt; 'hidden', 'value' =&gt; 'custom-background' );
+                }
+
+                return $form_fields;
+        }
+
+        function filter_upload_tabs ( $tabs ){
+                if ( isset( $_REQUEST['context'] ) &amp;&amp; $_REQUEST['context'] == 'custom-background' )
+                        return array( 'library' =&gt; __('Media Library') );
+
+                return $tabs;
+        }
+
+        public function wp_set_background_image() {
+                if ( ! current_user_can('edit_theme_options') || ! isset( $_POST['attachment_id'] ) ) exit;
+                $attachment_id = absint($_POST['attachment_id']);
+                $sizes = array_keys(apply_filters( 'image_size_names_choose', array('thumbnail' =&gt; __('Thumbnail'), 'medium' =&gt; __('Medium'), 'large' =&gt; __('Large'), 'full' =&gt; __('Full Size')) ));
+                $size = 'thumbnail';
+                if ( in_array( $_POST['size'], $sizes ) )
+                        $size = esc_attr( $_POST['size'] );
+
+                update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) );
+                $url = wp_get_attachment_image_src( $attachment_id, $size );
+                $thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
+                set_theme_mod( 'background_image', esc_url( $url[0] ) );
+                set_theme_mod( 'background_image_thumb', esc_url( $thumbnail[0] ) );
+                exit;
+        }
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadmincustomheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/custom-header.php (20357 => 20358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-header.php        2012-04-04 23:58:25 UTC (rev 20357)
+++ trunk/wp-admin/custom-header.php        2012-04-05 00:20:28 UTC (rev 20358)
</span><span class="lines">@@ -92,6 +92,9 @@
</span><span class="cx">                 add_action(&quot;admin_head-$page&quot;, array(&amp;$this, 'take_action'), 50);
</span><span class="cx">                 add_action(&quot;admin_head-$page&quot;, array(&amp;$this, 'js'), 50);
</span><span class="cx">                 add_action(&quot;admin_head-$page&quot;, $this-&gt;admin_header_callback, 51);
</span><ins>+
+                add_filter( 'attachment_fields_to_edit', array( $this, 'attachment_fields_to_edit' ), 10, 2 );
+                add_filter( 'media_upload_tabs', array( $this, 'filter_upload_tabs' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -128,8 +131,11 @@
</span><span class="cx">                         return 1;
</span><span class="cx"> 
</span><span class="cx">                 $step = (int) $_GET['step'];
</span><del>-                if ( $step &lt; 1 || 3 &lt; $step )
-                        $step = 1;
</del><ins>+                if ( $step &lt; 1 || 3 &lt; $step ||
+                        ( 2 == $step &amp;&amp; ! wp_verify_nonce( $_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload' ) ) ||
+                        ( 3 == $step &amp;&amp; ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom-header-crop-image' ) )
+                )
+                        return 1;
</ins><span class="cx"> 
</span><span class="cx">                 return $step;
</span><span class="cx">         }
</span><span class="lines">@@ -142,10 +148,15 @@
</span><span class="cx">         function js_includes() {
</span><span class="cx">                 $step = $this-&gt;step();
</span><span class="cx"> 
</span><del>-                if ( ( 1 == $step || 3 == $step ) &amp;&amp; current_theme_supports( 'custom-header', 'header-text' ) )
-                        wp_enqueue_script('farbtastic');
-                elseif ( 2 == $step )
</del><ins>+                if ( ( 1 == $step || 3 == $step ) ) {
+                        add_thickbox();
+                        wp_enqueue_script( 'media-upload' );
+                        wp_enqueue_script( 'custom-header' );
+                        if ( current_theme_supports( 'custom-header', 'header-text' ) )
+                                wp_enqueue_script('farbtastic');
+                } elseif ( 2 == $step ) {
</ins><span class="cx">                         wp_enqueue_script('imgareaselect');
</span><ins>+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -395,7 +406,7 @@
</span><span class="cx">                 &lt;?php if ( display_header_text() ) { ?&gt;
</span><span class="cx">                 pickColor('#&lt;?php echo get_header_textcolor(); ?&gt;');
</span><span class="cx">                 &lt;?php } else { ?&gt;
</span><del>-                toggle_text();                
</del><ins>+                toggle_text();
</ins><span class="cx">                 &lt;?php } ?&gt;
</span><span class="cx">         });
</span><span class="cx"> })(jQuery);
</span><span class="lines">@@ -553,6 +564,12 @@
</span><span class="cx">                 &lt;?php submit_button( __( 'Upload' ), 'button', 'submit', false ); ?&gt;
</span><span class="cx">         &lt;/p&gt;
</span><span class="cx">         &lt;/form&gt;
</span><ins>+        &lt;?php
+                $image_library_url = get_upload_iframe_src( 'image', null, 'library' );
+                $image_library_url = remove_query_arg( 'TB_iframe', $image_library_url );
+                $image_library_url = add_query_arg( array( 'context' =&gt; 'custom-header', 'TB_iframe' =&gt; 1 ), $image_library_url );
+        ?&gt;
+        &lt;span class=&quot;howto&quot;&gt;&lt;?php _ex( 'or', 'Custom Header: Choose an image from your computer - or - Choose from image library' ); ?&gt;&lt;/span&gt; &lt;a class=&quot;thickbox&quot; href=&quot;&lt;?php echo $image_library_url; ?&gt;&quot;&gt;&lt;?php _e( 'Choose from image library' ); ?&gt;&lt;/a&gt;
</ins><span class="cx"> &lt;/td&gt;
</span><span class="cx"> &lt;/tr&gt;
</span><span class="cx"> &lt;?php endif; ?&gt;
</span><span class="lines">@@ -674,29 +691,15 @@
</span><span class="cx">                 if ( ! current_theme_supports( 'custom-header', 'uploads' ) )
</span><span class="cx">                         wp_die( __( 'Cheatin&amp;#8217; uh?' ) );
</span><span class="cx"> 
</span><del>-                $overrides = array('test_form' =&gt; false);
-                $file = wp_handle_upload($_FILES['import'], $overrides);
</del><ins>+                if ( empty( $_POST ) &amp;&amp; isset( $_GET['file'] ) ) {
+                        $id = absint( $_GET['file'] );
+                        $file = get_attached_file( $id, true );
+                        $url = wp_get_attachment_image_src( $id, 'full');
+                        $url = $url[0];
+                } elseif ( isset( $_POST ) ) {
+                        extract($this-&gt;step_2_manage_upload());
+                }
</ins><span class="cx"> 
</span><del>-                if ( isset($file['error']) )
-                        wp_die( $file['error'],  __( 'Image Upload Error' ) );
-
-                $url = $file['url'];
-                $type = $file['type'];
-                $file = $file['file'];
-                $filename = basename($file);
-
-                // Construct the object array
-                $object = array(
-                'post_title' =&gt; $filename,
-                'post_content' =&gt; $url,
-                'post_mime_type' =&gt; $type,
-                'guid' =&gt; $url,
-                'context' =&gt; 'custom-header'
-                );
-
-                // Save the data
-                $id = wp_insert_attachment($object, $file);
-
</del><span class="cx">                 list($width, $height, $type, $attr) = getimagesize( $file );
</span><span class="cx"> 
</span><span class="cx">                 $max_width = 0;
</span><span class="lines">@@ -753,6 +756,9 @@
</span><span class="cx">         &lt;input type=&quot;hidden&quot; name=&quot;height&quot; id=&quot;height&quot; value=&quot;&lt;?php echo esc_attr( $height ); ?&gt;&quot;/&gt;
</span><span class="cx">         &lt;input type=&quot;hidden&quot; name=&quot;attachment_id&quot; id=&quot;attachment_id&quot; value=&quot;&lt;?php echo esc_attr( $id ); ?&gt;&quot; /&gt;
</span><span class="cx">         &lt;input type=&quot;hidden&quot; name=&quot;oitar&quot; id=&quot;oitar&quot; value=&quot;&lt;?php echo esc_attr( $oitar ); ?&gt;&quot; /&gt;
</span><ins>+        &lt;?php if ( empty( $_POST ) &amp;&amp; isset( $_GET['file'] ) ) { ?&gt;
+        &lt;input type=&quot;hidden&quot; name=&quot;new-attachment&quot; value=&quot;true&quot; /&gt;
+        &lt;?php } ?&gt;
</ins><span class="cx">         &lt;?php wp_nonce_field( 'custom-header-crop-image' ) ?&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;?php submit_button( __( 'Crop and Publish' ) ); ?&gt;
</span><span class="lines">@@ -762,6 +768,33 @@
</span><span class="cx">                 &lt;?php
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+
+        function step_2_manage_upload() {
+                $overrides = array('test_form' =&gt; false);
+                $file = wp_handle_upload($_FILES['import'], $overrides);
+
+                if ( isset($file['error']) )
+                        wp_die( $file['error'],  __( 'Image Upload Error' ) );
+
+                $url = $file['url'];
+                $type = $file['type'];
+                $file = $file['file'];
+                $filename = basename($file);
+
+                // Construct the object array
+                $object = array(
+                        'post_title'     =&gt; $filename,
+                        'post_content'   =&gt; $url,
+                        'post_mime_type' =&gt; $type,
+                        'guid'           =&gt; $url,
+                        'context'        =&gt; 'custom-header'
+                );
+
+                // Save the data
+                $id = wp_insert_attachment( $object, $file );
+                return compact( 'id', 'file', 'filename', 'url', 'type' );
+        }
+
</ins><span class="cx">         /**
</span><span class="cx">          * Display third step of custom header image page.
</span><span class="cx">          *
</span><span class="lines">@@ -826,9 +859,11 @@
</span><span class="cx">                         'guid' =&gt; $url,
</span><span class="cx">                         'context' =&gt; 'custom-header'
</span><span class="cx">                 );
</span><ins>+                if ( isset( $_POST['new-attachment'] ) &amp;&amp; $_POST['new-attachment'] )
+                        unset($object['ID']);
</ins><span class="cx"> 
</span><span class="cx">                 // Update the attachment
</span><del>-                wp_insert_attachment($object, $cropped);
</del><ins>+                $attachment_id = wp_insert_attachment( $object, $cropped );
</ins><span class="cx">                 wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $cropped ) );
</span><span class="cx">                 update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_option('stylesheet' ) );
</span><span class="cx"> 
</span><span class="lines">@@ -845,8 +880,10 @@
</span><span class="cx"> 
</span><span class="cx">                 // cleanup
</span><span class="cx">                 $medium = str_replace(basename($original), 'midsize-'.basename($original), $original);
</span><del>-                @unlink( apply_filters( 'wp_delete_file', $medium ) );
-                @unlink( apply_filters( 'wp_delete_file', $original ) );
</del><ins>+                if ( file_exists( $medium ) )
+                        @unlink( apply_filters( 'wp_delete_file', $medium ) );
+                if ( empty ( $_POST['new-attachment'] ) )
+                        @unlink( apply_filters( 'wp_delete_file', $original ) );
</ins><span class="cx"> 
</span><span class="cx">                 return $this-&gt;finished();
</span><span class="cx">         }
</span><span class="lines">@@ -870,12 +907,36 @@
</span><span class="cx">                 if ( ! current_user_can('edit_theme_options') )
</span><span class="cx">                         wp_die(__('You do not have permission to customize headers.'));
</span><span class="cx">                 $step = $this-&gt;step();
</span><del>-                if ( 1 == $step || ! $_POST )
-                        $this-&gt;step_1();
-                elseif ( 2 == $step )
</del><ins>+                if ( 2 == $step )
</ins><span class="cx">                         $this-&gt;step_2();
</span><span class="cx">                 elseif ( 3 == $step )
</span><span class="cx">                         $this-&gt;step_3();
</span><ins>+                else
+                        $this-&gt;step_1();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function attachment_fields_to_edit( $form_fields, $post ) {
+                if ( isset( $_REQUEST['context'] ) &amp;&amp; $_REQUEST['context'] == 'custom-header' ) {
+                        $form_fields = array();
+                        $href = esc_url(add_query_arg(array(
+                                'page' =&gt; 'custom-header',
+                                'step' =&gt; 2,
+                                '_wpnonce-custom-header-upload' =&gt; wp_create_nonce('custom-header-upload'),
+                                'file' =&gt; $post-&gt;ID
+                        ), admin_url('themes.php')));
+
+                        $form_fields['buttons'] = array( 'tr' =&gt; '&lt;tr class=&quot;submit&quot;&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;a data-location=&quot;' . $href . '&quot; class=&quot;wp-set-header&quot;&gt;' . _( 'Set as header' ) . '&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;' );
+                        $form_fields['context'] = array( 'input' =&gt; 'hidden', 'value' =&gt; 'custom-header' );
+                }
+
+                return $form_fields;
+        }
+
+        function filter_upload_tabs( $tabs ) {
+                if ( isset( $_REQUEST['context'] ) &amp;&amp; $_REQUEST['context'] == 'custom-header' )
+                        return array( 'library' =&gt; __('Media Library') );
+
+                return $tabs;
+        }
+
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/media.php (20357 => 20358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/media.php        2012-04-04 23:58:25 UTC (rev 20357)
+++ trunk/wp-admin/includes/media.php        2012-04-05 00:20:28 UTC (rev 20358)
</span><span class="lines">@@ -403,18 +403,20 @@
</span><span class="cx">         return &quot;&lt;a href='&quot; . esc_url( get_upload_iframe_src($type) ) . &quot;' id='{$id}-add_{$type}' class='thickbox add_$type' title='&quot; . esc_attr( $title ) . &quot;'&gt;&lt;img src='&quot; . esc_url( admin_url( $icon ) ) . &quot;' alt='$title' onclick='return false;' /&gt;&lt;/a&gt;&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function get_upload_iframe_src( $type = null, $post_id = null ) {
</del><ins>+function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
</ins><span class="cx">         global $post_ID;
</span><span class="cx"> 
</span><span class="cx">         if ( empty( $post_id ) )
</span><span class="cx">                 $post_id = $post_ID;
</span><span class="cx"> 
</span><del>-        $uploading_iframe_ID = (int) $post_id;
-        $upload_iframe_src = add_query_arg( 'post_id', $uploading_iframe_ID, admin_url('media-upload.php') );
</del><ins>+        $upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url('media-upload.php') );
</ins><span class="cx"> 
</span><span class="cx">         if ( $type &amp;&amp; 'media' != $type )
</span><span class="cx">                 $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
</span><span class="cx"> 
</span><ins>+        if ( ! empty( $tab ) )
+                $upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src);
+
</ins><span class="cx">         $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);
</span><span class="cx"> 
</span><span class="cx">         return add_query_arg('TB_iframe', true, $upload_iframe_src);
</span><span class="lines">@@ -497,7 +499,7 @@
</span><span class="cx">         if ( isset($send_id) ) {
</span><span class="cx">                 $attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
</span><span class="cx"> 
</span><del>-                $html = $attachment['post_title'];
</del><ins>+                $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
</ins><span class="cx">                 if ( !empty($attachment['url']) ) {
</span><span class="cx">                         $rel = '';
</span><span class="cx">                         if ( strpos($attachment['url'], 'attachment_id') || get_attachment_link($send_id) == $attachment['url'] )
</span></span></pre></div>
<a id="trunkwpadminmediauploadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/media-upload.php (20357 => 20358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/media-upload.php        2012-04-04 23:58:25 UTC (rev 20357)
+++ trunk/wp-admin/media-upload.php        2012-04-05 00:20:28 UTC (rev 20358)
</span><span class="lines">@@ -22,6 +22,7 @@
</span><span class="cx"> wp_enqueue_script('image-edit');
</span><span class="cx"> wp_enqueue_script('set-post-thumbnail' );
</span><span class="cx"> wp_enqueue_style('imgareaselect');
</span><ins>+wp_enqueue_script( 'media-gallery' );
</ins><span class="cx"> 
</span><span class="cx"> @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (20357 => 20358)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2012-04-04 23:58:25 UTC (rev 20357)
+++ trunk/wp-includes/script-loader.php        2012-04-05 00:20:28 UTC (rev 20358)
</span><span class="lines">@@ -417,6 +417,7 @@
</span><span class="cx">                 ) );
</span><span class="cx"> 
</span><span class="cx">                 $scripts-&gt;add( 'custom-background', &quot;/wp-admin/js/custom-background$suffix.js&quot;, array('farbtastic'), false, 1 );
</span><ins>+                $scripts-&gt;add( 'media-gallery', &quot;/wp-admin/js/media-gallery$suffix.js&quot;, array('jquery'), false, 1 );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>