<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[13765] trunk/wp-admin/custom-background.php:
  Show Background preview and options when no Image is uploaded.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13765">13765</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-03-19 09:33:29 +0000 (Fri, 19 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Show Background preview and options when no Image is uploaded. Display &quot;Updated&quot; div upon updates. Fix Colour Picker not loading after uploading a background image. See <a href="http://trac.wordpress.org/ticket/12186">#12186</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincustombackgroundphp">trunk/wp-admin/custom-background.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 (13764 => 13765)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-background.php        2010-03-19 09:10:37 UTC (rev 13764)
+++ trunk/wp-admin/custom-background.php        2010-03-19 09:33:29 UTC (rev 13765)
</span><span class="lines">@@ -89,10 +89,7 @@
</span><span class="cx">          * @since unknown
</span><span class="cx">          */
</span><span class="cx">         function js_includes() {
</span><del>-                $step = $this-&gt;step();
-
-                if ( 1 == $step )
-                        wp_enqueue_script('farbtastic');
</del><ins>+                wp_enqueue_script('farbtastic');
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -101,10 +98,7 @@
</span><span class="cx">          * @since unknown
</span><span class="cx">          */
</span><span class="cx">         function css_includes() {
</span><del>-                $step = $this-&gt;step();
-
-                if ( 1 == $step )
-                        wp_enqueue_style('farbtastic');
</del><ins>+                wp_enqueue_style('farbtastic');
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -153,6 +147,8 @@
</span><span class="cx">                         else
</span><span class="cx">                                 set_theme_mod('background_color', '');
</span><span class="cx">                 }
</span><ins>+
+                $this-&gt;updated = true;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -161,9 +157,7 @@
</span><span class="cx">          * @since unknown
</span><span class="cx">          */
</span><span class="cx">         function js() {
</span><del>-                $step = $this-&gt;step();
-                if ( 1 == $step )
-                        $this-&gt;js_1();
</del><ins>+                $this-&gt;js_1();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -234,13 +228,11 @@
</span><span class="cx"> &lt;div class=&quot;wrap&quot; id=&quot;custom-background&quot;&gt;
</span><span class="cx"> &lt;?php screen_icon(); ?&gt;
</span><span class="cx"> &lt;h2&gt;&lt;?php _e('Custom Background'); ?&gt;&lt;/h2&gt;
</span><del>-&lt;?php if ( isset($_GET['updated']) &amp;&amp; $_GET['updated'] ) { ?&gt;
</del><ins>+&lt;?php if ( !empty($this-&gt;updated) ) { ?&gt;
</ins><span class="cx"> &lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;
</span><span class="cx"> &lt;p&gt;&lt;?php printf(__('Background updated. &lt;a href=&quot;%s&quot;&gt;Visit your site&lt;/a&gt; to see how it looks.'), home_url()); ?&gt;&lt;/p&gt;
</span><span class="cx"> &lt;/div&gt;
</span><del>-&lt;?php }
-
-if ( get_background_image() || get_background_color() ) { ?&gt;
</del><ins>+&lt;?php } ?&gt;
</ins><span class="cx"> &lt;p&gt;&lt;?php _e('This is your current background.'); ?&gt;&lt;/p&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx">         if ( $this-&gt;admin_image_div_callback ) {
</span><span class="lines">@@ -256,13 +248,7 @@
</span><span class="cx"> &lt;img class=&quot;custom-background-image&quot; src=&quot;&lt;?php background_image(); ?&gt;&quot; /&gt;
</span><span class="cx"> &lt;?php } ?&gt;
</span><span class="cx"> &lt;/div&gt;
</span><del>-&lt;?php }
-} else { ?&gt;
-&lt;p&gt;&lt;?php _e('There is currently no background image.'); ?&gt;&lt;/p&gt; &lt;?php
-}
-
-if ( get_background_image() ) : ?&gt;
-
</del><ins>+&lt;?php } ?&gt;
</ins><span class="cx"> &lt;h3&gt;&lt;?php _e('Change Display Options') ?&gt;&lt;/h3&gt;
</span><span class="cx"> &lt;form method=&quot;post&quot; action=&quot;&lt;?php echo esc_attr(add_query_arg('step', 1)) ?&gt;&quot;&gt;
</span><span class="cx"> &lt;table&gt;
</span><span class="lines">@@ -327,8 +313,6 @@
</span><span class="cx"> &lt;p class=&quot;submit&quot;&gt;&lt;input type=&quot;submit&quot; class=&quot;button&quot; name=&quot;save-background-options&quot; value=&quot;&lt;?php esc_attr_e('Save Changes'); ?&gt;&quot; /&gt;&lt;/p&gt;
</span><span class="cx"> &lt;/form&gt;
</span><span class="cx"> 
</span><del>-&lt;?php endif; ?&gt;
-
</del><span class="cx"> &lt;h3&gt;&lt;?php _e('Upload New Background Image'); ?&gt;&lt;/h3&gt;
</span><span class="cx"> &lt;form enctype=&quot;multipart/form-data&quot; id=&quot;uploadForm&quot; method=&quot;POST&quot; action=&quot;&lt;?php echo esc_attr(add_query_arg('step', 2)) ?&gt;&quot;&gt;
</span><span class="cx"> &lt;label for=&quot;upload&quot;&gt;&lt;?php _e('Choose an image from your computer:'); ?&gt;&lt;/label&gt;&lt;br /&gt;&lt;input type=&quot;file&quot; id=&quot;upload&quot; name=&quot;import&quot; /&gt;
</span><span class="lines">@@ -363,7 +347,7 @@
</span><span class="cx">                 $file = wp_handle_upload($_FILES['import'], $overrides);
</span><span class="cx"> 
</span><span class="cx">                 if ( isset($file['error']) )
</span><del>-                        die( $file['error'] );
</del><ins>+                        wp_die( $file['error'] );
</ins><span class="cx"> 
</span><span class="cx">                 $url = $file['url'];
</span><span class="cx">                 $type = $file['type'];
</span><span class="lines">@@ -372,10 +356,11 @@
</span><span class="cx"> 
</span><span class="cx">                 // Construct the object array
</span><span class="cx">                 $object = array(
</span><del>-                'post_title' =&gt; $filename,
-                'post_content' =&gt; $url,
-                'post_mime_type' =&gt; $type,
-                'guid' =&gt; $url);
</del><ins>+                        'post_title' =&gt; $filename,
+                        'post_content' =&gt; $url,
+                        'post_mime_type' =&gt; $type,
+                        'guid' =&gt; $url
+                );
</ins><span class="cx"> 
</span><span class="cx">                 // Save the data
</span><span class="cx">                 $id = wp_insert_attachment($object, $file);
</span><span class="lines">@@ -385,6 +370,7 @@
</span><span class="cx"> 
</span><span class="cx">                 set_theme_mod('background_image', esc_url($url));
</span><span class="cx">                 do_action('wp_create_file_in_uploads', $file, $id); // For replication
</span><ins>+                $this-&gt;updated = true;
</ins><span class="cx">                 return $this-&gt;finished();
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -394,8 +380,7 @@
</span><span class="cx">          * @since unknown
</span><span class="cx">          */
</span><span class="cx">         function finished() {
</span><del>-                $_GET['updated'] = 1;
-          $this-&gt;step_1();
</del><ins>+                $this-&gt;step_1();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span></span></pre>
</div>
</div>

</body>
</html>