Ticket #12186: background.patch
File background.patch, 9.4 KB (added by , 15 years ago) |
---|
-
wp-admin/custom-background.php
107 107 $repeat = 'repeat'; 108 108 set_theme_mod('background_repeat', $repeat); 109 109 } 110 if ( isset($_POST['background-position ']) ) {110 if ( isset($_POST['background-position-x']) ) { 111 111 check_admin_referer('custom-background'); 112 if ( in_array($_POST['background-position '], array('center', 'right', 'left')) )113 $position = $_POST['background-position '];112 if ( in_array($_POST['background-position-x'], array('center', 'right', 'left')) ) 113 $position = $_POST['background-position-x']; 114 114 else 115 115 $position = 'left'; 116 set_theme_mod('background_position ', $position);116 set_theme_mod('background_position_x', $position); 117 117 } 118 118 if ( isset($_POST['background-attachment']) ) { 119 119 check_admin_referer('custom-background'); … … 155 155 call_user_func($this->admin_image_div_callback); 156 156 } else { 157 157 ?> 158 <h3><?php _e('Background Preview'); ?></h3>159 158 <table class="form-table"> 160 159 <tbody> 161 160 <tr valign="top"> 162 <th scope="row"><?php _e(' Current Background'); ?></th>161 <th scope="row"><?php _e('Background Preview'); ?></th> 163 162 <td> 164 163 <?php 165 164 $background_styles = ''; … … 171 170 $background_styles .= " 172 171 background-image: url(" . get_theme_mod('background_image_thumb', '') . "); 173 172 background-repeat: ". get_theme_mod('background_repeat', 'repeat') . "; 174 background-position: ". get_theme_mod('background_position', 'left') . " top; 175 background-attachment: " . get_theme_mod('background_attachment', 'fixed') . "; 173 background-position: ". get_theme_mod('background_position_x', 'left') . " top; 176 174 "; 177 175 } 178 176 ?> … … 181 179 <img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" alt="" /><br /> 182 180 <img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" alt="" /> 183 181 <?php } ?> 184 <br class="clear" />185 182 </div> 186 183 <?php } ?> 187 184 </td> 188 185 </tr> 186 </tbody> 187 </table> 188 189 <form method="post" action=""> 190 <table class="form-table"> 191 <tbody> 192 <tr valign="top"> 193 <th scope="row"><?php _e( 'Background Color' ); ?></th> 194 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend> 195 <input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr(get_background_color()) ?>" /> 196 <input type="button" class="button" value="<?php esc_attr_e('Select a Color'); ?>" id="pickcolor" /> 197 198 <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> 199 </fieldset></td> 200 </tr> 201 </tbody> 202 </table> 203 </form> 204 205 <h3><?php _e('Background Image'); ?></h3> 206 <table class="form-table"> 207 <tbody> 189 208 <?php if ( get_background_image() ) : ?> 190 209 <tr valign="top"> 191 210 <th scope="row"><?php _e('Remove Image'); ?></th> 192 <td> <p><?php _e('This will remove the background image. You will not be able to restore any customizations.') ?></p>211 <td> 193 212 <form method="post" action=""> 213 <p><?php _e('This will remove the background image. You will not be able to restore any customizations.') ?></p> 194 214 <?php wp_nonce_field('custom-background-remove', '_wpnonce-custom-background-remove'); ?> 195 <input type="submit" class="button" name="remove-background" value="<?php esc_attr_e('Remove Background '); ?>" />215 <input type="submit" class="button" name="remove-background" value="<?php esc_attr_e('Remove Background Image'); ?>" /> 196 216 </form> 197 217 </td> 198 218 </tr> … … 201 221 <?php if ( defined( 'BACKGROUND_IMAGE' ) ) : // Show only if a default background image exists ?> 202 222 <tr valign="top"> 203 223 <th scope="row"><?php _e('Restore Original Image'); ?></th> 204 <td> <p><?php _e('This will restore the original background image. You will not be able to restore any customizations.') ?></p>224 <td> 205 225 <form method="post" action=""> 226 <p><?php _e('This will restore the original background image. You will not be able to restore any customizations.') ?></p> 206 227 <?php wp_nonce_field('custom-background-reset', '_wpnonce-custom-background-reset'); ?> 207 228 <input type="submit" class="button" name="reset-background" value="<?php esc_attr_e('Restore Original Image'); ?>" /> 208 229 </form> … … 212 233 <?php endif; ?> 213 234 <tr valign="top"> 214 235 <th scope="row"><?php _e('Upload Image'); ?></th> 215 <td><form enctype="multipart/form-data" id="upload-form" method="post" action=""> 216 <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" /> 236 <td> 237 <form enctype="multipart/form-data" id="upload-form" method="post" action=""> 238 <p><label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /> 239 <input type="file" id="upload" name="import" /> 217 240 <input type="hidden" name="action" value="save" /> 218 241 <?php wp_nonce_field('custom-background-upload', '_wpnonce-custom-background-upload') ?> 219 <p class="submit"> 220 <input type="submit" value="<?php esc_attr_e('Upload'); ?>" /> 242 <input type="submit" class="button" value="<?php esc_attr_e('Upload'); ?>" /> 221 243 </p> 222 244 </form> 223 245 </td> … … 225 247 </tbody> 226 248 </table> 227 249 228 <h3><?php _e('Display Options') ?></h3>229 250 <form method="post" action=""> 230 251 <table class="form-table"> 231 252 <tbody> 232 253 <tr valign="top"> 233 <th scope="row"><?php _e( 'Background Color' ); ?></th>234 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend>235 <input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr(get_background_color()) ?>" />236 <input type="button" class="button" value="<?php esc_attr_e('Select a Color'); ?>" id="pickcolor" />237 238 <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>239 </fieldset></td>240 </tr>241 242 <tr valign="top">243 254 <th scope="row"><?php _e( 'Background Position' ); ?></th> 244 255 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend> 245 256 <label> 246 <input name="background-position " type="radio" value="left" <?php checked('left', get_theme_mod('background_position', 'left')); ?> />257 <input name="background-position-x" type="radio" value="left" <?php checked('left', get_theme_mod('background_position_x', 'left')); ?> /> 247 258 <?php _e('Left') ?> 248 259 </label> 249 260 <label> 250 <input name="background-position " type="radio" value="center" <?php checked('center', get_theme_mod('background_position', 'left')); ?> />261 <input name="background-position-x" type="radio" value="center" <?php checked('center', get_theme_mod('background_position_x', 'left')); ?> /> 251 262 <?php _e('Center') ?> 252 263 </label> 253 264 <label> 254 <input name="background-position " type="radio" value="right" <?php checked('right', get_theme_mod('background_position', 'left')); ?> />265 <input name="background-position-x" type="radio" value="right" <?php checked('right', get_theme_mod('background_position_x', 'left')); ?> /> 255 266 <?php _e('Right') ?> 256 267 </label> 257 268 </fieldset></td> 258 269 </tr> 259 270 260 271 <tr valign="top"> 261 <th scope="row"><?php _e( ' Repeat' ); ?></th>272 <th scope="row"><?php _e( 'Background Repeat' ); ?></th> 262 273 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Repeat' ); ?></span></legend> 263 274 <label> 264 275 <select name="background-repeat"> … … 272 283 </tr> 273 284 274 285 <tr valign="top"> 275 <th scope="row"><?php _e( ' Attachment' ); ?></th>286 <th scope="row"><?php _e( 'Background Attachment' ); ?></th> 276 287 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Attachment' ); ?></span></legend> 277 288 <label> 278 289 <input name="background-attachment" type="radio" value="scroll" <?php checked('scroll', get_theme_mod('background_attachment', 'fixed')); ?> /> -
wp-admin/js/custom-background.dev.js
23 23 pickColor( hex ); 24 24 }); 25 25 26 jQuery('input[name="background-position "]').change(function() {27 jQuery('#custom-background-image').css('background-position', 'top ' + jQuery(this).val());26 jQuery('input[name="background-position-x"]').change(function() { 27 jQuery('#custom-background-image').css('background-position', jQuery(this).val() + ' top'); 28 28 }); 29 29 30 30 jQuery('select[name="background-repeat"]').change(function() { 31 31 jQuery('#custom-background-image').css('background-repeat', jQuery(this).val()); 32 32 }); 33 34 jQuery('input[name="background-attachment"]').change(function() {35 jQuery('#custom-background-image').css('background-attachment', jQuery(this).val());36 });37 33 38 34 farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) { 39 35 pickColor(color); -
wp-includes/theme.php
1553 1553 $repeat = 'background-repeat: repeat;'; 1554 1554 } 1555 1555 1556 switch ( get_theme_mod('background_position ', 'left') ) {1556 switch ( get_theme_mod('background_position_x', 'left') ) { 1557 1557 case 'center': 1558 $position = 'background-position: top center;';1558 $position = 'background-position: center top;'; 1559 1559 break; 1560 1560 case 'right': 1561 $position = 'background-position: top right;';1561 $position = 'background-position: right top;'; 1562 1562 break; 1563 1563 default: 1564 $position = 'background-position: top left;';1564 $position = 'background-position: left top;'; 1565 1565 } 1566 1566 1567 1567 if ( 'scroll' == get_theme_mod('background_attachment', 'fixed') )