Ticket #22058: 22058.diff
File 22058.diff, 10.6 KB (added by , 12 years ago) |
---|
-
wp-includes/class-wp-customize-manager.php
847 847 ) ); 848 848 849 849 $this->add_control( 'background_position_x', array( 850 'label' => __( 'Background Position' ),851 'section' 852 'type' 853 'choices' 854 'left' => __('Left'),855 'center' => __('Center'),856 'right' => __('Right'),850 'label' => __( 'Horizontal Background Position' ), 851 'section' => 'background_image', 852 'type' => 'radio', 853 'choices' => array( 854 'left' => __( 'Left' ), 855 'center' => __( 'Center' ), 856 'right' => __( 'Right' ), 857 857 ), 858 858 ) ); 859 859 860 $this->add_setting( 'background_position_y', array( 861 'default' => 'top', 862 'theme_supports' => 'custom-background', 863 ) ); 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( 'attachment', 'color', 'image', 'position_x', 'position_y', 'repeat' ) 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( [ 'attachment', 'color', 'image', 'position_x', 'position_y', 'repeat' ], 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( attachment, color, image, position_x, position_y, repeat ) { 106 106 var body = $(document.body), 107 107 head = $('head'), 108 108 style = $('#custom-background-css'), … … 126 126 css += 'background-color: ' + color() + ';'; 127 127 128 128 if ( image() ) { 129 css += 'background-attachment: ' + attachment() + ';'; 129 130 css += 'background-image: url("' + image() + '");'; 130 css += 'background-position: top ' + position_x() + ';';131 css += 'background-position: ' + position_x() + ' ' + position_y() + ';'; 131 132 css += 'background-repeat: ' + repeat() + ';'; 132 css += 'background-attachment: ' + attachment() + ';';133 133 } 134 134 135 135 // Refresh the stylesheet by removing and recreating it. -
wp-includes/theme.php
1167 1167 $repeat = 'repeat'; 1168 1168 $repeat = " background-repeat: $repeat;"; 1169 1169 1170 $position = get_theme_mod( 'background_position_x', 'left' ); 1171 if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) ) 1172 $position = 'left'; 1173 $position = " background-position: top $position;"; 1170 $position_x = get_theme_mod( 'background_position_x', 'left' ); 1174 1171 1172 if ( ! in_array( $position_x, array( 'center', 'left', 'right' ) ) ) 1173 $position_x = 'left'; 1174 1175 $position_y = get_theme_mod( 'background_position_y', 'top' ); 1176 1177 if ( ! in_array( $position_y, array( 'bottom', 'center', 'top' ) ) ) 1178 $position_y = 'top'; 1179 1180 $position = ' background-position: ' . $position_x . ' ' . $position_y . ';'; 1181 1175 1182 $attachment = get_theme_mod( 'background_attachment', 'scroll' ); 1176 1183 if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) ) 1177 1184 $attachment = 'scroll'; … … 1732 1739 }()); 1733 1740 </script> 1734 1741 <?php 1735 } 1736 No newline at end of file 1742 } -
wp-admin/js/custom-background.js
12 12 } 13 13 }); 14 14 15 $('input[name="background-position-x"]').change(function() { 16 bgImage.css('background-position', $(this).val() + ' top'); 17 }); 15 $( 'input[name="background-position-x"]' ).change( function() { 16 bgPosition = bgImage.css( 'background-position' ).split( ' ' ); 18 17 18 bgImage.css( 'background-position', $( this ).val() + ' ' + bgPosition[1] ); 19 } ); 20 21 $( 'input[name="background-position-y"]' ).change( function() { 22 bgPosition = bgImage.css( 'background-position' ).split( ' ' ); 23 24 bgImage.css( 'background-position', bgPosition[0] + ' ' + $( this ).val() ); 25 } ); 26 19 27 $('input[name="background-repeat"]').change(function() { 20 28 bgImage.css('background-repeat', $(this).val()); 21 29 }); … … 71 79 frame.open(); 72 80 }); 73 81 }); 74 })(jQuery); 75 No newline at end of file 82 })(jQuery); -
wp-admin/js/customize-controls.js
914 914 // Control visibility for default controls 915 915 $.each({ 916 916 'background_image': { 917 controls: [ 'background_repeat', 'background_position_x', 'background_ attachment' ],917 controls: [ 'background_repeat', 'background_position_x', 'background_position_y', 'background_attachment' ], 918 918 callback: function( to ) { return !! to } 919 919 }, 920 920 'show_on_front': { -
wp-admin/custom-background.php
141 141 set_theme_mod('background_repeat', $repeat); 142 142 } 143 143 144 if ( isset($_POST['background-position-x']) ) { 145 check_admin_referer('custom-background'); 146 if ( in_array($_POST['background-position-x'], array('center', 'right', 'left')) ) 147 $position = $_POST['background-position-x']; 144 if ( isset( $_POST[ 'background-position-x' ] ) ) { 145 check_admin_referer( 'custom-background' ); 146 147 if ( in_array( $_POST[ 'background-position-x' ], array( 'center', 'left', 'right') ) ) 148 $position_x = $_POST[ 'background-position-x' ]; 148 149 else 149 $position = 'left'; 150 set_theme_mod('background_position_x', $position); 150 $position_x = 'left'; 151 152 set_theme_mod( 'background_position_x', $position_x ); 151 153 } 152 154 155 if ( isset( $_POST[ 'background-position-y' ] ) ) { 156 check_admin_referer( 'custom-background' ); 157 158 if ( in_array( $_POST[ 'background-position-y' ], array( 'bottom', 'center', 'top' ) ) ) 159 $position_y = $_POST[ 'background-position-y' ]; 160 else 161 $position_y = 'top'; 162 163 set_theme_mod( 'background_position_y', $position_y ); 164 } 165 153 166 if ( isset($_POST['background-attachment']) ) { 154 167 check_admin_referer('custom-background'); 155 168 if ( in_array($_POST['background-attachment'], array('fixed', 'scroll')) ) … … 206 219 // background-image URL must be single quote, see below 207 220 $background_styles .= ' background-image: url(\'' . set_url_scheme( get_theme_mod( 'background_image_thumb', get_background_image() ) ) . '\');' 208 221 . ' background-repeat: ' . get_theme_mod('background_repeat', 'repeat') . ';' 209 . ' background-position: top ' . get_theme_mod('background_position_x', 'left');222 . ' background-position: ' . get_theme_mod( 'background_position_x', 'left' ) . ' ' . get_theme_mod( 'background_position_y', 'top' ); 210 223 } 211 224 ?> 212 225 <div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?> … … 273 286 <tbody> 274 287 <?php if ( get_background_image() ) : ?> 275 288 <tr valign="top"> 276 <th scope="row"><?php _e( ' Position' ); ?></th>289 <th scope="row"><?php _e( 'Horizontal Position' ); ?></th> 277 290 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend> 278 291 <label> 279 <input name="background-position-x" type="radio" value="left"<?php checked( 'left', get_theme_mod('background_position_x', 'left')); ?> />280 <?php _e( 'Left')?>292 <input name="background-position-x" type="radio" value="left"<?php checked( 'left', get_theme_mod( 'background_position_x', 'left' ) ); ?> /> 293 <?php _e( 'Left' ); ?> 281 294 </label> 282 295 <label> 283 <input name="background-position-x" type="radio" value="center"<?php checked( 'center', get_theme_mod('background_position_x', 'left')); ?> />284 <?php _e( 'Center')?>296 <input name="background-position-x" type="radio" value="center"<?php checked( 'center', get_theme_mod( 'background_position_x', 'left' ) ); ?> /> 297 <?php _e( 'Center' ); ?> 285 298 </label> 286 299 <label> 287 <input name="background-position-x" type="radio" value="right"<?php checked( 'right', get_theme_mod('background_position_x', 'left')); ?> />288 <?php _e( 'Right')?>300 <input name="background-position-x" type="radio" value="right"<?php checked( 'right', get_theme_mod( 'background_position_x', 'left' ) ); ?> /> 301 <?php _e( 'Right' ); ?> 289 302 </label> 290 303 </fieldset></td> 291 304 </tr> 292 305 293 306 <tr valign="top"> 307 <th scope="row"><?php _e( 'Vertical Position' ); ?></th> 308 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend> 309 <label> 310 <input name="background-position-y" type="radio" value="top"<?php checked( 'top', get_theme_mod( 'background_position_y', 'top' ) ); ?> /> 311 <?php _e( 'Top' ); ?> 312 </label> 313 <label> 314 <input name="background-position-y" type="radio" value="center"<?php checked( 'center', get_theme_mod( 'background_position_y', 'top' ) ); ?> /> 315 <?php _e( 'Center' ); ?> 316 </label> 317 <label> 318 <input name="background-position-y" type="radio" value="bottom"<?php checked( 'bottom', get_theme_mod( 'background_position_y', 'top' ) ); ?> /> 319 <?php _e( 'Bottom' ); ?> 320 </label> 321 </fieldset></td> 322 </tr> 323 324 <tr valign="top"> 294 325 <th scope="row"><?php _e( 'Repeat' ); ?></th> 295 326 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Repeat' ); ?></span></legend> 296 327 <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>