wp/wp-admin/custom-background.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     8 
     8 
     9 /**
     9 /**
    10  * The custom background class.
    10  * The custom background class.
    11  *
    11  *
    12  * @since 3.0.0
    12  * @since 3.0.0
    13  * @package WordPress
       
    14  * @subpackage Administration
       
    15  */
    13  */
    16 class Custom_Background {
    14 class Custom_Background {
    17 
    15 
    18 	/**
    16 	/**
    19 	 * Callback for administration header.
    17 	 * Callback for administration header.
    20 	 *
    18 	 *
    21 	 * @var callback
    19 	 * @var callable
    22 	 * @since 3.0.0
    20 	 * @since 3.0.0
    23 	 */
    21 	 */
    24 	public $admin_header_callback;
    22 	public $admin_header_callback;
    25 
    23 
    26 	/**
    24 	/**
    27 	 * Callback for header div.
    25 	 * Callback for header div.
    28 	 *
    26 	 *
    29 	 * @var callback
    27 	 * @var callable
    30 	 * @since 3.0.0
    28 	 * @since 3.0.0
    31 	 */
    29 	 */
    32 	public $admin_image_div_callback;
    30 	public $admin_image_div_callback;
    33 
    31 
    34 	/**
    32 	/**
       
    33 	 * Used to trigger a success message when settings updated and set to true.
       
    34 	 *
       
    35 	 * @since 3.0.0
    35 	 * @var bool
    36 	 * @var bool
    36 	 */
    37 	 */
    37 	private $updated;
    38 	private $updated;
    38 
    39 
    39 	/**
    40 	/**
    40 	 * Constructor - Register administration header callback.
    41 	 * Constructor - Register administration header callback.
    41 	 *
    42 	 *
    42 	 * @since 3.0.0
    43 	 * @since 3.0.0
    43 	 * @param callback $admin_header_callback
    44 	 * @param callable $admin_header_callback
    44 	 * @param callback $admin_image_div_callback Optional custom image div output callback.
    45 	 * @param callable $admin_image_div_callback Optional custom image div output callback.
    45 	 */
    46 	 */
    46 	public function __construct($admin_header_callback = '', $admin_image_div_callback = '') {
    47 	public function __construct($admin_header_callback = '', $admin_image_div_callback = '') {
    47 		$this->admin_header_callback = $admin_header_callback;
    48 		$this->admin_header_callback = $admin_header_callback;
    48 		$this->admin_image_div_callback = $admin_image_div_callback;
    49 		$this->admin_image_div_callback = $admin_image_div_callback;
    49 
    50 
    91 				'<p>' . __( 'Don&#8217;t forget to click on the Save Changes button when you are finished.' ) . '</p>'
    92 				'<p>' . __( 'Don&#8217;t forget to click on the Save Changes button when you are finished.' ) . '</p>'
    92 		) );
    93 		) );
    93 
    94 
    94 		get_current_screen()->set_help_sidebar(
    95 		get_current_screen()->set_help_sidebar(
    95 			'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    96 			'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    96 			'<p>' . __( '<a href="https://codex.wordpress.org/Appearance_Background_Screen" target="_blank">Documentation on Custom Background</a>' ) . '</p>' .
    97 			'<p>' . __( '<a href="https://codex.wordpress.org/Appearance_Background_Screen">Documentation on Custom Background</a>' ) . '</p>' .
    97 			'<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
    98 			'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    98 		);
    99 		);
    99 
   100 
   100 		wp_enqueue_media();
   101 		wp_enqueue_media();
   101 		wp_enqueue_script('custom-background');
   102 		wp_enqueue_script('custom-background');
   102 		wp_enqueue_style('wp-color-picker');
   103 		wp_enqueue_style('wp-color-picker');
   106 	 * Execute custom background modification.
   107 	 * Execute custom background modification.
   107 	 *
   108 	 *
   108 	 * @since 3.0.0
   109 	 * @since 3.0.0
   109 	 */
   110 	 */
   110 	public function take_action() {
   111 	public function take_action() {
   111 
       
   112 		if ( empty($_POST) )
   112 		if ( empty($_POST) )
   113 			return;
   113 			return;
   114 
   114 
   115 		if ( isset($_POST['reset-background']) ) {
   115 		if ( isset($_POST['reset-background']) ) {
   116 			check_admin_referer('custom-background-reset', '_wpnonce-custom-background-reset');
   116 			check_admin_referer('custom-background-reset', '_wpnonce-custom-background-reset');
   128 			$this->updated = true;
   128 			$this->updated = true;
   129 			wp_safe_redirect( $_POST['_wp_http_referer'] );
   129 			wp_safe_redirect( $_POST['_wp_http_referer'] );
   130 			return;
   130 			return;
   131 		}
   131 		}
   132 
   132 
   133 		if ( isset($_POST['background-repeat']) ) {
   133 		if ( isset( $_POST['background-preset'] ) ) {
   134 			check_admin_referer('custom-background');
   134 			check_admin_referer( 'custom-background' );
   135 			if ( in_array($_POST['background-repeat'], array('repeat', 'no-repeat', 'repeat-x', 'repeat-y')) )
   135 
   136 				$repeat = $_POST['background-repeat'];
   136 			if ( in_array( $_POST['background-preset'], array( 'default', 'fill', 'fit', 'repeat', 'custom' ), true ) ) {
   137 			else
   137 				$preset = $_POST['background-preset'];
       
   138 			} else {
       
   139 				$preset = 'default';
       
   140 			}
       
   141 
       
   142 			set_theme_mod( 'background_preset', $preset );
       
   143 		}
       
   144 
       
   145 		if ( isset( $_POST['background-position'] ) ) {
       
   146 			check_admin_referer( 'custom-background' );
       
   147 
       
   148 			$position = explode( ' ', $_POST['background-position'] );
       
   149 
       
   150 			if ( in_array( $position[0], array( 'left', 'center', 'right' ), true ) ) {
       
   151 				$position_x = $position[0];
       
   152 			} else {
       
   153 				$position_x = 'left';
       
   154 			}
       
   155 
       
   156 			if ( in_array( $position[1], array( 'top', 'center', 'bottom' ), true ) ) {
       
   157 				$position_y = $position[1];
       
   158 			} else {
       
   159 				$position_y = 'top';
       
   160 			}
       
   161 
       
   162 			set_theme_mod( 'background_position_x', $position_x );
       
   163 			set_theme_mod( 'background_position_y', $position_y );
       
   164 		}
       
   165 
       
   166 		if ( isset( $_POST['background-size'] ) ) {
       
   167 			check_admin_referer( 'custom-background' );
       
   168 
       
   169 			if ( in_array( $_POST['background-size'], array( 'auto', 'contain', 'cover' ), true ) ) {
       
   170 				$size = $_POST['background-size'];
       
   171 			} else {
       
   172 				$size = 'auto';
       
   173 			}
       
   174 
       
   175 			set_theme_mod( 'background_size', $size );
       
   176 		}
       
   177 
       
   178 		if ( isset( $_POST['background-repeat'] ) ) {
       
   179 			check_admin_referer( 'custom-background' );
       
   180 
       
   181 			$repeat = $_POST['background-repeat'];
       
   182 
       
   183 			if ( 'no-repeat' !== $repeat ) {
   138 				$repeat = 'repeat';
   184 				$repeat = 'repeat';
   139 			set_theme_mod('background_repeat', $repeat);
   185 			}
   140 		}
   186 
   141 
   187 			set_theme_mod( 'background_repeat', $repeat );
   142 		if ( isset($_POST['background-position-x']) ) {
   188 		}
   143 			check_admin_referer('custom-background');
   189 
   144 			if ( in_array($_POST['background-position-x'], array('center', 'right', 'left')) )
   190 		if ( isset( $_POST['background-attachment'] ) ) {
   145 				$position = $_POST['background-position-x'];
   191 			check_admin_referer( 'custom-background' );
   146 			else
   192 
   147 				$position = 'left';
   193 			$attachment = $_POST['background-attachment'];
   148 			set_theme_mod('background_position_x', $position);
   194 
   149 		}
   195 			if ( 'fixed' !== $attachment ) {
   150 
   196 				$attachment = 'scroll';
   151 		if ( isset($_POST['background-attachment']) ) {
   197 			}
   152 			check_admin_referer('custom-background');
   198 
   153 			if ( in_array($_POST['background-attachment'], array('fixed', 'scroll')) )
   199 			set_theme_mod( 'background_attachment', $attachment );
   154 				$attachment = $_POST['background-attachment'];
       
   155 			else
       
   156 				$attachment = 'fixed';
       
   157 			set_theme_mod('background_attachment', $attachment);
       
   158 		}
   200 		}
   159 
   201 
   160 		if ( isset($_POST['background-color']) ) {
   202 		if ( isset($_POST['background-color']) ) {
   161 			check_admin_referer('custom-background');
   203 			check_admin_referer('custom-background');
   162 			$color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['background-color']);
   204 			$color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['background-color']);
   175 	 * @since 3.0.0
   217 	 * @since 3.0.0
   176 	 */
   218 	 */
   177 	public function admin_page() {
   219 	public function admin_page() {
   178 ?>
   220 ?>
   179 <div class="wrap" id="custom-background">
   221 <div class="wrap" id="custom-background">
   180 <h2><?php _e( 'Custom Background' ); ?></h2>
   222 <h1><?php _e( 'Custom Background' ); ?></h1>
   181 
   223 
   182 <?php if ( current_user_can( 'customize' ) ) { ?>
   224 <?php if ( current_user_can( 'customize' ) ) { ?>
   183 <div class="notice notice-info hide-if-no-customize">
   225 <div class="notice notice-info hide-if-no-customize">
   184 	<p>
   226 	<p>
   185 		<?php
   227 		<?php
   214 			$background_styles .= 'background-color: #' . $bgcolor . ';';
   256 			$background_styles .= 'background-color: #' . $bgcolor . ';';
   215 
   257 
   216 		$background_image_thumb = get_background_image();
   258 		$background_image_thumb = get_background_image();
   217 		if ( $background_image_thumb ) {
   259 		if ( $background_image_thumb ) {
   218 			$background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) );
   260 			$background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) );
       
   261 			$background_position_x = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
       
   262 			$background_position_y = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) );
       
   263 			$background_size = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) );
       
   264 			$background_repeat = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
       
   265 			$background_attachment = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );
   219 
   266 
   220 			// Background-image URL must be single quote, see below.
   267 			// Background-image URL must be single quote, see below.
   221 			$background_styles .= ' background-image: url(\'' . $background_image_thumb . '\');'
   268 			$background_styles .= " background-image: url('$background_image_thumb');"
   222 				. ' background-repeat: ' . get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) . ';'
   269 				. " background-size: $background_size;"
   223 				. ' background-position: top ' . get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
   270 				. " background-position: $background_position_x $background_position_y;"
       
   271 				. " background-repeat: $background_repeat;"
       
   272 				. " background-attachment: $background_attachment;";
   224 		}
   273 		}
   225 	?>
   274 	?>
   226 	<div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?>
   275 	<div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?>
   227 		<?php if ( $background_image_thumb ) { ?>
   276 		<?php if ( $background_image_thumb ) { ?>
   228 		<img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" /><br />
   277 		<img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" /><br />
   237 <tr>
   286 <tr>
   238 <th scope="row"><?php _e('Remove Image'); ?></th>
   287 <th scope="row"><?php _e('Remove Image'); ?></th>
   239 <td>
   288 <td>
   240 <form method="post">
   289 <form method="post">
   241 <?php wp_nonce_field('custom-background-remove', '_wpnonce-custom-background-remove'); ?>
   290 <?php wp_nonce_field('custom-background-remove', '_wpnonce-custom-background-remove'); ?>
   242 <?php submit_button( __( 'Remove Background Image' ), 'button', 'remove-background', false ); ?><br/>
   291 <?php submit_button( __( 'Remove Background Image' ), '', 'remove-background', false ); ?><br/>
   243 <?php _e('This will remove the background image. You will not be able to restore any customizations.') ?>
   292 <?php _e('This will remove the background image. You will not be able to restore any customizations.') ?>
   244 </form>
   293 </form>
   245 </td>
   294 </td>
   246 </tr>
   295 </tr>
   247 <?php endif; ?>
   296 <?php endif; ?>
   251 <tr>
   300 <tr>
   252 <th scope="row"><?php _e('Restore Original Image'); ?></th>
   301 <th scope="row"><?php _e('Restore Original Image'); ?></th>
   253 <td>
   302 <td>
   254 <form method="post">
   303 <form method="post">
   255 <?php wp_nonce_field('custom-background-reset', '_wpnonce-custom-background-reset'); ?>
   304 <?php wp_nonce_field('custom-background-reset', '_wpnonce-custom-background-reset'); ?>
   256 <?php submit_button( __( 'Restore Original Image' ), 'button', 'reset-background', false ); ?><br/>
   305 <?php submit_button( __( 'Restore Original Image' ), '', 'reset-background', false ); ?><br/>
   257 <?php _e('This will restore the original background image. You will not be able to restore any customizations.') ?>
   306 <?php _e('This will restore the original background image. You will not be able to restore any customizations.') ?>
   258 </form>
   307 </form>
   259 </td>
   308 </td>
   260 </tr>
   309 </tr>
   261 <?php endif; ?>
   310 <?php endif; ?>
   262 
   311 
       
   312 <?php if ( current_user_can( 'upload_files' ) ): ?>
   263 <tr>
   313 <tr>
   264 <th scope="row"><?php _e('Select Image'); ?></th>
   314 <th scope="row"><?php _e('Select Image'); ?></th>
   265 <td><form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post">
   315 <td><form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post">
   266 	<p>
   316 	<p>
   267 		<label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
   317 		<label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
   268 		<input type="file" id="upload" name="import" />
   318 		<input type="file" id="upload" name="import" />
   269 		<input type="hidden" name="action" value="save" />
   319 		<input type="hidden" name="action" value="save" />
   270 		<?php wp_nonce_field( 'custom-background-upload', '_wpnonce-custom-background-upload' ); ?>
   320 		<?php wp_nonce_field( 'custom-background-upload', '_wpnonce-custom-background-upload' ); ?>
   271 		<?php submit_button( __( 'Upload' ), 'button', 'submit', false ); ?>
   321 		<?php submit_button( __( 'Upload' ), '', 'submit', false ); ?>
   272 	</p>
   322 	</p>
   273 	<p>
   323 	<p>
   274 		<label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br />
   324 		<label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br />
   275 		<button id="choose-from-library-link" class="button"
   325 		<button id="choose-from-library-link" class="button"
   276 			data-choose="<?php esc_attr_e( 'Choose a Background Image' ); ?>"
   326 			data-choose="<?php esc_attr_e( 'Choose a Background Image' ); ?>"
   277 			data-update="<?php esc_attr_e( 'Set as background' ); ?>"><?php _e( 'Choose Image' ); ?></button>
   327 			data-update="<?php esc_attr_e( 'Set as background' ); ?>"><?php _e( 'Choose Image' ); ?></button>
   278 	</p>
   328 	</p>
   279 	</form>
   329 	</form>
   280 </td>
   330 </td>
   281 </tr>
   331 </tr>
       
   332 <?php endif; ?>
   282 </tbody>
   333 </tbody>
   283 </table>
   334 </table>
   284 
   335 
   285 <h3><?php _e('Display Options') ?></h3>
   336 <h3><?php _e( 'Display Options' ); ?></h3>
   286 <form method="post">
   337 <form method="post">
   287 <table class="form-table">
   338 <table class="form-table">
   288 <tbody>
   339 <tbody>
   289 <?php if ( get_background_image() ) : ?>
   340 <?php if ( get_background_image() ) : ?>
   290 <tr>
   341 <input name="background-preset" type="hidden" value="custom">
   291 <th scope="row"><?php _e( 'Position' ); ?></th>
   342 
   292 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend>
   343 <?php
   293 <label>
   344 $background_position = sprintf(
   294 <input name="background-position-x" type="radio" value="left"<?php checked( 'left', get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ) ); ?> />
   345 	'%s %s',
   295 <?php _e('Left') ?>
   346 	get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ),
   296 </label>
   347 	get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) )
   297 <label>
   348 );
   298 <input name="background-position-x" type="radio" value="center"<?php checked( 'center', get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ) ); ?> />
   349 
   299 <?php _e('Center') ?>
   350 $background_position_options = array(
   300 </label>
   351 	array(
   301 <label>
   352 		'left top'   => array( 'label' => __( 'Top Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),
   302 <input name="background-position-x" type="radio" value="right"<?php checked( 'right', get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ) ); ?> />
   353 		'center top' => array( 'label' => __( 'Top' ), 'icon' => 'dashicons dashicons-arrow-up-alt' ),
   303 <?php _e('Right') ?>
   354 		'right top'  => array( 'label' => __( 'Top Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),
   304 </label>
   355 	),
       
   356 	array(
       
   357 		'left center'   => array( 'label' => __( 'Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),
       
   358 		'center center' => array( 'label' => __( 'Center' ), 'icon' => 'background-position-center-icon' ),
       
   359 		'right center'  => array( 'label' => __( 'Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),
       
   360 	),
       
   361 	array(
       
   362 		'left bottom'   => array( 'label' => __( 'Bottom Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),
       
   363 		'center bottom' => array( 'label' => __( 'Bottom' ), 'icon' => 'dashicons dashicons-arrow-down-alt' ),
       
   364 		'right bottom'  => array( 'label' => __( 'Bottom Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),
       
   365 	),
       
   366 );
       
   367 ?>
       
   368 <tr>
       
   369 <th scope="row"><?php _e( 'Image Position' ); ?></th>
       
   370 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Image Position' ); ?></span></legend>
       
   371 <div class="background-position-control">
       
   372 <?php foreach ( $background_position_options as $group ) : ?>
       
   373 	<div class="button-group">
       
   374 	<?php foreach ( $group as $value => $input ) : ?>
       
   375 		<label>
       
   376 			<input class="screen-reader-text" name="background-position" type="radio" value="<?php echo esc_attr( $value ); ?>"<?php checked( $value, $background_position ); ?>>
       
   377 			<span class="button display-options position"><span class="<?php echo esc_attr( $input['icon'] ); ?>" aria-hidden="true"></span></span>
       
   378 			<span class="screen-reader-text"><?php echo $input['label']; ?></span>
       
   379 		</label>
       
   380 	<?php endforeach; ?>
       
   381 	</div>
       
   382 <?php endforeach; ?>
       
   383 </div>
   305 </fieldset></td>
   384 </fieldset></td>
   306 </tr>
   385 </tr>
   307 
   386 
   308 <tr>
   387 <tr>
   309 <th scope="row"><?php _e( 'Repeat' ); ?></th>
   388 <th scope="row"><label for="background-size"><?php _e( 'Image Size' ); ?></label></th>
   310 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Repeat' ); ?></span></legend>
   389 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Image Size' ); ?></span></legend>
   311 <label><input type="radio" name="background-repeat" value="no-repeat"<?php checked( 'no-repeat', get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) ); ?> /> <?php _e('No Repeat'); ?></label>
   390 <select id="background-size" name="background-size">
   312 	<label><input type="radio" name="background-repeat" value="repeat"<?php checked( 'repeat', get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) ); ?> /> <?php _e('Tile'); ?></label>
   391 <option value="auto"<?php selected( 'auto', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?>><?php _ex( 'Original', 'Original Size' ); ?></option>
   313 	<label><input type="radio" name="background-repeat" value="repeat-x"<?php checked( 'repeat-x', get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) ); ?> /> <?php _e('Tile Horizontally'); ?></label>
   392 <option value="contain"<?php selected( 'contain', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?>><?php _e( 'Fit to Screen' ); ?></option>
   314 	<label><input type="radio" name="background-repeat" value="repeat-y"<?php checked( 'repeat-y', get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) ); ?> /> <?php _e('Tile Vertically'); ?></label>
   393 <option value="cover"<?php selected( 'cover', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?>><?php _e( 'Fill Screen' ); ?></option>
       
   394 </select>
   315 </fieldset></td>
   395 </fieldset></td>
   316 </tr>
   396 </tr>
   317 
   397 
   318 <tr>
   398 <tr>
   319 <th scope="row"><?php _ex( 'Attachment', 'Background Attachment' ); ?></th>
   399 <th scope="row"><?php _ex( 'Repeat', 'Background Repeat' ); ?></th>
   320 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Attachment' ); ?></span></legend>
   400 <td><fieldset><legend class="screen-reader-text"><span><?php _ex( 'Repeat', 'Background Repeat' ); ?></span></legend>
   321 <label>
   401 <input name="background-repeat" type="hidden" value="no-repeat">
   322 <input name="background-attachment" type="radio" value="scroll" <?php checked( 'scroll', get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) ) ); ?> />
   402 <label><input type="checkbox" name="background-repeat" value="repeat"<?php checked( 'repeat', get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) ); ?>> <?php _e( 'Repeat Background Image' ); ?></label>
   323 <?php _e( 'Scroll' ); ?>
   403 </fieldset></td>
   324 </label>
   404 </tr>
   325 <label>
   405 
   326 <input name="background-attachment" type="radio" value="fixed" <?php checked( 'fixed', get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) ) ); ?> />
   406 <tr>
   327 <?php _e( 'Fixed' ); ?>
   407 <th scope="row"><?php _ex( 'Scroll', 'Background Scroll' ); ?></th>
   328 </label>
   408 <td><fieldset><legend class="screen-reader-text"><span><?php _ex( 'Scroll', 'Background Scroll' ); ?></span></legend>
       
   409 <input name="background-attachment" type="hidden" value="fixed">
       
   410 <label><input name="background-attachment" type="checkbox" value="scroll" <?php checked( 'scroll', get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) ) ); ?>> <?php _e( 'Scroll with Page' ); ?></label>
   329 </fieldset></td>
   411 </fieldset></td>
   330 </tr>
   412 </tr>
   331 <?php endif; // get_background_image() ?>
   413 <?php endif; // get_background_image() ?>
   332 <tr>
   414 <tr>
   333 <th scope="row"><?php _e( 'Background Color' ); ?></th>
   415 <th scope="row"><?php _e( 'Background Color' ); ?></th>
   335 <?php
   417 <?php
   336 $default_color = '';
   418 $default_color = '';
   337 if ( current_theme_supports( 'custom-background', 'default-color' ) )
   419 if ( current_theme_supports( 'custom-background', 'default-color' ) )
   338 	$default_color = ' data-default-color="#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ) . '"';
   420 	$default_color = ' data-default-color="#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ) . '"';
   339 ?>
   421 ?>
   340 <input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr( get_background_color() ); ?>"<?php echo $default_color ?> />
   422 <input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr( get_background_color() ); ?>"<?php echo $default_color ?>>
   341 </fieldset></td>
   423 </fieldset></td>
   342 </tr>
   424 </tr>
   343 </tbody>
   425 </tbody>
   344 </table>
   426 </table>
   345 
   427 
   355 	 * Handle an Image upload for the background image.
   437 	 * Handle an Image upload for the background image.
   356 	 *
   438 	 *
   357 	 * @since 3.0.0
   439 	 * @since 3.0.0
   358 	 */
   440 	 */
   359 	public function handle_upload() {
   441 	public function handle_upload() {
   360 
       
   361 		if ( empty($_FILES) )
   442 		if ( empty($_FILES) )
   362 			return;
   443 			return;
   363 
   444 
   364 		check_admin_referer('custom-background-upload', '_wpnonce-custom-background-upload');
   445 		check_admin_referer('custom-background-upload', '_wpnonce-custom-background-upload');
   365 		$overrides = array('test_form' => false);
   446 		$overrides = array('test_form' => false);
   404 		do_action( 'wp_create_file_in_uploads', $file, $id ); // For replication
   485 		do_action( 'wp_create_file_in_uploads', $file, $id ); // For replication
   405 		$this->updated = true;
   486 		$this->updated = true;
   406 	}
   487 	}
   407 
   488 
   408 	/**
   489 	/**
   409 	 * AJAX handler for adding custom background context to an attachment.
   490 	 * Ajax handler for adding custom background context to an attachment.
   410 	 *
   491 	 *
   411 	 * Triggered when the user adds a new background image from the
   492 	 * Triggered when the user adds a new background image from the
   412 	 * Media Manager.
   493 	 * Media Manager.
   413 	 *
   494 	 *
   414 	 * @since 4.1.0
   495 	 * @since 4.1.0
   432 
   513 
   433 	/**
   514 	/**
   434 	 *
   515 	 *
   435 	 * @since 3.4.0
   516 	 * @since 3.4.0
   436 	 * @deprecated 3.5.0
   517 	 * @deprecated 3.5.0
       
   518 	 *
       
   519 	 * @param array $form_fields
       
   520 	 * @return array $form_fields
   437 	 */
   521 	 */
   438 	public function attachment_fields_to_edit( $form_fields ) {
   522 	public function attachment_fields_to_edit( $form_fields ) {
   439 		return $form_fields;
   523 		return $form_fields;
   440 	}
   524 	}
   441 
   525 
   442 	/**
   526 	/**
   443 	 *
   527 	 *
   444 	 * @since 3.4.0
   528 	 * @since 3.4.0
   445 	 * @deprecated 3.5.0
   529 	 * @deprecated 3.5.0
       
   530 	 *
       
   531 	 * @param array $tabs
       
   532 	 * @return array $tabs
   446 	 */
   533 	 */
   447 	public function filter_upload_tabs( $tabs ) {
   534 	public function filter_upload_tabs( $tabs ) {
   448 		return $tabs;
   535 		return $tabs;
   449 	}
   536 	}
   450 
   537