<!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-&gt;admin_image_div_callback);
</span><span class="cx"> } else {
</span><span class="cx"> ?&gt;
</span><del>-&lt;div id=&quot;background-image&quot;&gt;
-&lt;img src=&quot;&lt;?php background_image(); ?&gt;&quot; /&gt;
</del><ins>+&lt;div id=&quot;custom-background-image&quot;&gt;
+&lt;img class=&quot;custom-background-image&quot; src=&quot;&lt;?php background_image(); ?&gt;&quot; /&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;?php } ?&gt;
</span><span class="cx"> &lt;/div&gt;
</span><ins>+
+&lt;?php if ( get_background_image() ) : ?&gt;
</ins><span class="cx"> &lt;div class=&quot;wrap&quot;&gt;
</span><del>-&lt;h2&gt;&lt;?php _e('Upload New Background Image'); ?&gt;&lt;/h2&gt;&lt;p&gt;&lt;?php _e('Here you can upload a new background image.'); ?&gt;&lt;/p&gt;
</del><span class="cx"> 
</span><del>-&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; style=&quot;margin: auto; width: 50%;&quot;&gt;
-&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;
-&lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;save&quot; /&gt;
-&lt;?php wp_nonce_field('custom-background') ?&gt;
-&lt;p class=&quot;submit&quot;&gt;
-&lt;input type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Upload'); ?&gt;&quot; /&gt;
-&lt;/p&gt;
-&lt;/form&gt;
</del><ins>+&lt;h2&gt;&lt;?php _e('Change Display Options') ?&gt;&lt;/h2&gt;
+&lt;form method=&quot;post&quot; action=&quot;&lt;?php echo esc_attr(add_query_arg('step', 1)) ?&gt;&quot;&gt;
+&lt;table&gt;
+&lt;thead&gt;
+&lt;tr&gt;
+&lt;th scope=&quot;col&quot;&gt;&lt;?php _e( 'Position' ); ?&gt;&lt;/th&gt;
+&lt;th scope=&quot;col&quot;&gt;&lt;?php _e( 'Repeat' ); ?&gt;&lt;/th&gt;
+&lt;th scope=&quot;col&quot;&gt;&lt;?php _e( 'Attachment' ); ?&gt;&lt;/th&gt;
+&lt;/tr&gt;
</ins><span class="cx"> 
</span><del>-&lt;/div&gt;
</del><ins>+&lt;tbody&gt;
+&lt;tr&gt;
+&lt;td&gt;&lt;fieldset&gt;&lt;legend class=&quot;screen-reader-text&quot;&gt;&lt;span&gt;&lt;?php _e( 'Position' ); ?&gt;&lt;/span&gt;&lt;/legend&gt;
+&lt;label&gt;
+&lt;input name=&quot;background-position&quot; type=&quot;radio&quot; value=&quot;left&quot; &lt;?php checked('left', get_theme_mod('background_position')); ?&gt; /&gt;
+&lt;?php _e('Left') ?&gt;
+&lt;/label&gt;
+&lt;label&gt;
+&lt;input name=&quot;background-position&quot; type=&quot;radio&quot; value=&quot;center&quot; &lt;?php checked('center', get_theme_mod('background_position')); ?&gt; /&gt;
+&lt;?php _e('Center') ?&gt;
+&lt;/label&gt;
+&lt;label&gt;
+&lt;input name=&quot;background-position&quot; type=&quot;radio&quot; value=&quot;right&quot; &lt;?php checked('right', get_theme_mod('background_position')); ?&gt; /&gt;
+&lt;?php _e('Right') ?&gt;
+&lt;/label&gt;
+&lt;/fieldset&gt;&lt;/td&gt;
</ins><span class="cx"> 
</span><del>-&lt;div class=&quot;wrap&quot;&gt;
</del><ins>+&lt;td&gt;&lt;fieldset&gt;&lt;legend class=&quot;screen-reader-text&quot;&gt;&lt;span&gt;&lt;?php _e( 'Repeat' ); ?&gt;&lt;/span&gt;&lt;/legend&gt;
+&lt;label&gt;
+&lt;input name=&quot;background-repeat&quot; type=&quot;radio&quot; value=&quot;no-repeat&quot; &lt;?php checked('no-repeat', get_theme_mod('background_repeat')); ?&gt; /&gt;
+&lt;?php _e('No repeat') ?&gt;
+&lt;/label&gt;
+&lt;label&gt;
+&lt;input name=&quot;background-repeat&quot; type=&quot;radio&quot; value=&quot;repeat&quot; &lt;?php checked('repeat', get_theme_mod('background_repeat')); ?&gt; /&gt;
+&lt;?php _e('Tile') ?&gt;
+&lt;/label&gt;
+&lt;/fieldset&gt;&lt;/td&gt;
</ins><span class="cx"> 
</span><del>-&lt;h2&gt;&lt;?php _e('Change Display Options') ?&gt;&lt;/h2&gt;
-&lt;form method=&quot;post&quot; action=&quot;&lt;?php echo esc_attr(add_query_arg('step', 1)) ?&gt;&quot;&gt;
-&lt;label for=&quot;repeat-background&quot;&gt;
-&lt;p&gt;&lt;input name=&quot;repeat-background&quot; type=&quot;checkbox&quot; id=&quot;repeat-background&quot; value=&quot;1&quot; &lt;?php checked(true, get_theme_mod('background_repeat')); ?&gt; /&gt;
-&lt;?php _e('Tile the background.') ?&gt;&lt;/label&gt;&lt;/p&gt;
</del><ins>+&lt;td&gt;&lt;fieldset&gt;&lt;legend class=&quot;screen-reader-text&quot;&gt;&lt;span&gt;&lt;?php _e( 'Attachment' ); ?&gt;&lt;/span&gt;&lt;/legend&gt;
+&lt;label&gt;
+&lt;input name=&quot;background-attachment&quot; type=&quot;radio&quot; value=&quot;scroll&quot; &lt;?php checked('scroll', get_theme_mod('background_attachment')); ?&gt; /&gt;
+&lt;?php _e('Scroll') ?&gt;
+&lt;/label&gt;
+&lt;label&gt;
+&lt;input name=&quot;background-attachment&quot; type=&quot;radio&quot; value=&quot;fixed&quot; &lt;?php checked('fixed', get_theme_mod('background_attachment')); ?&gt; /&gt;
+&lt;?php _e('Fixed') ?&gt;
+&lt;/label&gt;
+&lt;/fieldset&gt;&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/tbody&gt;
+&lt;/table&gt;
+
</ins><span class="cx"> &lt;?php wp_nonce_field('custom-background'); ?&gt;
</span><span class="cx"> &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;
</span><span class="cx"> &lt;/form&gt;
</span><span class="cx"> &lt;/div&gt;
</span><ins>+&lt;?php endif; ?&gt;
</ins><span class="cx"> 
</span><del>-&lt;?php if ( get_theme_mod('background_image') ) : ?&gt;
</del><span class="cx"> &lt;div class=&quot;wrap&quot;&gt;
</span><del>-&lt;h2&gt;&lt;?php _e('Reset Background Image'); ?&gt;&lt;/h2&gt;
-&lt;p&gt;&lt;?php _e('This will restore the original background image. You will not be able to retrieve any customizations.') ?&gt;&lt;/p&gt;
-&lt;form method=&quot;post&quot; action=&quot;&lt;?php echo esc_attr(add_query_arg('step', 1)) ?&gt;&quot;&gt;
-&lt;?php wp_nonce_field('custom-background'); ?&gt;
-&lt;input type=&quot;submit&quot; class=&quot;button&quot; name=&quot;reset-background&quot; value=&quot;&lt;?php esc_attr_e('Restore Original Background'); ?&gt;&quot; /&gt;
</del><ins>+&lt;h2&gt;&lt;?php _e('Upload New Background Image'); ?&gt;&lt;/h2&gt;
+&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; style=&quot;margin: auto; width: 50%;&quot;&gt;
+&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;
+&lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;save&quot; /&gt;
+&lt;?php wp_nonce_field('custom-background') ?&gt;
+&lt;p class=&quot;submit&quot;&gt;
+&lt;input type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Upload'); ?&gt;&quot; /&gt;
+&lt;/p&gt;
</ins><span class="cx"> &lt;/form&gt;
</span><span class="cx"> &lt;/div&gt;
</span><del>-&lt;?php endif;
</del><span class="cx"> 
</span><del>-if ( get_background_image() ) :
-?&gt;
</del><ins>+&lt;?php if ( get_background_image() ) : ?&gt;
</ins><span class="cx"> &lt;div class=&quot;wrap&quot;&gt;
</span><span class="cx"> &lt;h2&gt;&lt;?php _e('Remove Background Image'); ?&gt;&lt;/h2&gt;
</span><span class="cx"> &lt;p&gt;&lt;?php _e('This will remove background image. You will not be able to retrieve any customizations.') ?&gt;&lt;/p&gt;
</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"> ?&gt;
</span><span class="cx"> &lt;style type=&quot;text/css&quot;&gt;
</span><span class="cx"> body {
</span><del>-        background: url('&lt;?php background_image(); ?&gt;') fixed &lt;?php echo $repeat ?&gt;;
</del><ins>+        background-image:url('&lt;?php background_image(); ?&gt;');
+        &lt;?php echo $repeat; ?&gt;
+        &lt;?php echo $position; ?&gt;
+        &lt;?php echo $attachment; ?&gt;
</ins><span class="cx"> }
</span><span class="cx"> &lt;/style&gt;
</span><span class="cx"> &lt;?php
</span></span></pre>
</div>
</div>

</body>
</html>