WordPress.org

Make WordPress Core

Changeset 20973


Ignore:
Timestamp:
06/01/2012 08:31:50 PM (6 years ago)
Author:
ryan
Message:

Custom background fixes:

  • Specify default background colors for the bundled themes.
  • Change the default custom background callback to only operate on saved values, rather than default values.
  • Prevent an unsaved default value from overriding a manually modified style.css file.

Props nacin, kobenland
fixes #20448

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyeleven/functions.php

    r20471 r20973  
    9898    add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
    9999
     100    $theme_options = twentyeleven_get_theme_options();
     101    if ( 'dark' == $theme_options['color_scheme'] )
     102        $default_background_color = '1d1d1d';
     103    else
     104        $default_background_color = 'f1f1f1';
     105
    100106    // Add support for custom backgrounds.
    101     add_theme_support( 'custom-background' );
     107    add_theme_support( 'custom-background', array(
     108        // Let WordPress know what our default background color is.
     109        // This is dependent on our current color scheme.
     110        'default-color' => $default_background_color,
     111    ) );
    102112
    103113    // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
  • trunk/wp-content/themes/twentyten/functions.php

    r20474 r20973  
    9595
    9696    // This theme allows users to set a custom background.
    97     add_theme_support( 'custom-background' );
     97    add_theme_support( 'custom-background', array(
     98        // Let WordPress know what our default background color is.
     99        'default-color' => 'f1f1f1',
     100    ) );
    98101
    99102    // The custom header business starts here.
  • trunk/wp-includes/post-template.php

    r20654 r20973  
    502502        $classes[] = 'admin-bar';
    503503
    504     if ( get_background_image() || get_background_color() )
     504    if ( get_theme_mod( 'background_image' ) || get_theme_mod( 'background_color' ) ||
     505        ( '_custom_background_cb' != get_theme_support( 'custom-background', 'wp-head-callback' )
     506            && ( get_theme_support( 'custom-background', 'default-image' ) ||
     507                get_theme_support( 'custom-background', 'default-color' ) ) ) )
    505508        $classes[] = 'custom-background';
    506509
  • trunk/wp-includes/theme.php

    r20934 r20973  
    11031103 */
    11041104function _custom_background_cb() {
    1105     $background = get_background_image();
    1106     $color = get_background_color();
     1105    $background = get_theme_mod( 'background_image' );
     1106    $color = get_theme_mod( 'background_color' );
     1107
    11071108    if ( ! $background && ! $color )
    11081109        return;
Note: See TracChangeset for help on using the changeset viewer.