WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#20768 closed defect (bug) (fixed)

Twenty Eleven Theme with Custom Header

Reported by: andrejcarter Owned by: ryan
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.4
Component: Bundled Theme Keywords: has-patch commit
Focuses: Cc:

Description

I updated from 3.3.2 to 3.4 RC1. When I visit the site I get an error stating "Fatal error: Call to undefined function get_custom_header() in /home/andrejcarter/ajorel.com/wp-content/themes/twentyeleven/header.php on line 82". I have a multisite installation and the only site giving this error is the site using the Twenty Eleven theme. Other sites use Twenty Ten 1.3, Oxygen 0.2.2, and Frisco for BuddyPress 1.5.04.

Attachments (5)

3.4 Error.png (124.6 KB) - added by andrejcarter 5 years ago.
Screenshot of the error "Fatal error: Call to undefined function get_custom_header() in /home/andrejcarter/ajorel.com/wp-content/themes/twentyeleven/header.php on line 82"
20768.diff (5.0 KB) - added by kobenland 5 years ago.
Patch provides backward compatibility to 3.2 for Twenty Eleven and 3.1 for Twenty Ten.
20768.2.diff (1.3 KB) - added by SergeyBiryukov 5 years ago.
20768.3.diff (9.4 KB) - added by nacin 5 years ago.
20768.4.diff (9.7 KB) - added by nacin 5 years ago.
Includes background compat.

Download all attachments as: .zip

Change History (22)

@andrejcarter
5 years ago

Screenshot of the error "Fatal error: Call to undefined function get_custom_header() in /home/andrejcarter/ajorel.com/wp-content/themes/twentyeleven/header.php on line 82"

#1 @SergeyBiryukov
5 years ago

Sounds like an incomplete upgrade.

get_custom_header() is defined in wp-includes/theme.php:
http://core.trac.wordpress.org/browser/trunk/wp-includes/theme.php?rev=20934#L1003

In Twenty Ten, get_custom_header() is wrapped in a function_exists() check, that may explain why the issue only manifests itself in Twenty Eleven.

#2 @nacin
5 years ago

  • Milestone changed from Awaiting Review to 3.4

#3 @andrejcarter
5 years ago

Filezilla didn't give me an error when I uploaded the RC the first time, but I got the error when visiting the site. I re-uploaded it after SergeyBiryukov's comment and didn't have a problem.

#4 @scribu
5 years ago

  • Component changed from Themes to Upgrade/Install
  • Milestone 3.4 deleted
  • Resolution set to invalid
  • Severity changed from major to normal
  • Status changed from new to closed

Sounds like a bug in Filezilla then.

#5 @nacin
5 years ago

  • Milestone set to 3.4
  • Resolution invalid deleted
  • Status changed from closed to reopened

Re-opening as Twenty Eleven should be compatible back to 3.2, when it was introduced.

#6 @nacin
5 years ago

  • Component changed from Upgrade/Install to Bundled Theme

@kobenland
5 years ago

Patch provides backward compatibility to 3.2 for Twenty Eleven and 3.1 for Twenty Ten.

#7 @kobenland
5 years ago

  • Keywords has-patch added

By replacing

<?php
set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );

with

<?php
set_post_thumbnail_size( $custom_header_args['height'], $custom_header_args['width'], true );

in Twenty Ten's functions.php, we could even achieve backward compatibility to WordPress versions prior to 3.1

#8 @SergeyBiryukov
5 years ago

20768.2.diff brings the check from [20474] to Twenty Eleven.

This seems enough to make it work in WordPress 3.2 and 3.3 without a fatal error, though custom header and custom background options are missing there (feels like graceful degradation to me).

The current version of Twenty Ten works in 3.1 to 3.3 in the same way (with custom header and custom background options missing).

In 3.0, Twenty Ten fails due to missing get_theme_support() function. Not sure if we want to fix that.

#9 follow-up: @markjaquith
5 years ago

Even though it's more code, I think we should provide the fuller back compat. It's not very nice for people to lose a bundled theme feature because they updated their theme but weren't yet ready to update core.

#10 in reply to: ↑ 9 @westi
5 years ago

Replying to markjaquith:

Even though it's more code, I think we should provide the fuller back compat. It's not very nice for people to lose a bundled theme feature because they updated their theme but weren't yet ready to update core.

Agreed.

#11 @SergeyBiryukov
5 years ago

In the long run, we should probably introduce "Requires at least" parameter for themes (#16868) and don't show theme updates incompatible with the current core version in the admin, like we do for plugins.

#12 @ryan
5 years ago

We usually hold off updating 2010/2011 in theme repo until the first maintenance for this reason.

@nacin
5 years ago

#13 follow-up: @nacin
5 years ago

Per the IRC dev chat on May 30, we need to upload the default themes into the theme repo when we release WordPress, as a core update no longer updates default themes.

20768.3.diff is what I'm about to test. It is based on kobenland's work, which in turn was based on mfields' work in Automattic's _s theme, but it avoids defining get_custom_header() on its own, because I find it to be more confusing.

It should be fully compatible down to 3.2 for Twenty Eleven, and 3.0 for Twenty Ten.

#14 @SergeyBiryukov
5 years ago

Applied 20768.3.diff and tested Twenty Eleven on 3.2 and Twenty Ten on 3.0.

No fatal errors, custom header options seem to work properly.

Custom background options are missing in both cases though. Adding add_custom_background() to the ! function_exists( 'get_custom_header' ) block seems enough.

@nacin
5 years ago

Includes background compat.

#15 @nacin
5 years ago

  • Keywords commit added

20768.4.diff includes background support.

Tested Twenty Eleven's featured image headers too.

#16 in reply to: ↑ 13 @kobenland
5 years ago

Replying to nacin:

Per the IRC dev chat on May 30, we need to upload the default themes into the theme repo when we release WordPress, as a core update no longer updates default themes.

Concerning guidelines: Are you still open to patches to follow all current requirements? Or is this more something for 3.5?


20768.3.diff is what I'm about to test. It is based on kobenland's work, which in turn was based on mfields' work in Automattic's _s theme

... which in turn is based on my message in the Theme Review mailing list (see _s commit message) (don't bother with the Automattic in the @author tag, I actually wanted to credit you for the original get_custom_header(), had it mixed up and had it changed later).

#17 @ryan
5 years ago

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

In [20983]:

Back compat for bundled themes. Props nacin, SergeyBiryukov, kobenland. fixes #20768

Note: See TracTickets for help on using tickets.