<!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>[30911] branches/4.1: Customizer: Re-add the possibility to remove and restore a default background image.</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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/30911">30911</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/30911","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>johnbillion</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2014-12-16 17:10:01 +0000 (Tue, 16 Dec 2014)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Customizer: Re-add the possibility to remove and restore a default background image.

Merges <a href="https://core.trac.wordpress.org/changeset/30849">[30849]</a> to the 4.1 branch.

Fixes <a href="https://core.trac.wordpress.org/ticket/30683">#30683</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branches41srcwpadmincsscustomizecontrolscss">branches/4.1/src/wp-admin/css/customize-controls.css</a></li>
<li><a href="#branches41srcwpincludesclasswpcustomizecontrolphp">branches/4.1/src/wp-includes/class-wp-customize-control.php</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#branches41">branches/4.1/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/4.1
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/4.1 2014-12-16 16:18:40 UTC (rev 30910)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/4.1  2014-12-16 17:10:01 UTC (rev 30911)
</ins><a id="branches41"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/4.1</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/3.1:18031
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/3.3:20543
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/3.4:21757
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk:18512,30801-30813,30817,30821,30823-30824,30829-30832,30835,30837,30839-30843,30846-30847,30854,30856-30857,30865-30867,30873-30874,30879,30884,30887-30890,30903
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:18512,30801-30813,30817,30821,30823-30824,30829-30832,30835,30837,30839-30843,30846-30847,30849,30854,30856-30857,30865-30867,30873-30874,30879,30884,30887-30890,30903
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches41srcwpadmincsscustomizecontrolscss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.1/src/wp-admin/css/customize-controls.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.1/src/wp-admin/css/customize-controls.css      2014-12-16 16:18:40 UTC (rev 30910)
+++ branches/4.1/src/wp-admin/css/customize-controls.css        2014-12-16 17:10:01 UTC (rev 30911)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -605,8 +605,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> .customize-control-upload .remove-button,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.customize-control-upload .default-button,
</ins><span class="cx" style="display: block; padding: 0 10px"> .customize-control-upload .upload-button,
</span><span class="cx" style="display: block; padding: 0 10px"> .customize-control-image .remove-button,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.customize-control-image .default-button,
</ins><span class="cx" style="display: block; padding: 0 10px"> .customize-control-image .upload-button,
</span><span class="cx" style="display: block; padding: 0 10px"> .customize-control-header button.new,
</span><span class="cx" style="display: block; padding: 0 10px"> .customize-control-header button.remove {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -797,8 +799,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">        border-radius: 2px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.customize-control-upload .remove-button
-.customize-control-image .remove-button
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.customize-control-upload .remove-button,
+.customize-control-upload .default-button,
+.customize-control-image .remove-button,
+.customize-control-image .default-button,
</ins><span class="cx" style="display: block; padding: 0 10px"> .customize-control-header .remove {
</span><span class="cx" style="display: block; padding: 0 10px">        float: left;
</span><span class="cx" style="display: block; padding: 0 10px">        margin-right: 3px;
</span></span></pre></div>
<a id="branches41srcwpincludesclasswpcustomizecontrolphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.1/src/wp-includes/class-wp-customize-control.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.1/src/wp-includes/class-wp-customize-control.php       2014-12-16 16:18:40 UTC (rev 30910)
+++ branches/4.1/src/wp-includes/class-wp-customize-control.php 2014-12-16 17:10:01 UTC (rev 30911)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -687,6 +687,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->json['mime_type'] = $this->mime_type;
</span><span class="cx" style="display: block; padding: 0 10px">                $this->json['button_labels'] = $this->button_labels;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $value = $this->value();
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( is_object( $this->setting ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( $this->setting->default ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                // Fake an attachment model - needs all fields used by template.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -695,24 +697,28 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'id' => 1,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'url' => $this->setting->default,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'type' => $type,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'sizes' => array(
-                                               'full' => array( 'url' => $this->setting->default ),
-                                       ),
</del><span class="cx" style="display: block; padding: 0 10px">                                         'icon' => wp_mime_type_icon( $type ),
</span><span class="cx" style="display: block; padding: 0 10px">                                        'title' => basename( $this->setting->default ),
</span><span class="cx" style="display: block; padding: 0 10px">                                );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                               if ( 'image' === $type ) {
+                                       $default_attachment['sizes'] = array(
+                                               'full' => array( 'url' => $this->setting->default ),
+                                       );
+                               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $this->json['defaultAttachment'] = $default_attachment;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Get the attachment model for the existing file.
-                       if ( $this->value() ) {
-                               $attachment_id = attachment_url_to_postid( $this->value() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( $value && $this->setting->default && $value === $this->setting->default ) {
+                               // Set the default as the attachment.
+                               $this->json['attachment'] = $this->json['defaultAttachment'];
+                       } elseif ( $value ) {
+                               // Get the attachment model for the existing file.
+                               $attachment_id = attachment_url_to_postid( $value );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 if ( $attachment_id ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        } else if ( $this->setting->default ) {
-                               // Set the default as the attachment.
-                               $this->json['attachment'] = $default_attachment;
</del><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -741,12 +747,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        <# } #>
</span><span class="cx" style="display: block; padding: 0 10px">                </label>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                <# // Ensure that the default attachment is used if it exists.
-               if ( _.isEmpty( data.attachment ) && data.defaultAttachment ) {
-                       data.attachment = data.defaultAttachment;
-               }
-
-               if ( data.attachment && data.attachment.id ) { #>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         <# if ( data.attachment && data.attachment.id ) { #>
</ins><span class="cx" style="display: block; padding: 0 10px">                         <div class="current">
</span><span class="cx" style="display: block; padding: 0 10px">                                <div class="container">
</span><span class="cx" style="display: block; padding: 0 10px">                                        <div class="attachment-media-view attachment-media-view-{{ data.attachment.type }} {{ data.attachment.orientation }}">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -773,11 +774,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                </div>
</span><span class="cx" style="display: block; padding: 0 10px">                        </div>
</span><span class="cx" style="display: block; padding: 0 10px">                        <div class="actions">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                <# if ( data.defaultAttachment && data.defaultAttachment.id !== data.attachment.id ) { #>
-                                       <button type="button" class="button default-button remove-button"><?php echo $this->button_labels['default']; ?></button>
-                               <# } else if ( ! data.defaultAttachment ) { #>
-                                       <button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button>
-                               <# } #>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         <button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button>
</ins><span class="cx" style="display: block; padding: 0 10px">                                 <button type="button" class="button upload-button" id="{{ data.settings.default }}-button"><?php echo $this->button_labels['change']; ?></button>
</span><span class="cx" style="display: block; padding: 0 10px">                                <div style="clear:both"></div>
</span><span class="cx" style="display: block; padding: 0 10px">                        </div>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -795,7 +792,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        </div>
</span><span class="cx" style="display: block; padding: 0 10px">                        <div class="actions">
</span><span class="cx" style="display: block; padding: 0 10px">                                <# if ( data.defaultAttachment ) { #>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        <button type="button" class="button default-button remove-button"><?php echo $this->button_labels['default']; ?></button>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 <button type="button" class="button default-button"><?php echo $this->button_labels['default']; ?></button>
</ins><span class="cx" style="display: block; padding: 0 10px">                                 <# } #>
</span><span class="cx" style="display: block; padding: 0 10px">                                <button type="button" class="button upload-button" id="{{ data.settings.default }}-button"><?php echo $this->button_labels['select']; ?></button>
</span><span class="cx" style="display: block; padding: 0 10px">                                <div style="clear:both"></div>
</span></span></pre>
</div>
</div>

</body>
</html>