Make WordPress Core

Ticket #22058: 22058.patch

File 22058.patch, 4.4 KB (added by SergeyBiryukov, 12 years ago)

A patch with grapplerulrich's changes

  • wp-admin/custom-background.php

     
    151151                if ( isset($_POST['background-position-x']) ) {
    152152                        check_admin_referer('custom-background');
    153153                        if ( in_array($_POST['background-position-x'], array('center', 'right', 'left')) )
    154                                 $position = $_POST['background-position-x'];
     154                                $hposition = $_POST['background-position-x'];
    155155                        else
    156                                 $position = 'left';
    157                         set_theme_mod('background_position_x', $position);
     156                                $hposition = 'left';
     157                        set_theme_mod('background_position_x', $hposition);
    158158                }
    159159
     160                if ( isset($_POST['background-position-y']) ) {
     161                        check_admin_referer('custom-background');
     162                        if ( in_array($_POST['background-position-y'], array('center', 'top', 'bottom')) )
     163                                $vposition = $_POST['background-position-y'];
     164                        else
     165                                $vposition = 'top';
     166                        set_theme_mod('background_position_y', $vposition);
     167                }
     168               
    160169                if ( isset($_POST['background-attachment']) ) {
    161170                        check_admin_referer('custom-background');
    162171                        if ( in_array($_POST['background-attachment'], array('fixed', 'scroll')) )
     
    213222        // background-image URL must be single quote, see below
    214223        $background_styles .= ' background-image: url(\'' . set_url_scheme( get_theme_mod( 'background_image_thumb', get_background_image() ) ) . '\');'
    215224                . ' background-repeat: ' . get_theme_mod('background_repeat', 'repeat') . ';'
    216                 . ' background-position: top ' . get_theme_mod('background_position_x', 'left');
     225                . ' background-position: ' . get_theme_mod('background_position_y', 'top') . get_theme_mod('background_position_x', 'left');
    217226}
    218227?>
    219228<div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?>
     
    283292<tbody>
    284293<?php if ( get_background_image() ) : ?>
    285294<tr valign="top">
    286 <th scope="row"><?php _e( 'Position' ); ?></th>
     295<th scope="row"><?php _e( 'Horizontal Position' ); ?></th>
    287296<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend>
    288297<label>
    289298<input name="background-position-x" type="radio" value="left"<?php checked('left', get_theme_mod('background_position_x', 'left')); ?> />
     
    301310</tr>
    302311
    303312<tr valign="top">
     313<th scope="row"><?php _e( 'Vertical Position' ); ?></th>
     314<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend>
     315<label>
     316<input name="background-position-y" type="radio" value="top"<?php checked('top', get_theme_mod('background_position_y', 'top')); ?> />
     317<?php _e('Top') ?>
     318</label>
     319<label>
     320<input name="background-position-y" type="radio" value="center"<?php checked('center', get_theme_mod('background_position_y', 'top')); ?> />
     321<?php _e('Center') ?>
     322</label>
     323<label>
     324<input name="background-position-y" type="radio" value="bottom"<?php checked('bottom', get_theme_mod('background_position_y', 'top')); ?> />
     325<?php _e('Bottom') ?>
     326</label>
     327</fieldset></td>
     328</tr>
     329
     330<tr valign="top">
    304331<th scope="row"><?php _e( 'Repeat' ); ?></th>
    305332<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Repeat' ); ?></span></legend>
    306333<label><input type="radio" name="background-repeat" value="no-repeat"<?php checked('no-repeat', get_theme_mod('background_repeat', 'repeat')); ?> /> <?php _e('No Repeat'); ?></label>
  • wp-includes/theme.php

     
    11391139                        $repeat = 'repeat';
    11401140                $repeat = " background-repeat: $repeat;";
    11411141
    1142                 $position = get_theme_mod( 'background_position_x', 'left' );
    1143                 if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
    1144                         $position = 'left';
    1145                 $position = " background-position: top $position;";
     1142                $hposition = get_theme_mod( 'background_position_x', 'left' );
     1143                if ( ! in_array( $hposition, array( 'center', 'right', 'left' ) ) )
     1144                        $hposition = 'left';
     1145                $vposition = get_theme_mod( 'background_position_y', 'top' );
     1146                if ( ! in_array( $vposition, array( 'center', 'top', 'bottom' ) ) )
     1147                        $vposition = 'top';
     1148                $position = " background-position: $vposition $hposition;";
    11461149
    11471150                $attachment = get_theme_mod( 'background_attachment', 'scroll' );
    11481151                if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )