Make WordPress Core

Ticket #22058: 22058.3.patch

File 22058.3.patch, 7.2 KB (added by grapplerulrich, 12 years ago)

22058.2.patch​

  • 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/class-wp-customize-manager.php

     
    847847                ) );
    848848
    849849                $this->add_control( 'background_position_x', array(
    850                         'label'      => __( 'Background Position' ),
     850                        'label'      => __( 'Horizontal Background Position' ),
    851851                        'section'    => 'background_image',
    852852                        'type'       => 'radio',
    853853                        'choices'    => array(
     
    856856                                'right'      => __('Right'),
    857857                        ),
    858858                ) );
     859               
     860                $this->add_setting( 'background_position_y', array(
     861                        'default'        => 'top',
     862                        'theme_supports' => 'custom-background',
     863                ) );
    859864
     865                $this->add_control( 'background_position_y', array(
     866                        'label'      => __( 'Vertical Background Position' ),
     867                        'section'    => 'background_image',
     868                        'type'       => 'radio',
     869                        'choices'    => array(
     870                                'top'       => __('Top'),
     871                                'center'     => __('Center'),
     872                                'bottom'      => __('Bottom'),
     873                        ),
     874                ) );
     875
    860876                $this->add_setting( 'background_attachment', array(
    861877                        'default'        => 'fixed',
    862878                        'theme_supports' => 'custom-background',
     
    875891                // If the theme is using the default background callback, we can update
    876892                // the background CSS using postMessage.
    877893                if ( get_theme_support( 'custom-background', 'wp-head-callback' ) === '_custom_background_cb' ) {
    878                         foreach ( array( 'color', 'image', 'position_x', 'repeat', 'attachment' ) as $prop ) {
     894                        foreach ( array( 'color', 'image', 'position_y' ,'position_x', 'repeat', 'attachment' ) as $prop ) {
    879895                                $this->get_setting( 'background_' . $prop )->transport = 'postMessage';
    880896                        }
    881897                }
  • wp-includes/js/customize-preview.js

     
    9898                preview.send( 'ready' );
    9999
    100100                /* Custom Backgrounds */
    101                 bg = $.map(['color', 'image', 'position_x', 'repeat', 'attachment'], function( prop ) {
     101                bg = $.map(['color', 'image', 'position_y', 'position_x', 'repeat', 'attachment'], function( prop ) {
    102102                        return 'background_' + prop;
    103103                });
    104104
    105                 api.when.apply( api, bg ).done( function( color, image, position_x, repeat, attachment ) {
     105                api.when.apply( api, bg ).done( function( color, image, position_y, position_x, repeat, attachment ) {
    106106                        var body = $(document.body),
    107107                                head = $('head'),
    108108                                style = $('#custom-background-css'),
     
    127127
    128128                                if ( image() ) {
    129129                                        css += 'background-image: url("' + image() + '");';
    130                                         css += 'background-position: top ' + position_x() + ';';
     130                                        css += 'background-position: ' + position_y() + ' ' + position_x() + ';';
    131131                                        css += 'background-repeat: ' + repeat() + ';';
    132132                                        css += 'background-attachment: ' + attachment() + ';';
    133133                                }
  • 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' ) ) )