I would like to extend the Custom Header class to include an animation feature for the header graphics. Essentially, I'd like to add another possible value for the radio button for randomization. The existing code reads:

if ( 1 < count( $headers ) ) {
        echo '<div class="random-header">';
        echo '<label><input name="default-header" type="radio" value="random-' . $type . '-image"' . checked( is_random_header_image( $type ), true, false ) . ' />';
        echo __( '<strong>Random:</strong> Show a different image on each page.' );
        echo '</label>';
        echo '</div>';

I would like to do something like this so you can toggle between random and animated. Default output would look something like this:

<div class="behavior-header">
<div class="default-header">
<label><input name="behavior-header" type="radio" value="none" checked />
<strong>None:</strong> No randomization or animation.</label>
<div class="random-header">
<label><input name="behavior-header" type="radio" value="random" />
<strong>Random:</strong> Show a different image on each page load.</label>
<div class="animate-header">
<label><input name="behavior-header" type="radio" value="animate" />
<strong>Animate:</strong> Display headers as slideshow.</label>

I have had no luck hooking into the custom_header_options (it just places any code into the end of the page, which does not allow for an either/or selection of none/random/animation). Anyone had any experience with extending the custom header class? Is there a simpler way to do this without extending the class?

I'm all ears :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.