[wp-trac] [WordPress Trac] #16919: style.css can sometimes conflict with custom background image
WordPress Trac
wp-trac at lists.automattic.com
Mon Jun 6 17:16:19 UTC 2011
#16919: style.css can sometimes conflict with custom background image
-----------------------------------------+------------------
Reporter: nathanrice | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.2
Component: Themes | Version: 3.1
Severity: normal | Resolution:
Keywords: has-patch reporter-feedback |
-----------------------------------------+------------------
Comment (by greenshady):
Setting a background image in PHP (i.e., `BACKGROUND_IMAGE` constant) is
not ideal because many users just like to overwrite this with CSS and not
fiddle with admin options. I'm not sure anything should really be changed
in core though. There are pros and cons to leaving it as-is and changing
it.
Here's a "fix" for theme developers that need to work around this problem.
{{{
add_custom_background( 'my_custom_background_callback' );
function my_custom_background_callback() {
/* Get the background image. */
$image = get_background_image();
/* If there's an image, just call the normal WordPress callback.
We won't do anything here. */
if ( !empty( $image ) ) {
_custom_background_cb();
return;
}
/* Get the background color. */
$color = get_background_color();
/* If no background color, return. */
if ( empty( $color ) )
return;
/* Use 'background' instead of 'background-color'. */
$style = "background: #{$color};";
?>
<style type="text/css">body { <?php echo trim( $style ); ?> }</style>
<?php
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16919#comment:12>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list