Ticket #22058: 22058.3.patch
File 22058.3.patch, 7.2 KB (added by , 12 years ago) |
---|
-
wp-admin/custom-background.php
151 151 if ( isset($_POST['background-position-x']) ) { 152 152 check_admin_referer('custom-background'); 153 153 if ( in_array($_POST['background-position-x'], array('center', 'right', 'left')) ) 154 $ position = $_POST['background-position-x'];154 $hposition = $_POST['background-position-x']; 155 155 else 156 $ position = 'left';157 set_theme_mod('background_position_x', $ position);156 $hposition = 'left'; 157 set_theme_mod('background_position_x', $hposition); 158 158 } 159 159 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 160 169 if ( isset($_POST['background-attachment']) ) { 161 170 check_admin_referer('custom-background'); 162 171 if ( in_array($_POST['background-attachment'], array('fixed', 'scroll')) ) … … 213 222 // background-image URL must be single quote, see below 214 223 $background_styles .= ' background-image: url(\'' . set_url_scheme( get_theme_mod( 'background_image_thumb', get_background_image() ) ) . '\');' 215 224 . ' 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'); 217 226 } 218 227 ?> 219 228 <div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?> … … 283 292 <tbody> 284 293 <?php if ( get_background_image() ) : ?> 285 294 <tr valign="top"> 286 <th scope="row"><?php _e( ' Position' ); ?></th>295 <th scope="row"><?php _e( 'Horizontal Position' ); ?></th> 287 296 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend> 288 297 <label> 289 298 <input name="background-position-x" type="radio" value="left"<?php checked('left', get_theme_mod('background_position_x', 'left')); ?> /> … … 301 310 </tr> 302 311 303 312 <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"> 304 331 <th scope="row"><?php _e( 'Repeat' ); ?></th> 305 332 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Repeat' ); ?></span></legend> 306 333 <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
847 847 ) ); 848 848 849 849 $this->add_control( 'background_position_x', array( 850 'label' => __( ' Background Position' ),850 'label' => __( 'Horizontal Background Position' ), 851 851 'section' => 'background_image', 852 852 'type' => 'radio', 853 853 'choices' => array( … … 856 856 'right' => __('Right'), 857 857 ), 858 858 ) ); 859 860 $this->add_setting( 'background_position_y', array( 861 'default' => 'top', 862 'theme_supports' => 'custom-background', 863 ) ); 859 864 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 860 876 $this->add_setting( 'background_attachment', array( 861 877 'default' => 'fixed', 862 878 'theme_supports' => 'custom-background', … … 875 891 // If the theme is using the default background callback, we can update 876 892 // the background CSS using postMessage. 877 893 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 ) { 879 895 $this->get_setting( 'background_' . $prop )->transport = 'postMessage'; 880 896 } 881 897 } -
wp-includes/js/customize-preview.js
98 98 preview.send( 'ready' ); 99 99 100 100 /* 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 ) { 102 102 return 'background_' + prop; 103 103 }); 104 104 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 ) { 106 106 var body = $(document.body), 107 107 head = $('head'), 108 108 style = $('#custom-background-css'), … … 127 127 128 128 if ( image() ) { 129 129 css += 'background-image: url("' + image() + '");'; 130 css += 'background-position: top' + position_x() + ';';130 css += 'background-position: ' + position_y() + ' ' + position_x() + ';'; 131 131 css += 'background-repeat: ' + repeat() + ';'; 132 132 css += 'background-attachment: ' + attachment() + ';'; 133 133 } -
wp-includes/theme.php
1139 1139 $repeat = 'repeat'; 1140 1140 $repeat = " background-repeat: $repeat;"; 1141 1141 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;"; 1146 1149 1147 1150 $attachment = get_theme_mod( 'background_attachment', 'scroll' ); 1148 1151 if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )