<!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>[13186] trunk: Add some options to custom background admin.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13186">13186</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-18 00:14:56 +0000 (Thu, 18 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add some options to custom background admin. Needs styling. 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>
<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 (13185 => 13186)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-background.php        2010-02-17 20:36:00 UTC (rev 13185)
+++ trunk/wp-admin/custom-background.php        2010-02-18 00:14:56 UTC (rev 13186)
</span><span class="lines">@@ -93,13 +93,30 @@
</span><span class="cx">                         check_admin_referer('custom-background');
</span><span class="cx">                         remove_theme_mods();
</span><span class="cx">                 }
</span><del>-                if ( isset($_POST['repeat-background']) ) {
</del><ins>+                if ( isset($_POST['background-repeat']) ) {
</ins><span class="cx">                         check_admin_referer('custom-background');
</span><del>-                        $repeat = $_POST['repeat-background'] ? true: false;
</del><ins>+                        if ( in_array($_POST['background-repeat'], array('repeat', 'no-repeat')) )
+                                $repeat = $_POST['background-repeat'];
+                        else
+                                $repeat = 'repeat';
</ins><span class="cx">                         set_theme_mod('background_repeat', $repeat);
</span><del>-                } elseif ( isset($_POST['save-background-options']) ) {
-                        set_theme_mod('background_repeat', false);
</del><span class="cx">                 }
</span><ins>+                if ( isset($_POST['background-position']) ) {
+                        check_admin_referer('custom-background');
+                        if ( in_array($_POST['background-position'], array('center', 'right', 'left')) )
+                                $position = $_POST['background-position'];
+                        else
+                                $position = 'left';
+                        set_theme_mod('background_position', $position);
+                }
+                if ( isset($_POST['background-attachment']) ) {
+                        check_admin_referer('custom-background');
+                        if ( in_array($_POST['background-attachment'], array('fixed', 'scroll')) )
+                                $attachment = $_POST['background-attachment'];
+                        else
+                                $attachment = 'fixed';
+                        set_theme_mod('background_attachment', $attachment);
+                }
</ins><span class="cx">                 if ( isset($_POST['remove-background']) ) {
</span><span class="cx">                         check_admin_referer('custom-background');
</span><span class="cx">                         set_theme_mod('background_image', '');
</span><span class="lines">@@ -132,50 +149,86 @@
</span><span class="cx"> call_user_func($this->admin_image_div_callback);
</span><span class="cx"> } else {
</span><span class="cx"> ?>
</span><del>-<div id="background-image">
-<img src="<?php background_image(); ?>" />
</del><ins>+<div id="custom-background-image">
+<img class="custom-background-image" src="<?php background_image(); ?>" />
</ins><span class="cx"> </div>
</span><span class="cx"> <?php } ?>
</span><span class="cx"> </div>
</span><ins>+
+<?php if ( get_background_image() ) : ?>
</ins><span class="cx"> <div class="wrap">
</span><del>-<h2><?php _e('Upload New Background Image'); ?></h2><p><?php _e('Here you can upload a new background image.'); ?></p>
</del><span class="cx">
</span><del>-<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo esc_attr(add_query_arg('step', 2)) ?>" style="margin: auto; width: 50%;">
-<label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" />
-<input type="hidden" name="action" value="save" />
-<?php wp_nonce_field('custom-background') ?>
-<p class="submit">
-<input type="submit" value="<?php esc_attr_e('Upload'); ?>" />
-</p>
-</form>
</del><ins>+<h2><?php _e('Change Display Options') ?></h2>
+<form method="post" action="<?php echo esc_attr(add_query_arg('step', 1)) ?>">
+<table>
+<thead>
+<tr>
+<th scope="col"><?php _e( 'Position' ); ?></th>
+<th scope="col"><?php _e( 'Repeat' ); ?></th>
+<th scope="col"><?php _e( 'Attachment' ); ?></th>
+</tr>
</ins><span class="cx">
</span><del>-</div>
</del><ins>+<tbody>
+<tr>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Position' ); ?></span></legend>
+<label>
+<input name="background-position" type="radio" value="left" <?php checked('left', get_theme_mod('background_position')); ?> />
+<?php _e('Left') ?>
+</label>
+<label>
+<input name="background-position" type="radio" value="center" <?php checked('center', get_theme_mod('background_position')); ?> />
+<?php _e('Center') ?>
+</label>
+<label>
+<input name="background-position" type="radio" value="right" <?php checked('right', get_theme_mod('background_position')); ?> />
+<?php _e('Right') ?>
+</label>
+</fieldset></td>
</ins><span class="cx">
</span><del>-<div class="wrap">
</del><ins>+<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Repeat' ); ?></span></legend>
+<label>
+<input name="background-repeat" type="radio" value="no-repeat" <?php checked('no-repeat', get_theme_mod('background_repeat')); ?> />
+<?php _e('No repeat') ?>
+</label>
+<label>
+<input name="background-repeat" type="radio" value="repeat" <?php checked('repeat', get_theme_mod('background_repeat')); ?> />
+<?php _e('Tile') ?>
+</label>
+</fieldset></td>
</ins><span class="cx">
</span><del>-<h2><?php _e('Change Display Options') ?></h2>
-<form method="post" action="<?php echo esc_attr(add_query_arg('step', 1)) ?>">
-<label for="repeat-background">
-<p><input name="repeat-background" type="checkbox" id="repeat-background" value="1" <?php checked(true, get_theme_mod('background_repeat')); ?> />
-<?php _e('Tile the background.') ?></label></p>
</del><ins>+<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Attachment' ); ?></span></legend>
+<label>
+<input name="background-attachment" type="radio" value="scroll" <?php checked('scroll', get_theme_mod('background_attachment')); ?> />
+<?php _e('Scroll') ?>
+</label>
+<label>
+<input name="background-attachment" type="radio" value="fixed" <?php checked('fixed', get_theme_mod('background_attachment')); ?> />
+<?php _e('Fixed') ?>
+</label>
+</fieldset></td>
+</tr>
+</tbody>
+</table>
+
</ins><span class="cx"> <?php wp_nonce_field('custom-background'); ?>
</span><span class="cx"> <input type="submit" class="button" name="save-background-options" value="<?php esc_attr_e('Save Changes'); ?>" />
</span><span class="cx"> </form>
</span><span class="cx"> </div>
</span><ins>+<?php endif; ?>
</ins><span class="cx">
</span><del>-<?php if ( get_theme_mod('background_image') ) : ?>
</del><span class="cx"> <div class="wrap">
</span><del>-<h2><?php _e('Reset Background Image'); ?></h2>
-<p><?php _e('This will restore the original background image. You will not be able to retrieve any customizations.') ?></p>
-<form method="post" action="<?php echo esc_attr(add_query_arg('step', 1)) ?>">
-<?php wp_nonce_field('custom-background'); ?>
-<input type="submit" class="button" name="reset-background" value="<?php esc_attr_e('Restore Original Background'); ?>" />
</del><ins>+<h2><?php _e('Upload New Background Image'); ?></h2>
+<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo esc_attr(add_query_arg('step', 2)) ?>" style="margin: auto; width: 50%;">
+<label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" />
+<input type="hidden" name="action" value="save" />
+<?php wp_nonce_field('custom-background') ?>
+<p class="submit">
+<input type="submit" value="<?php esc_attr_e('Upload'); ?>" />
+</p>
</ins><span class="cx"> </form>
</span><span class="cx"> </div>
</span><del>-<?php endif;
</del><span class="cx">
</span><del>-if ( get_background_image() ) :
-?>
</del><ins>+<?php if ( get_background_image() ) : ?>
</ins><span class="cx"> <div class="wrap">
</span><span class="cx"> <h2><?php _e('Remove Background Image'); ?></h2>
</span><span class="cx"> <p><?php _e('This will remove background image. You will not be able to retrieve any customizations.') ?></p>
</span></span></pre></div>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (13185 => 13186)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2010-02-17 20:36:00 UTC (rev 13185)
+++ trunk/wp-includes/theme.php        2010-02-18 00:14:56 UTC (rev 13186)
</span><span class="lines">@@ -1398,11 +1398,29 @@
</span><span class="cx">                 return;
</span><span class="cx">
</span><span class="cx">         $repeat = get_theme_mod('background_repeat');
</span><del>-        $repeat = $repeat ? '' : ' no-repeat';
</del><ins>+        if ( 'no-repeat' == $repeat )
+                $repeat = 'background-repeat: no-repeat;';
+        else
+                $repeat = 'background-repeat: repeat;';
+        $position = get_theme_mod('background_position');
+        if ( 'center' == $position )
+                $position = 'background-position: center;';
+        elseif ( 'right' == $position )
+                $position = 'background-position: right;';
+        else
+                $position = 'background-position: left;';
+        $attachment = get_theme_mod('background_attachment');
+        if ( 'scroll' == $attachment )
+                $attachment = 'background-attachment: scroll;';
+        else
+                $attachment = 'background-attachment: fixed;';
</ins><span class="cx"> ?>
</span><span class="cx"> <style type="text/css">
</span><span class="cx"> body {
</span><del>-        background: url('<?php background_image(); ?>') fixed <?php echo $repeat ?>;
</del><ins>+        background-image:url('<?php background_image(); ?>');
+        <?php echo $repeat; ?>
+        <?php echo $position; ?>
+        <?php echo $attachment; ?>
</ins><span class="cx"> }
</span><span class="cx"> </style>
</span><span class="cx"> <?php
</span></span></pre>
</div>
</div>
</body>
</html>