<!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>[20901] trunk: Preview by default the registered default image for custom backgrounds.</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/20901">20901</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-05-25 17:58:57 +0000 (Fri, 25 May 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Preview by default the registered default image for custom backgrounds. props mfields, billerickson.

If there is a default color registered, show a 'Default' action rather than a 'Clear' action, as clearing the value would simply return to the default.

Make current_theme_supports() accept a second argument for 'custom-background' requests, the same as get_theme_support(). Missed in earlier changes, see <a href="http://core.trac.wordpress.org/ticket/20249">#20249</a>.

fixes <a href="http://core.trac.wordpress.org/ticket/20734">#20734</a>, fixes <a href="http://core.trac.wordpress.org/ticket/18041">#18041</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincustombackgroundphp">trunk/wp-admin/custom-background.php</a></li>
<li><a href="#trunkwpadminjscustombackgrounddevjs">trunk/wp-admin/js/custom-background.dev.js</a></li>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.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 (20900 => 20901)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-background.php        2012-05-25 17:58:22 UTC (rev 20900)
+++ trunk/wp-admin/custom-background.php        2012-05-25 17:58:57 UTC (rev 20901)
</span><span class="lines">@@ -207,15 +207,15 @@
</span><span class="cx"> 
</span><span class="cx"> if ( get_background_image() ) {
</span><span class="cx">         // background-image URL must be single quote, see below
</span><del>-        $background_styles .= ' background-image: url(\'' . set_url_scheme( get_theme_mod('background_image_thumb', '') ) . '\');'
</del><ins>+        $background_styles .= ' background-image: url(\'' . set_url_scheme( get_theme_mod( 'background_image_thumb', get_background_image() ) ) . '\');'
</ins><span class="cx">                 . ' background-repeat: ' . get_theme_mod('background_repeat', 'repeat') . ';'
</span><span class="cx">                 . ' background-position: top ' . get_theme_mod('background_position_x', 'left');
</span><span class="cx"> }
</span><span class="cx"> ?&gt;
</span><span class="cx"> &lt;div id=&quot;custom-background-image&quot; style=&quot;&lt;?php echo $background_styles; ?&gt;&quot;&gt;&lt;?php // must be double quote, see above ?&gt;
</span><span class="cx"> &lt;?php if ( get_background_image() ) { ?&gt;
</span><del>-&lt;img class=&quot;custom-background-image&quot; src=&quot;&lt;?php echo set_url_scheme( get_theme_mod('background_image_thumb', '') ); ?&gt;&quot; style=&quot;visibility:hidden;&quot; alt=&quot;&quot; /&gt;&lt;br /&gt;
-&lt;img class=&quot;custom-background-image&quot; src=&quot;&lt;?php echo set_url_scheme( get_theme_mod('background_image_thumb', '') ); ?&gt;&quot; style=&quot;visibility:hidden;&quot; alt=&quot;&quot; /&gt;
</del><ins>+&lt;img class=&quot;custom-background-image&quot; src=&quot;&lt;?php echo set_url_scheme( get_theme_mod( 'background_image_thumb', get_background_image() ) ); ?&gt;&quot; style=&quot;visibility:hidden;&quot; alt=&quot;&quot; /&gt;&lt;br /&gt;
+&lt;img class=&quot;custom-background-image&quot; src=&quot;&lt;?php echo set_url_scheme( get_theme_mod( 'background_image_thumb', get_background_image() ) ); ?&gt;&quot; style=&quot;visibility:hidden;&quot; alt=&quot;&quot; /&gt;
</ins><span class="cx"> &lt;?php } ?&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;?php } ?&gt;
</span><span class="lines">@@ -322,9 +322,10 @@
</span><span class="cx"> &lt;tr valign=&quot;top&quot;&gt;
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Background Color' ); ?&gt;&lt;/th&gt;
</span><span class="cx"> &lt;td&gt;&lt;fieldset&gt;&lt;legend class=&quot;screen-reader-text&quot;&gt;&lt;span&gt;&lt;?php _e( 'Background Color' ); ?&gt;&lt;/span&gt;&lt;/legend&gt;
</span><del>-&lt;?php $show_clear = get_background_color() ? '' : ' style=&quot;display:none&quot;'; ?&gt;
</del><ins>+&lt;?php $show_clear = get_theme_mod('background_color') ? '' : ' style=&quot;display:none&quot;'; ?&gt;
</ins><span class="cx"> &lt;input type=&quot;text&quot; name=&quot;background-color&quot; id=&quot;background-color&quot; value=&quot;#&lt;?php echo esc_attr(get_background_color()) ?&gt;&quot; /&gt;
</span><del>-&lt;a class=&quot;hide-if-no-js&quot; href=&quot;#&quot; id=&quot;pickcolor&quot;&gt;&lt;?php _e('Select a Color'); ?&gt;&lt;/a&gt; &lt;span&lt;?php echo $show_clear; ?&gt; class=&quot;hide-if-no-js&quot; id=&quot;clearcolor&quot;&gt; (&lt;a href=&quot;#&quot;&gt;&lt;?php _e( 'Clear' ); ?&gt;&lt;/a&gt;)&lt;/span&gt;
</del><ins>+&lt;a class=&quot;hide-if-no-js&quot; href=&quot;#&quot; id=&quot;pickcolor&quot;&gt;&lt;?php _e('Select a Color'); ?&gt;&lt;/a&gt; &lt;span&lt;?php echo $show_clear; ?&gt; class=&quot;hide-if-no-js&quot; id=&quot;clearcolor&quot;&gt; (&lt;a href=&quot;#&quot;&gt;&lt;?php current_theme_supports( 'custom-background', 'default-color' ) ? _e( 'Default' ) : _e( 'Clear' ); ?&gt;&lt;/a&gt;)&lt;/span&gt;
+&lt;input type=&quot;hidden&quot; id=&quot;defaultcolor&quot; value=&quot;&lt;?php if ( current_theme_supports( 'custom-background', 'default-color' ) ) echo '#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ); ?&gt;&quot; /&gt;
</ins><span class="cx"> &lt;div id=&quot;colorPickerDiv&quot; style=&quot;z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/fieldset&gt;&lt;/td&gt;
</span><span class="cx"> &lt;/tr&gt;
</span></span></pre></div>
<a id="trunkwpadminjscustombackgrounddevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/custom-background.dev.js (20900 => 20901)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/custom-background.dev.js        2012-05-25 17:58:22 UTC (rev 20900)
+++ trunk/wp-admin/js/custom-background.dev.js        2012-05-25 17:58:57 UTC (rev 20901)
</span><span class="lines">@@ -1,55 +1,63 @@
</span><del>-var farbtastic;
</del><ins>+var farbtastic, pickColor;
</ins><span class="cx"> 
</span><del>-function pickColor(color) {
-        farbtastic.setColor(color);
-        jQuery('#background-color').val(color);
-        jQuery('#custom-background-image').css('background-color', color);
-        if ( color &amp;&amp; color !== '#' )
-                jQuery('#clearcolor').show();
-        else
-                jQuery('#clearcolor').hide();
-}
</del><ins>+(function($) {
</ins><span class="cx"> 
</span><del>-jQuery(document).ready(function() {
-        jQuery('#pickcolor').click(function() {
-                jQuery('#colorPickerDiv').show();
-                return false;
-        });
</del><ins>+        pickColor = function(color, cleared) {
+                farbtastic.setColor(color);
+                $('#background-color').val(color);
+                $('#custom-background-image').css('background-color', color);
+                console.log( color );
+                if ( typeof cleared === 'undefined' )
+                        cleared = ! color || color === '#';
+                if ( cleared )
+                        $('#clearcolor').hide();
+                else
+                        $('#clearcolor').show();
+        }
</ins><span class="cx"> 
</span><del>-        jQuery('#clearcolor a').click( function(e) {
-                pickColor('');
-                e.preventDefault();
</del><ins>+        $(document).ready(function() {
+        
+                $('#pickcolor').click(function() {
+                        $('#colorPickerDiv').show();
+                        return false;
+                });
+        
+                $('#clearcolor a').click( function(e) {
+                        pickColor( $('#defaultcolor').val(), true );
+                        e.preventDefault();
+                });
+        
+                $('#background-color').keyup(function() {
+                        var _hex = $('#background-color').val(), hex = _hex;
+                        if ( hex.charAt(0) != '#' )
+                                hex = '#' + hex;
+                        hex = hex.replace(/[^#a-fA-F0-9]+/, '');
+                        if ( hex != _hex )
+                                $('#background-color').val(hex);
+                        if ( hex.length == 4 || hex.length == 7 )
+                                pickColor( hex );
+                });
+        
+                $('input[name=&quot;background-position-x&quot;]').change(function() {
+                        $('#custom-background-image').css('background-position', $(this).val() + ' top');
+                });
+        
+                $('input[name=&quot;background-repeat&quot;]').change(function() {
+                        $('#custom-background-image').css('background-repeat', $(this).val());
+                });
+        
+                farbtastic = $.farbtastic('#colorPickerDiv', function(color) {
+                        pickColor(color);
+                });
+                pickColor($('#background-color').val());
+        
+                $(document).mousedown(function(){
+                        $('#colorPickerDiv').each(function(){
+                                var display = $(this).css('display');
+                                if ( display == 'block' )
+                                        $(this).fadeOut(2);
+                        });
+                });
</ins><span class="cx">         });
</span><span class="cx"> 
</span><del>-        jQuery('#background-color').keyup(function() {
-                var _hex = jQuery('#background-color').val(), hex = _hex;
-                if ( hex.charAt(0) != '#' )
-                        hex = '#' + hex;
-                hex = hex.replace(/[^#a-fA-F0-9]+/, '');
-                if ( hex != _hex )
-                        jQuery('#background-color').val(hex);
-                if ( hex.length == 4 || hex.length == 7 )
-                        pickColor( hex );
-        });
-
-        jQuery('input[name=&quot;background-position-x&quot;]').change(function() {
-                jQuery('#custom-background-image').css('background-position', jQuery(this).val() + ' top');
-        });
-
-        jQuery('input[name=&quot;background-repeat&quot;]').change(function() {
-                jQuery('#custom-background-image').css('background-repeat', jQuery(this).val());
-        });
-
-        farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) {
-                pickColor(color);
-        });
-        pickColor(jQuery('#background-color').val());
-
-        jQuery(document).mousedown(function(){
-                jQuery('#colorPickerDiv').each(function(){
-                        var display = jQuery(this).css('display');
-                        if ( display == 'block' )
-                                jQuery(this).fadeOut(2);
-                });
-        });
-});
</del><ins>+})(jQuery);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (20900 => 20901)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2012-05-25 17:58:22 UTC (rev 20900)
+++ trunk/wp-includes/theme.php        2012-05-25 17:58:57 UTC (rev 20901)
</span><span class="lines">@@ -1501,7 +1501,8 @@
</span><span class="cx">                         break;
</span><span class="cx"> 
</span><span class="cx">                 case 'custom-header':
</span><del>-                        // specific custom header capabilities can be registered by passing
</del><ins>+                case 'custom-background' :
+                        // specific custom header and background capabilities can be registered by passing
</ins><span class="cx">                         // an array to add_theme_support()
</span><span class="cx">                         $header_support = $args[0];
</span><span class="cx">                         return ( isset( $_wp_theme_features[$feature][0][$header_support] ) &amp;&amp; $_wp_theme_features[$feature][0][$header_support] );
</span></span></pre>
</div>
</div>

</body>
</html>