Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 7 years ago

#11855 closed enhancement (fixed)

Custom header template filter

Reported by: dphiffer's profile dphiffer Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch reporter-feedback
Focuses: Cc:

Description

I'm trying to use the built-in functionality that comes in custom-header.php, but found a couple things frustrating about the experience:

  • Hard-coded markup, with no capacity for customization
  • The final step in the process is pointless

I'm including a patch that addresses both these things:

  • Allows a theme developer to specify a PHP script to be included in place of the default markup defined by custom-header.php
  • Shows step1() instead of the "Visit your site and you should see the new header now." message

This is my first patch submission, so I'm sure I'm doing something wrong. Go easy on me :)

Attachments (1)

custom-header.php.diff (1.4 KB) - added by dphiffer 15 years ago.

Download all attachments as: .zip

Change History (16)

#1 @filosofo
15 years ago

why add a custom-header.php template file, when you can just edit header.php to do what you want?

#2 @scribu
15 years ago

  • Keywords has-patch added

I didn't even know about the Custom Image Header API until now.

I think dphiffer wants to be able to customize what is shown on the admin page, not on the front-end.

#3 @dphiffer
15 years ago

Yes, scribu has it. There's an image upload & crop back-end component I'm trying to make more useful to my needs. I could put together a minimal demonstration theme if that's helpful for understanding my patch.

#4 @ShaneF
15 years ago

  • Keywords reporter-feedback added
  • Milestone changed from Unassigned to Future Release

Screenshot would be nice. Give us more to go on.

#5 @dphiffer
15 years ago

Sure, I'll attach before & after screenshots. The crux of the matter is the admin is imposing a precise markup pattern on the theme developer.

In my case my theme adds an adjustable overlay -- I'm using a jquery-ui drag thing that lets me easily upload a new header image and move the text band to an appropriate position. Because of that it's important that the markup be exactly the same on this page as it is for the front-end theme.

#6 @ryan
15 years ago

Let's avoid doing an include on an arbitrary string. Since this is such a small block of markup, let's just pass the markup to the filter.

Getting rid of finished looks good, although the updated text could use a little more info.

More details on what you're wanting to do would indeed be helpful. That way we can think about what the best approach would be. For example would an action above the headimg div suffice? Or maybe a filter in header_image()? Also, maybe we'd like to steal whatever you're doing and bring it into core WP. :-)

#8 @dphiffer
15 years ago

Thanks ryan, that's exactly the kind of feedback I was looking for! Let me rework things and put up a new patch.

Basically I think my beef is that, as a professional front-end developer, I want 100% control over what markup is on my website. All the way down to id="headerimg" vs id="header". Without *something* there, I'd probably rather go and just hard code this stuff instead of using the API.

#9 @ryan
15 years ago

How about adding a $header_image_callback to add_custom_image_header()?

#10 @dphiffer
15 years ago

Yeah, I like that idea -- seems cleaner. Should I take a shot at that? I'd be curious to see the approach by somebody with more experience than me, but I also don't mind pitching in.

#11 @ryan
15 years ago

(In [12890]) Send user back to main custom header page after cropping and setting image. Add support for a custom image div callback for greather theme flexibility. Props dphiffer. see #11855

#12 @ryan
15 years ago

  • Milestone changed from Future Release to 3.0

I did a first pass that needs testing. Create a function that outputs your custom div and pass that to add_custom_image_header().

#13 @dphiffer
15 years ago

Awesome, thanks ryan! I'll try this out with my theme.

#14 @dphiffer
15 years ago

Works perfectly.

#15 @ryan
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.