Custom_Background::admin_page() – Display the custom background page.

You appear to be a bot. Output may be restricted

Description

Display the custom background page.

Usage

Custom_Background::admin_page();

Parameters

Returns

void

Source

File name: wordpress/wp-admin/includes/class-custom-background.php
Lines:

1 to 100 of 252
  public function admin_page() {
    ?>
<div class="wrap" id="custom-background">
<h1><?php _e( 'Custom Background' ); ?></h1>

		<?php if ( current_user_can( 'customize' ) ) { ?>
<div class="notice notice-info hide-if-no-customize">
	<p>
			<?php
      printf(
        /* translators: %s: URL to background image configuration in Customizer. */
        __( 'You can now manage and live-preview Custom Backgrounds in the <a href="%s">Customizer</a>.' ),
        admin_url( 'customize.php?autofocus[control]=background_image' )
      );
      ?>
	</p>
</div>
		<?php } ?>

		<?php if ( ! empty( $this->updated ) ) { ?>
<div id="message" class="updated">
	<p>
			<?php
      /* translators: %s: Home URL. */
      printf( __( 'Background updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) );
      ?>
	</p>
</div>
		<?php } ?>

<h2><?php _e( 'Background Image' ); ?></h2>

<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row"><?php _e( 'Preview' ); ?></th>
<td>
		<?php
    if ( $this->admin_image_div_callback ) {
      call_user_func( $this->admin_image_div_callback );
    } else {
      $background_styles = '';
      $bgcolor           = get_background_color();
      if ( $bgcolor ) {
        $background_styles .= 'background-color: #' . $bgcolor . ';';
      }

      $background_image_thumb = get_background_image();
      if ( $background_image_thumb ) {
        $background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) );
        $background_position_x  = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
        $background_position_y  = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) );
        $background_size        = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) );
        $background_repeat      = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
        $background_attachment  = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );

        // Background-image URL must be single quote, see below.
        $background_styles .= " background-image: url('$background_image_thumb');"
        . " background-size: $background_size;"
        . " background-position: $background_position_x $background_position_y;"
        . " background-repeat: $background_repeat;"
        . " background-attachment: $background_attachment;";
      }
      ?>
	<div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // Must be double quote, see above. ?>
			<?php if ( $background_image_thumb ) { ?>
		<img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" /><br />
		<img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" />
		<?php } ?>
	</div>
	<?php } ?>
</td>
</tr>

		<?php if ( get_background_image() ) : ?>
<tr>
<th scope="row"><?php _e( 'Remove Image' ); ?></th>
<td>
<form method="post">
			<?php wp_nonce_field( 'custom-background-remove', '_wpnonce-custom-background-remove' ); ?>
			<?php submit_button( __( 'Remove Background Image' ), '', 'remove-background', false ); ?><br/>
			<?php _e( 'This will remove the background image. You will not be able to restore any customizations.' ); ?>
</form>
</td>
</tr>
		<?php endif; ?>

		<?php $default_image = get_theme_support( 'custom-background', 'default-image' ); ?>
		<?php if ( $default_image && get_background_image() !== $default_image ) : ?>
<tr>
<th scope="row"><?php _e( 'Restore Original Image' ); ?></th>
<td>
<form method="post">
			<?php wp_nonce_field( 'custom-background-reset', '_wpnonce-custom-background-reset' ); ?>
			<?php submit_button( __( 'Restore Original Image' ), '', 'reset-background', false ); ?><br/>
			<?php _e( 'This will restore the original background image. You will not be able to restore any customizations.' ); ?>
</form>
</td>
</tr>
		<?php endif; ?>
 

 View on GitHub View on Trac