mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Custom background UI updates. props ocean90 for initial patch, see #12186.
git-svn-id: https://develop.svn.wordpress.org/trunk@14684 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -91,6 +91,7 @@ class Custom_Background {
|
||||
remove_theme_mod('background_image_thumb');
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset($_POST['remove-background']) ) {
|
||||
// @TODO: Uploaded files are not removed here.
|
||||
check_admin_referer('custom-background-remove', '_wpnonce-custom-background-remove');
|
||||
@@ -107,14 +108,16 @@ class Custom_Background {
|
||||
$repeat = 'repeat';
|
||||
set_theme_mod('background_repeat', $repeat);
|
||||
}
|
||||
if ( isset($_POST['background-position']) ) {
|
||||
|
||||
if ( isset($_POST['background-position-x']) ) {
|
||||
check_admin_referer('custom-background');
|
||||
if ( in_array($_POST['background-position'], array('center', 'right', 'left')) )
|
||||
$position = $_POST['background-position'];
|
||||
if ( in_array($_POST['background-position-x'], array('center', 'right', 'left')) )
|
||||
$position = $_POST['background-position-x'];
|
||||
else
|
||||
$position = 'left';
|
||||
set_theme_mod('background_position', $position);
|
||||
set_theme_mod('background_position_x', $position);
|
||||
}
|
||||
|
||||
if ( isset($_POST['background-attachment']) ) {
|
||||
check_admin_referer('custom-background');
|
||||
if ( in_array($_POST['background-attachment'], array('fixed', 'scroll')) )
|
||||
@@ -123,6 +126,7 @@ class Custom_Background {
|
||||
$attachment = 'fixed';
|
||||
set_theme_mod('background_attachment', $attachment);
|
||||
}
|
||||
|
||||
if ( isset($_POST['background-color']) ) {
|
||||
check_admin_referer('custom-background');
|
||||
$color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['background-color']);
|
||||
@@ -155,33 +159,29 @@ class Custom_Background {
|
||||
call_user_func($this->admin_image_div_callback);
|
||||
} else {
|
||||
?>
|
||||
<h3><?php _e('Background Preview'); ?></h3>
|
||||
<h3><?php _e('Background Image'); ?></h3>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Current Background'); ?></th>
|
||||
<th scope="row"><?php _e('Preview'); ?></th>
|
||||
<td>
|
||||
<?php
|
||||
$background_styles = '';
|
||||
if ( $bgcolor = get_background_color() ) {
|
||||
$background_styles .= "background-color: #{$bgcolor};";
|
||||
}
|
||||
if ( $bgcolor = get_background_color() )
|
||||
$background_styles .= 'background-color: #' . $bgcolor . ';';
|
||||
|
||||
if ( get_background_image() ) {
|
||||
$background_styles .= "
|
||||
background-image: url(" . get_theme_mod('background_image_thumb', '') . ");
|
||||
background-repeat: ". get_theme_mod('background_repeat', 'repeat') . ";
|
||||
background-position: ". get_theme_mod('background_position', 'left') . " top;
|
||||
background-attachment: " . get_theme_mod('background_attachment', 'fixed') . ";
|
||||
";
|
||||
if ( get_background_image() ) {
|
||||
// background-image URL must be single quote, see below
|
||||
$background_styles .= ' background-image: url(\'' . get_theme_mod('background_image_thumb', '') . '\');'
|
||||
. ' background-repeat: ' . get_theme_mod('background_repeat', 'repeat') . ';'
|
||||
. ' background-position: top ' . get_theme_mod('background_position_x', 'left');
|
||||
}
|
||||
?>
|
||||
<div id="custom-background-image" style="<?php echo $background_styles; ?>">
|
||||
<div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?>
|
||||
<?php if ( get_background_image() ) { ?>
|
||||
<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" alt="" /><br />
|
||||
<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" alt="" />
|
||||
<?php } ?>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
@@ -189,10 +189,11 @@ if ( get_background_image() ) {
|
||||
<?php if ( get_background_image() ) : ?>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Remove Image'); ?></th>
|
||||
<td><p><?php _e('This will remove the background image. You will not be able to restore any customizations.') ?></p>
|
||||
<td>
|
||||
<form method="post" action="">
|
||||
<?php wp_nonce_field('custom-background-remove', '_wpnonce-custom-background-remove'); ?>
|
||||
<input type="submit" class="button" name="remove-background" value="<?php esc_attr_e('Remove Background'); ?>" />
|
||||
<input type="submit" class="button" name="remove-background" value="<?php esc_attr_e('Remove Background Image'); ?>" /><br/>
|
||||
<?php _e('This will remove the background image. You will not be able to restore any customizations.') ?>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -201,10 +202,11 @@ if ( get_background_image() ) {
|
||||
<?php if ( defined( 'BACKGROUND_IMAGE' ) ) : // Show only if a default background image exists ?>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Restore Original Image'); ?></th>
|
||||
<td><p><?php _e('This will restore the original background image. You will not be able to restore any customizations.') ?></p>
|
||||
<td>
|
||||
<form method="post" action="">
|
||||
<?php wp_nonce_field('custom-background-reset', '_wpnonce-custom-background-reset'); ?>
|
||||
<input type="submit" class="button" name="reset-background" value="<?php esc_attr_e('Restore Original Image'); ?>" />
|
||||
<input type="submit" class="button" name="reset-background" value="<?php esc_attr_e('Restore Original Image'); ?>" /><br/>
|
||||
<?php _e('This will restore the original background image. You will not be able to restore any customizations.') ?>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -216,8 +218,7 @@ if ( get_background_image() ) {
|
||||
<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-upload', '_wpnonce-custom-background-upload') ?>
|
||||
<p class="submit">
|
||||
<input type="submit" value="<?php esc_attr_e('Upload'); ?>" />
|
||||
<input type="submit" class="button" value="<?php esc_attr_e('Upload'); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
</td>
|
||||
@@ -230,28 +231,27 @@ if ( get_background_image() ) {
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e( 'Background Color' ); ?></th>
|
||||
<th scope="row"><?php _e( 'Color' ); ?></th>
|
||||
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend>
|
||||
<input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr(get_background_color()) ?>" />
|
||||
<input type="button" class="button" value="<?php esc_attr_e('Select a Color'); ?>" id="pickcolor" />
|
||||
|
||||
<div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
|
||||
</fieldset></td>
|
||||
</tr>
|
||||
|
||||
<?php if ( get_background_image() ) : ?>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e( 'Background Position' ); ?></th>
|
||||
<th scope="row"><?php _e( 'Position' ); ?></th>
|
||||
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend>
|
||||
<label>
|
||||
<input name="background-position" type="radio" value="left" <?php checked('left', get_theme_mod('background_position', 'left')); ?> />
|
||||
<input name="background-position-x" type="radio" value="left"<?php checked('left', get_theme_mod('background_position_x', 'left')); ?> />
|
||||
<?php _e('Left') ?>
|
||||
</label>
|
||||
<label>
|
||||
<input name="background-position" type="radio" value="center" <?php checked('center', get_theme_mod('background_position', 'left')); ?> />
|
||||
<input name="background-position-x" type="radio" value="center"<?php checked('center', get_theme_mod('background_position_x', 'left')); ?> />
|
||||
<?php _e('Center') ?>
|
||||
</label>
|
||||
<label>
|
||||
<input name="background-position" type="radio" value="right" <?php checked('right', get_theme_mod('background_position', 'left')); ?> />
|
||||
<input name="background-position-x" type="radio" value="right"<?php checked('right', get_theme_mod('background_position_x', 'left')); ?> />
|
||||
<?php _e('Right') ?>
|
||||
</label>
|
||||
</fieldset></td>
|
||||
@@ -262,10 +262,10 @@ if ( get_background_image() ) {
|
||||
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Repeat' ); ?></span></legend>
|
||||
<label>
|
||||
<select name="background-repeat">
|
||||
<option value="no-repeat" <?php selected('no-repeat', get_theme_mod('background_repeat', 'repeat')); ?> ><?php _e('No repeat'); ?></option>
|
||||
<option value="repeat" <?php selected('repeat', get_theme_mod('background_repeat', 'repeat')); ?>><?php _e('Tile'); ?></option>
|
||||
<option value="repeat-x" <?php selected('repeat-x', get_theme_mod('background_repeat', 'repeat')); ?>><?php _e('Tile Horizontally'); ?></option>
|
||||
<option value="repeat-y" <?php selected('repeat-y', get_theme_mod('background_repeat', 'repeat')); ?>><?php _e('Tile Vertically'); ?></option>
|
||||
<option value="no-repeat"<?php selected('no-repeat', get_theme_mod('background_repeat', 'repeat')); ?> ><?php _e('No repeat'); ?></option>
|
||||
<option value="repeat"<?php selected('repeat', get_theme_mod('background_repeat', 'repeat')); ?>><?php _e('Tile'); ?></option>
|
||||
<option value="repeat-x"<?php selected('repeat-x', get_theme_mod('background_repeat', 'repeat')); ?>><?php _e('Tile Horizontally'); ?></option>
|
||||
<option value="repeat-y"<?php selected('repeat-y', get_theme_mod('background_repeat', 'repeat')); ?>><?php _e('Tile Vertically'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</fieldset></td>
|
||||
@@ -284,7 +284,7 @@ if ( get_background_image() ) {
|
||||
</label>
|
||||
</fieldset></td>
|
||||
</tr>
|
||||
|
||||
<?php endif; // get_background_image() ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user