Improve the custom background front-end callback. Also, background-attachment should default to scroll, not fixed. fixes #13751.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15196 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4c53975440
commit
69164abe07
|
@ -281,11 +281,11 @@ if ( get_background_image() ) {
|
||||||
<th scope="row"><?php _e( 'Attachment' ); ?></th>
|
<th scope="row"><?php _e( 'Attachment' ); ?></th>
|
||||||
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Attachment' ); ?></span></legend>
|
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Attachment' ); ?></span></legend>
|
||||||
<label>
|
<label>
|
||||||
<input name="background-attachment" type="radio" value="scroll" <?php checked('scroll', get_theme_mod('background_attachment', 'fixed')); ?> />
|
<input name="background-attachment" type="radio" value="scroll" <?php checked('scroll', get_theme_mod('background_attachment', 'scroll')); ?> />
|
||||||
<?php _e('Scroll') ?>
|
<?php _e('Scroll') ?>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input name="background-attachment" type="radio" value="fixed" <?php checked('fixed', get_theme_mod('background_attachment', 'fixed')); ?> />
|
<input name="background-attachment" type="radio" value="fixed" <?php checked('fixed', get_theme_mod('background_attachment', 'scroll')); ?> />
|
||||||
<?php _e('Fixed') ?>
|
<?php _e('Fixed') ?>
|
||||||
</label>
|
</label>
|
||||||
</fieldset></td>
|
</fieldset></td>
|
||||||
|
|
|
@ -1535,57 +1535,34 @@ function add_custom_background($header_callback = '', $admin_header_callback = '
|
||||||
function _custom_background_cb() {
|
function _custom_background_cb() {
|
||||||
$background = get_background_image();
|
$background = get_background_image();
|
||||||
$color = get_background_color();
|
$color = get_background_color();
|
||||||
if ( !$background && !$color )
|
if ( ! $background && ! $color )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch ( get_theme_mod('background_repeat', 'repeat') ) {
|
$style = $color ? "background-color: #$color;" : '';
|
||||||
case 'no-repeat':
|
|
||||||
$repeat = 'background-repeat: no-repeat;';
|
if ( $background ) {
|
||||||
break;
|
$image = " background-image: url('$background');";
|
||||||
case 'repeat-x':
|
|
||||||
$repeat = 'background-repeat: repeat-x;';
|
$repeat = get_theme_mod( 'background_repeat', 'repeat' );
|
||||||
break;
|
if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
|
||||||
case 'repeat-y':
|
$repeat = 'repeat';
|
||||||
$repeat = 'background-repeat: repeat-y;';
|
$repeat = " background-repeat: $repeat;";
|
||||||
break;
|
|
||||||
default:
|
$position = get_theme_mod( 'background_position_x', 'left' );
|
||||||
$repeat = 'background-repeat: repeat;';
|
if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
|
||||||
|
$position = 'left';
|
||||||
|
$position = " background-position: top $position;";
|
||||||
|
|
||||||
|
$attachment = get_theme_mod( 'background_attachment', 'scroll' );
|
||||||
|
if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )
|
||||||
|
$attachment = 'scroll';
|
||||||
|
$attachment = " background-attachment: $attachment;";
|
||||||
|
|
||||||
|
$style .= $image . $repeat . $position . $attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( get_theme_mod('background_position_x', 'left') ) {
|
|
||||||
case 'center':
|
|
||||||
$position = 'background-position: top center;';
|
|
||||||
break;
|
|
||||||
case 'right':
|
|
||||||
$position = 'background-position: top right;';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$position = 'background-position: top left;';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( 'scroll' == get_theme_mod('background_attachment', 'fixed') )
|
|
||||||
$attachment = 'background-attachment: scroll;';
|
|
||||||
else
|
|
||||||
$attachment = 'background-attachment: fixed;';
|
|
||||||
|
|
||||||
if ( !empty($background ) )
|
|
||||||
$image = "background-image: url('$background');";
|
|
||||||
else
|
|
||||||
$image = '';
|
|
||||||
|
|
||||||
if ( !empty($color) )
|
|
||||||
$color = "background-color: #$color;";
|
|
||||||
else
|
|
||||||
$color = '';
|
|
||||||
?>
|
?>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body {
|
body { <?php echo trim( $style ); ?> }
|
||||||
<?php echo $image; ?>
|
|
||||||
<?php echo $color; ?>
|
|
||||||
<?php echo $repeat; ?>
|
|
||||||
<?php echo $position; ?>
|
|
||||||
<?php echo $attachment; ?>
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue