Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#23157 closed defect (bug) (invalid)

Custom header in twenty twelve theme not pluggable/filterable

Reported by: adamrice's profile adamrice Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.5
Component: Bundled Theme Keywords:
Focuses: Cc:

Description

Child themes cannot cleanly alter the header styling output from the twenty twelve theme in inc/custom-header.php

I propose a change from

function twentytwelve_header_style()

to

if ( ! function_exists( 'function twentytwelve_header_style' ) ) :
function twentytwelve_header_style()
...

Change History (6)

#1 follow-up: @toscho
11 years ago

  • Cc info@… added
  • Resolution set to invalid
  • Status changed from new to closed

No need to make this function pluggable. Just remove it in your child theme per hook, and use your own setup function then:

add_action( 'after_setup_theme', 'disable_parent_custom_header', 9 );
function disable_parent_custom_header()
{
	remove_action( 'after_setup_theme', 'twentytwelve_custom_header_setup' );
}

#2 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted

#3 in reply to: ↑ 1 ; follow-up: @paulwp
11 years ago

@toscho

Why does 9 work instead of 11 ?

I've been searching everywhere for the answer as to why in this particular case the priority lower than 10 (like 9 as you used in the example above) works instead of priority more than 10 like 11.

Child's function is loaded first, when there are 2 functions, 1 is from parent and 1 from child, both are hooking to the same after_setup_theme(), the add and remove and the order of file being loaded doesn't seem right.

Is this a bug in after_setup_theme() ?

#4 in reply to: ↑ 3 ; follow-up: @toscho
11 years ago

Replying to paulwp:

Why does 9 work instead of 11 ?

When the child theme’s functions.php is loaded the parent theme’s action is not yet bound to the hook. So you have to wait until 'after_setup_theme' is actually called, then remove the callback registered with a lower priority. But you have to do this earlier than the callback, otherwise the callback will be done already.

#5 in reply to: ↑ 4 @paulwp
11 years ago

Replying to toscho:

But you have to do this earlier than the callback, otherwise the callback will be done already.

Thanks a lot !

#6 @adamrice
11 years ago

@toscho — thanks for the explanation.

Note: See TracTickets for help on using tickets.