WordPress.org

Make WordPress Core

Ticket #12186: background.2.patch

File background.2.patch, 7.0 KB (added by ocean90, 11 years ago)

No UI change

  • wp-admin/custom-background.php

     
    107107                                $repeat = 'repeat';
    108108                        set_theme_mod('background_repeat', $repeat);
    109109                }
    110                 if ( isset($_POST['background-position']) ) {
     110                if ( isset($_POST['background-position-x']) ) {
    111111                        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'];
    114114                        else
    115115                                $position = 'left';
    116                         set_theme_mod('background_position', $position);
     116                        set_theme_mod('background_position_x', $position);
    117117                }
    118118                if ( isset($_POST['background-attachment']) ) {
    119119                        check_admin_referer('custom-background');
     
    155155                call_user_func($this->admin_image_div_callback);
    156156        } else {
    157157?>
    158 <h3><?php _e('Background Preview'); ?></h3>
     158<h3><?php _e('Background Image'); ?></h3>
    159159<table class="form-table">
    160160<tbody>
    161161<tr valign="top">
     
    171171        $background_styles .= "
    172172        background-image: url(" . get_theme_mod('background_image_thumb', '') . ");
    173173        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') . ";
     174        background-position: ". get_theme_mod('background_position_x', 'left') . " top;
    176175        ";
    177176}
    178177?>
     
    192191<td><p><?php _e('This will remove the background image. You will not be able to restore any customizations.') ?></p>
    193192<form method="post" action="">
    194193<?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'); ?>" />
     194<input type="submit" class="button" name="remove-background" value="<?php esc_attr_e('Remove Background Image'); ?>" />
    196195</form>
    197196</td>
    198197</tr>
     
    232231<tr valign="top">
    233232<th scope="row"><?php _e( 'Background Color' ); ?></th>
    234233<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend>
     234<p><label>
    235235<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" />
     236<input type="button" class="button hide-if-no-js" value="<?php esc_attr_e('Select a Color'); ?>" id="pickcolor" />
     237<span class="description"><?php _e( 'Leave it blank to use no background color.' ); ?></span>
     238</label></p>
    237239
    238240<div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
    239241</fieldset></td>
     
    243245<th scope="row"><?php _e( 'Background Position' ); ?></th>
    244246<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend>
    245247<label>
    246 <input name="background-position" type="radio" value="left" <?php checked('left', get_theme_mod('background_position', 'left')); ?> />
     248<input name="background-position-x" type="radio" value="left" <?php checked('left', get_theme_mod('background_position_x', 'left')); ?> />
    247249<?php _e('Left') ?>
    248250</label>
    249251<label>
    250 <input name="background-position" type="radio" value="center" <?php checked('center', get_theme_mod('background_position', 'left')); ?> />
     252<input name="background-position-x" type="radio" value="center" <?php checked('center', get_theme_mod('background_position_x', 'left')); ?> />
    251253<?php _e('Center') ?>
    252254</label>
    253255<label>
    254 <input name="background-position" type="radio" value="right" <?php checked('right', get_theme_mod('background_position', 'left')); ?> />
     256<input name="background-position-x" type="radio" value="right" <?php checked('right', get_theme_mod('background_position_x', 'left')); ?> />
    255257<?php _e('Right') ?>
    256258</label>
    257259</fieldset></td>
    258260</tr>
    259261
    260262<tr valign="top">
    261 <th scope="row"><?php _e( 'Repeat' ); ?></th>
     263<th scope="row"><?php _e( 'Background Repeat' ); ?></th>
    262264<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Repeat' ); ?></span></legend>
    263265<label>
    264266<select name="background-repeat">
     
    272274</tr>
    273275
    274276<tr valign="top">
    275 <th scope="row"><?php _e( 'Attachment' ); ?></th>
     277<th scope="row"><?php _e( 'Background Attachment' ); ?></th>
    276278<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Attachment' ); ?></span></legend>
    277279<label>
    278280<input name="background-attachment" type="radio" value="scroll" <?php checked('scroll', get_theme_mod('background_attachment', 'fixed')); ?> />
  • wp-admin/js/custom-background.dev.js

     
    2323                        pickColor( hex );
    2424        });
    2525
    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');
    2828        });
    2929
    3030        jQuery('select[name="background-repeat"]').change(function() {
    3131                jQuery('#custom-background-image').css('background-repeat', jQuery(this).val());
    3232        });
    33        
    34         jQuery('input[name="background-attachment"]').change(function() {
    35                 jQuery('#custom-background-image').css('background-attachment', jQuery(this).val());
    36         });
    3733
    3834        farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) {
    3935                pickColor(color);
  • wp-includes/script-loader.php

     
    529529                'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};'
    530530        ) );
    531531
    532         wp_localize_script( 'custom-background', 'customBackgroundL10n', array(
    533                 'backgroundcolor' => '#' . get_background_color(),
    534         ) );
    535532}
    536533
    537534/**
  • wp-includes/theme.php

     
    15531553                        $repeat = 'background-repeat: repeat;';
    15541554        }
    15551555
    1556         switch ( get_theme_mod('background_position', 'left') ) {
     1556        switch ( get_theme_mod('background_position_x', 'left') ) {
    15571557                case 'center':
    1558                         $position = 'background-position: top center;';
     1558                        $position = 'background-position: center top;';
    15591559                        break;
    15601560                case 'right':
    1561                         $position = 'background-position: top right;';
     1561                        $position = 'background-position: right top;';
    15621562                        break;
    15631563                default:
    1564                         $position = 'background-position: top left;';
     1564                        $position = 'background-position: left top;';
    15651565        }
    15661566
    15671567        if ( 'scroll' == get_theme_mod('background_attachment', 'fixed') )