_custom_background_cb

The timeline below displays how wordpress function _custom_background_cb has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    /*
     * $color is the saved custom color.
     * A default has to be specified in style.css. It will not be printed here.
     */
    $color = get_background_color();
    if (get_theme_support('custom-background', 'default-color') === $color) {
        $color = false;
    }
    $type_attr = current_theme_supports('html5', 'style') ? '' : ' type="text/css"';
    if (!$background && !$color) {
        if (is_customize_preview()) {
            printf('<style%s id="custom-background-css"></style>', $type_attr);
        }
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = ' background-image: url("' . sanitize_url($background) . '");';
        // Background Position.
        $position_x = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        $position_y = get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y'));
        if (!in_array($position_x, array('left', 'center', 'right'), true)) {
            $position_x = 'left';
        }
        if (!in_array($position_y, array('top', 'center', 'bottom'), true)) {
            $position_y = 'top';
        }
        $position = " background-position: {$position_x} {$position_y};";
        // Background Size.
        $size = get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'));
        if (!in_array($size, array('auto', 'contain', 'cover'), true)) {
            $size = 'auto';
        }
        $size = " background-size: {$size};";
        // Background Repeat.
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('repeat-x', 'repeat-y', 'repeat', 'no-repeat'), true)) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        // Background Scroll.
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if ('fixed' !== $attachment) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $position . $size . $repeat . $attachment;
    }
    ?>
<style<?php 
    echo $type_attr;
    ?> id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
	<?php 
}

WordPress Version: 6.1

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if (get_theme_support('custom-background', 'default-color') === $color) {
        $color = false;
    }
    $type_attr = current_theme_supports('html5', 'style') ? '' : ' type="text/css"';
    if (!$background && !$color) {
        if (is_customize_preview()) {
            printf('<style%s id="custom-background-css"></style>', $type_attr);
        }
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = ' background-image: url("' . sanitize_url($background) . '");';
        // Background Position.
        $position_x = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        $position_y = get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y'));
        if (!in_array($position_x, array('left', 'center', 'right'), true)) {
            $position_x = 'left';
        }
        if (!in_array($position_y, array('top', 'center', 'bottom'), true)) {
            $position_y = 'top';
        }
        $position = " background-position: {$position_x} {$position_y};";
        // Background Size.
        $size = get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'));
        if (!in_array($size, array('auto', 'contain', 'cover'), true)) {
            $size = 'auto';
        }
        $size = " background-size: {$size};";
        // Background Repeat.
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('repeat-x', 'repeat-y', 'repeat', 'no-repeat'), true)) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        // Background Scroll.
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if ('fixed' !== $attachment) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $position . $size . $repeat . $attachment;
    }
    ?>
<style<?php 
    echo $type_attr;
    ?> id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
	<?php 
}

WordPress Version: 5.4

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if (get_theme_support('custom-background', 'default-color') === $color) {
        $color = false;
    }
    $type_attr = current_theme_supports('html5', 'style') ? '' : ' type="text/css"';
    if (!$background && !$color) {
        if (is_customize_preview()) {
            printf('<style%s id="custom-background-css"></style>', $type_attr);
        }
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = ' background-image: url("' . esc_url_raw($background) . '");';
        // Background Position.
        $position_x = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        $position_y = get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y'));
        if (!in_array($position_x, array('left', 'center', 'right'), true)) {
            $position_x = 'left';
        }
        if (!in_array($position_y, array('top', 'center', 'bottom'), true)) {
            $position_y = 'top';
        }
        $position = " background-position: {$position_x} {$position_y};";
        // Background Size.
        $size = get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'));
        if (!in_array($size, array('auto', 'contain', 'cover'), true)) {
            $size = 'auto';
        }
        $size = " background-size: {$size};";
        // Background Repeat.
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('repeat-x', 'repeat-y', 'repeat', 'no-repeat'), true)) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        // Background Scroll.
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if ('fixed' !== $attachment) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $position . $size . $repeat . $attachment;
    }
    ?>
<style<?php 
    echo $type_attr;
    ?> id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
	<?php 
}

WordPress Version: 5.3

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    $type_attr = current_theme_supports('html5', 'style') ? '' : ' type="text/css"';
    if (!$background && !$color) {
        if (is_customize_preview()) {
            printf('<style%s id="custom-background-css"></style>', $type_attr);
        }
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = ' background-image: url("' . esc_url_raw($background) . '");';
        // Background Position.
        $position_x = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        $position_y = get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y'));
        if (!in_array($position_x, array('left', 'center', 'right'), true)) {
            $position_x = 'left';
        }
        if (!in_array($position_y, array('top', 'center', 'bottom'), true)) {
            $position_y = 'top';
        }
        $position = " background-position: {$position_x} {$position_y};";
        // Background Size.
        $size = get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'));
        if (!in_array($size, array('auto', 'contain', 'cover'), true)) {
            $size = 'auto';
        }
        $size = " background-size: {$size};";
        // Background Repeat.
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('repeat-x', 'repeat-y', 'repeat', 'no-repeat'), true)) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        // Background Scroll.
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if ('fixed' !== $attachment) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $position . $size . $repeat . $attachment;
    }
    ?>
<style<?php 
    echo $type_attr;
    ?> id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
	<?php 
}

WordPress Version: 5.1

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    if (!$background && !$color) {
        if (is_customize_preview()) {
            echo '<style type="text/css" id="custom-background-css"></style>';
        }
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = ' background-image: url("' . esc_url_raw($background) . '");';
        // Background Position.
        $position_x = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        $position_y = get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y'));
        if (!in_array($position_x, array('left', 'center', 'right'), true)) {
            $position_x = 'left';
        }
        if (!in_array($position_y, array('top', 'center', 'bottom'), true)) {
            $position_y = 'top';
        }
        $position = " background-position: {$position_x} {$position_y};";
        // Background Size.
        $size = get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'));
        if (!in_array($size, array('auto', 'contain', 'cover'), true)) {
            $size = 'auto';
        }
        $size = " background-size: {$size};";
        // Background Repeat.
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('repeat-x', 'repeat-y', 'repeat', 'no-repeat'), true)) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        // Background Scroll.
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if ('fixed' !== $attachment) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $position . $size . $repeat . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
	<?php 
}

WordPress Version: 4.9

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    if (!$background && !$color) {
        if (is_customize_preview()) {
            echo '<style type="text/css" id="custom-background-css"></style>';
        }
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = ' background-image: url("' . esc_url_raw($background) . '");';
        // Background Position.
        $position_x = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        $position_y = get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y'));
        if (!in_array($position_x, array('left', 'center', 'right'), true)) {
            $position_x = 'left';
        }
        if (!in_array($position_y, array('top', 'center', 'bottom'), true)) {
            $position_y = 'top';
        }
        $position = " background-position: {$position_x} {$position_y};";
        // Background Size.
        $size = get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'));
        if (!in_array($size, array('auto', 'contain', 'cover'), true)) {
            $size = 'auto';
        }
        $size = " background-size: {$size};";
        // Background Repeat.
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('repeat-x', 'repeat-y', 'repeat', 'no-repeat'), true)) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        // Background Scroll.
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if ('fixed' !== $attachment) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $position . $size . $repeat . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}

WordPress Version: 7.1

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 * @access protected
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    if (!$background && !$color) {
        if (is_customize_preview()) {
            echo '<style type="text/css" id="custom-background-css"></style>';
        }
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = ' background-image: url("' . esc_url_raw($background) . '");';
        // Background Position.
        $position_x = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        $position_y = get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y'));
        if (!in_array($position_x, array('left', 'center', 'right'), true)) {
            $position_x = 'left';
        }
        if (!in_array($position_y, array('top', 'center', 'bottom'), true)) {
            $position_y = 'top';
        }
        $position = " background-position: {$position_x} {$position_y};";
        // Background Size.
        $size = get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'));
        if (!in_array($size, array('auto', 'contain', 'cover'), true)) {
            $size = 'auto';
        }
        $size = " background-size: {$size};";
        // Background Repeat.
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('repeat-x', 'repeat-y', 'repeat', 'no-repeat'), true)) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        // Background Scroll.
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if ('fixed' !== $attachment) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $position . $size . $repeat . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}

WordPress Version: 4.7

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 * @access protected
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    if (!$background && !$color) {
        if (is_customize_preview()) {
            echo '<style type="text/css" id="custom-background-css"></style>';
        }
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = " background-image: url(" . wp_json_encode($background) . ");";
        // Background Position.
        $position_x = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        $position_y = get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y'));
        if (!in_array($position_x, array('left', 'center', 'right'), true)) {
            $position_x = 'left';
        }
        if (!in_array($position_y, array('top', 'center', 'bottom'), true)) {
            $position_y = 'top';
        }
        $position = " background-position: {$position_x} {$position_y};";
        // Background Size.
        $size = get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'));
        if (!in_array($size, array('auto', 'contain', 'cover'), true)) {
            $size = 'auto';
        }
        $size = " background-size: {$size};";
        // Background Repeat.
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('repeat-x', 'repeat-y', 'repeat', 'no-repeat'), true)) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        // Background Scroll.
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if ('fixed' !== $attachment) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $position . $size . $repeat . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}

WordPress Version: 6.3

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 * @access protected
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    if (!$background && !$color) {
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = " background-image: url('{$background}');";
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('no-repeat', 'repeat-x', 'repeat-y', 'repeat'))) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        $position = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        if (!in_array($position, array('center', 'right', 'left'))) {
            $position = 'left';
        }
        $position = " background-position: top {$position};";
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if (!in_array($attachment, array('fixed', 'scroll'))) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $repeat . $position . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}

WordPress Version: .20

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 * @access protected
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    if (!$background && !$color) {
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = " background-image: url('" . esc_url_raw($background) . "');";
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('no-repeat', 'repeat-x', 'repeat-y', 'repeat'))) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        $position = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        if (!in_array($position, array('center', 'right', 'left'))) {
            $position = 'left';
        }
        $position = " background-position: top {$position};";
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if (!in_array($attachment, array('fixed', 'scroll'))) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $repeat . $position . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}

WordPress Version: 6.2

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 * @access protected
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    if (!$background && !$color) {
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = " background-image: url('{$background}');";
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('no-repeat', 'repeat-x', 'repeat-y', 'repeat'))) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        $position = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        if (!in_array($position, array('center', 'right', 'left'))) {
            $position = 'left';
        }
        $position = " background-position: top {$position};";
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if (!in_array($attachment, array('fixed', 'scroll'))) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $repeat . $position . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}

WordPress Version: .16

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 * @access protected
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    if (!$background && !$color) {
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = " background-image: url('" . esc_url_raw($background) . "');";
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('no-repeat', 'repeat-x', 'repeat-y', 'repeat'))) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        $position = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        if (!in_array($position, array('center', 'right', 'left'))) {
            $position = 'left';
        }
        $position = " background-position: top {$position};";
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if (!in_array($attachment, array('fixed', 'scroll'))) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $repeat . $position . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}

WordPress Version: 3.9

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 * @access protected
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_background_color();
    if ($color === get_theme_support('custom-background', 'default-color')) {
        $color = false;
    }
    if (!$background && !$color) {
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = " background-image: url('{$background}');";
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('no-repeat', 'repeat-x', 'repeat-y', 'repeat'))) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        $position = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        if (!in_array($position, array('center', 'right', 'left'))) {
            $position = 'left';
        }
        $position = " background-position: top {$position};";
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if (!in_array($attachment, array('fixed', 'scroll'))) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $repeat . $position . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}

WordPress Version: 3.8

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 * @access protected
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_theme_mod('background_color');
    if (!$background && !$color) {
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = " background-image: url('{$background}');";
        $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
        if (!in_array($repeat, array('no-repeat', 'repeat-x', 'repeat-y', 'repeat'))) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        $position = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
        if (!in_array($position, array('center', 'right', 'left'))) {
            $position = 'left';
        }
        $position = " background-position: top {$position};";
        $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
        if (!in_array($attachment, array('fixed', 'scroll'))) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $repeat . $position . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}

WordPress Version: 3.7

/**
 * Default custom background callback.
 *
 * @since 3.0.0
 * @access protected
 */
function _custom_background_cb()
{
    // $background is the saved custom image, or the default image.
    $background = set_url_scheme(get_background_image());
    // $color is the saved custom color.
    // A default has to be specified in style.css. It will not be printed here.
    $color = get_theme_mod('background_color');
    if (!$background && !$color) {
        return;
    }
    $style = $color ? "background-color: #{$color};" : '';
    if ($background) {
        $image = " background-image: url('{$background}');";
        $repeat = get_theme_mod('background_repeat', 'repeat');
        if (!in_array($repeat, array('no-repeat', 'repeat-x', 'repeat-y', 'repeat'))) {
            $repeat = 'repeat';
        }
        $repeat = " background-repeat: {$repeat};";
        $position = get_theme_mod('background_position_x', 'left');
        if (!in_array($position, array('center', 'right', 'left'))) {
            $position = 'left';
        }
        $position = " background-position: top {$position};";
        $attachment = get_theme_mod('background_attachment', 'scroll');
        if (!in_array($attachment, array('fixed', 'scroll'))) {
            $attachment = 'scroll';
        }
        $attachment = " background-attachment: {$attachment};";
        $style .= $image . $repeat . $position . $attachment;
    }
    ?>
<style type="text/css" id="custom-background-css">
body.custom-background { <?php 
    echo trim($style);
    ?> }
</style>
<?php 
}