<!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 "Updated" 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->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->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->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->step();
-                if ( 1 == $step )
-                        $this->js_1();
</del><ins>+                $this->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"> <div class="wrap" id="custom-background">
</span><span class="cx"> <?php screen_icon(); ?>
</span><span class="cx"> <h2><?php _e('Custom Background'); ?></h2>
</span><del>-<?php if ( isset($_GET['updated']) && $_GET['updated'] ) { ?>
</del><ins>+<?php if ( !empty($this->updated) ) { ?>
</ins><span class="cx"> <div id="message" class="updated">
</span><span class="cx"> <p><?php printf(__('Background updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url()); ?></p>
</span><span class="cx"> </div>
</span><del>-<?php }
-
-if ( get_background_image() || get_background_color() ) { ?>
</del><ins>+<?php } ?>
</ins><span class="cx"> <p><?php _e('This is your current background.'); ?></p>
</span><span class="cx"> <?php
</span><span class="cx">         if ( $this->admin_image_div_callback ) {
</span><span class="lines">@@ -256,13 +248,7 @@
</span><span class="cx"> <img class="custom-background-image" src="<?php background_image(); ?>" />
</span><span class="cx"> <?php } ?>
</span><span class="cx"> </div>
</span><del>-<?php }
-} else { ?>
-<p><?php _e('There is currently no background image.'); ?></p> <?php
-}
-
-if ( get_background_image() ) : ?>
-
</del><ins>+<?php } ?>
</ins><span class="cx"> <h3><?php _e('Change Display Options') ?></h3>
</span><span class="cx"> <form method="post" action="<?php echo esc_attr(add_query_arg('step', 1)) ?>">
</span><span class="cx"> <table>
</span><span class="lines">@@ -327,8 +313,6 @@
</span><span class="cx"> <p class="submit"><input type="submit" class="button" name="save-background-options" value="<?php esc_attr_e('Save Changes'); ?>" /></p>
</span><span class="cx"> </form>
</span><span class="cx">
</span><del>-<?php endif; ?>
-
</del><span class="cx"> <h3><?php _e('Upload New Background Image'); ?></h3>
</span><span class="cx"> <form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo esc_attr(add_query_arg('step', 2)) ?>">
</span><span class="cx"> <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" />
</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' => $filename,
-                'post_content' => $url,
-                'post_mime_type' => $type,
-                'guid' => $url);
</del><ins>+                        'post_title' => $filename,
+                        'post_content' => $url,
+                        'post_mime_type' => $type,
+                        'guid' => $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->updated = true;
</ins><span class="cx">                 return $this->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->step_1();
</del><ins>+                $this->step_1();
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span></span></pre>
</div>
</div>
</body>
</html>