Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#20603 closed defect (bug) (fixed)

Warning error occurs on the default parameter of "admin-head-callback" in add_theme_support.

Reported by: jim912's profile jim912 Owned by: nacin's profile nacin
Milestone: 3.4 Priority: high
Severity: major Version: 3.4
Component: Themes Keywords: has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

When you make settings of custom header using add_theme_support on functions.php of a theme, if you use default value without defining admin-head-callback, warning error occurs as follows on admin screen of custom header.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '' not found or invalid function name in path-to-wordpress-root/wp-includes/plugin.php on line 403

To fix this, I think better to change default value of admin-head-callback into __return_false, on /wp-includes/theme.php. Here's patch.

Attachments (1)

theme.php.diff (102 bytes) - added by jim912 13 years ago.

Download all attachments as: .zip

Change History (9)

@jim912
13 years ago

#1 @nacin
13 years ago

  • Milestone changed from Awaiting Review to 3.4

#2 @SergeyBiryukov
13 years ago

  • Description modified (diff)

#3 @nacin
13 years ago

In 3.3, admin-head-callback was required, and remains required by the Custom_Image_Header class. So the best thing to do would be to require it in _custom_header_background_just_in_time().

#4 @nacin
13 years ago

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

In [20684]:

Require both wp-head-callback and admin-head-callback for custom header theme support. fixes #20603.

#5 @westi
13 years ago

  • Priority changed from normal to high
  • Resolution fixed deleted
  • Severity changed from normal to major
  • Status changed from closed to reopened

This change breaks backwards compatibility with themes that call add_custom_image_header() with an empty wp_head_callback which was previously quite valid.

In 3.3 we only added the hook onto wp_head if it wasn't empty.

With the change Custom Headers become disabled on all themes that don't need a wp_head callback which is a regression.

I think we can just revert the changes to wp-includes/theme.php

#6 @nacin
13 years ago

Bad logic change on my part. Can get away with a bit of a tweak here.

#7 @nacin
13 years ago

The best change is revert the changes to wp-includes/theme.php and make admin-head-callback optional. There's really no reason to not make it optional — the admin preview (image div) callback is optional; the argument enforces admin_head CSS for a header when it may not be needed.

The main issue is that otherwise we would have to enforce admin-head-callback as the only required argument for both custom headers and custom backgrounds. This forces us to do some funky things in the just-in-time function and I don't find it to be necessary for what should be optional CSS.

#8 @nacin
13 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In [20712]:

Make admin-head-callback optional for custom headers. Reverts part of [20684]. fixes #20603.

Note: See TracTickets for help on using tickets.