Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#28042 closed defect (bug) (fixed)

Logic for custom header default text color is broken

Reported by: ocean90's profile ocean90 Owned by: ocean90's profile ocean90
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.5
Component: Customize Keywords: has-patch
Focuses: administration Cc:

Description

Have a theme which registers following header support:

add_theme_support( 'custom-header', array(
	'width'       => 500,
	'flex-height' => true,
	'height'      => 500,
) );

(Or use Twenty Eleven and remove 'default-text-color' => '000',.)

Then go to Appearance > Header. You will see that beside "Text color" is nothing (see attached screenshot). Unchecking the checkbox for "Header Text" will produce a JS error: Uncaught TypeError: Cannot read property 'replace' of undefined in themes.php?page=custom-header:61.

The issue is that current_theme_supports( 'custom-header', 'default-text-color' ) returns false.

My original goal was to just support custom header images and allow to show/hide the header text. No color changing. Per default header-text will be true. default-text-color is an empty string. But that seems impossible with our API yet.

Attachments (3)

20842.png (16.0 KB) - added by ocean90 11 years ago.
28042.patch (1.1 KB) - added by ocean90 11 years ago.
28042.2.patch (2.3 KB) - added by ocean90 11 years ago.

Download all attachments as: .zip

Change History (11)

@ocean90
11 years ago

@ocean90
11 years ago

#1 @ocean90
11 years ago

  • Keywords has-patch added; needs-patch removed

28042.patch moves the input field out of the current_theme_supports() check.

#2 @ocean90
11 years ago

  • Version set to 3.5

#3 follow-up: @obenland
11 years ago

With 28042.patch we'd still be missing a default value.

Can we assume that if a theme does not provide a default color, it does not support changing the header color and that setting should not even appear?
Or do we consider changing the color a core feature that should work regardless of what the theme set its default to be?
Judging from how add_theme_support() sets the defaults, it's currently the former.

#4 in reply to: ↑ 3 @ocean90
11 years ago

Replying to obenland:

With 28042.patch we'd still be missing a default value.

The default value is an empty string, see tags/3.9/src/wp-includes/theme.php#L1453

Can we assume that if a theme does not provide a default color, it does not support changing the header color and that setting should not even appear?

No. Maybe we can use a value of false to disable the color feature, but that's another ticket.

Or do we consider changing the color a core feature that should work regardless of what the theme set its default to be?

Which is the current behavior, at least for the Customizer, but broken on the Custom Header screen.

#5 @obenland
11 years ago

I see. I wasn't aware Iris reverted to Clear instead of Default when no default value is present. I assumed it always needed a default.

With your patch we'd still be left with a stray # in the input field, which is not present in the customizer. I think #27583 would come in really handy here.

This ticket was mentioned in IRC in #wordpress-dev by ocean90. View the logs.


11 years ago

@ocean90
11 years ago

#7 @ocean90
11 years ago

28042.2.patch removes the stray # from the input field.

#8 @ocean90
11 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 28294:

Custom Header: Fix logic when a theme doesn't set default-text-color.

fixes #28042.

Note: See TracTickets for help on using tickets.