Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am debugging my theme using Debug Bar plugin, which is showing me this error (among a few others):

Notice: add_custom_image_header is deprecated since version 3.4! Use add_theme_support( 'custom-header', $args ) instead.

Okay, clearly, it says I need to use this instead of this. The question is, add_custom_image_header has three parameters, namely:

  • $header_callback
  • $admin_header_callback
  • $admin_image_div_callback

How do I represent them in add_theme_support function? Like this?

$aahan_custom_header_args = array(
    'wp-head-callback'       => '',
    'admin-head-callback'    => '',
    'admin-preview-callback' => '',
);
add_theme_support( 'custom-header', $aahan_custom_header_args );

Also, are wp-head-callback, admin-head-callback, and admin-preview-callback, the exact replacements for $header_callback, $admin_header_callback, and $admin_image_div_callback respectively?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

Please read Updating Custom Backgrounds and Custom Headers for WordPress 3.4.

Custom Headers

Old method:

// Define default header image constant
define( 'HEADER_IMAGE', get_template_directory_uri() . '/images/headers/default.jpg' );
// Define header image width constant
define( 'HEADER_IMAGE_WIDTH', 1000 );
// Define header image height constant
define( 'HEADER_IMAGE_HEIGHT', 198 );
// Define header text constant
define( 'NO_HEADER_TEXT', false );
// Define header text color constant
define( 'HEADER_TEXTCOLOR', '000' );
// Turn on random header image rotation by default.
// Requires HEADER_IMAGE to be null
add_theme_support( 'custom-header', array( 'random-default' => true ) );

// Add Theme support
add_custom_image_header( $wphead_cb, $adminhead_cb, $adminpreview_cb );

New method:

add_theme_support( 'custom-header', array(
    // Header image default
    'default-image'         => get_template_directory_uri() . '/images/headers/default.jpg',
    // Header text display default
    'header-text'           => false,
    // Header text color default
    'default-text-color'        => '000',
    // Header image width (in pixels)
    'width'             => 1000,
    // Header image height (in pixels)
    'height'            => 198,
    // Header image random rotation default
    'random-default'        => false,
    // Template header style callback
    'wp-head-callback'      => $wphead_cb,
    // Admin header style callback
    'admin-head-callback'       => $adminhead_cb,
    // Admin preview style callback
    'admin-preview-callback'    => $adminpreview_cb
) );

Again: that was easy, wasn't it?

Just to clarify, here are the old-constant/new-array-key equivalents:

HEADER_IMAGE       => 'default-image'
HEADER_IMAGE_WIDTH  => 'width'
HEADER_IMAGE_HEIGHT => 'height'
NO_HEADER_TEXT      => 'header-text'
HEADER_TEXTCOLOR    => 'default-text-color'

All of the same callbacks are supported, exactly as before.

For reference, here is the complete defaults array:

$defaults = array(
    'default-image' => '',
    'random-default' => false,
    'width' => 0,
    'height' => 0,
    'flex-height' => false,
    'flex-width' => false,
    'default-text-color' => '',
    'header-text' => true,
    'uploads' => true,
    'wp-head-callback' => '',
    'admin-head-callback' => '',
    'admin-preview-callback' => '',
);
share|improve this answer
    
Thanks, that was very very clear indeed. Just to confirm what I am doing is right, are wp-head-callback, admin-head-callback, and admin-preview-callback in the new function, the exact replacements for $header_callback, $admin_header_callback, and $admin_image_div_callback respectively? –  its_me Jun 16 '12 at 2:55
1  
Yes. Those are the exact analogs. It was designed to be straightforward to port from the old implementation to the new. (Thankfully :) ) –  Chip Bennett Jun 16 '12 at 3:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.