Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#54682 closed defect (bug) (fixed)

PHP Notice when adding 'custom_header' support to block theme

Reported by: afragen Owned by: SergeyBiryukov
Priority: normal Milestone: 5.9
Component: Themes Version: 5.9
Severity: major Keywords: has-patch
Cc: Focuses: administration

Description

When adding add_theme_support( 'custom_header' ); to a block theme in 5.9-beta a PHP warning is thrown on wp-admin/menu.php:231 as $customize_url hasn't been defined.

As $customize_url is defined inside a conditional that may not fire and is unset about 20 lines down the code, it should be defined outside of the conditional.

Change History (7)

This ticket was mentioned in ​PR #2078 on ​WordPress/wordpress-develop by ​afragen.


5 years ago
#1

Currently a PHP notice for an undefined variable $customize_url is reported when a plugin adds add_theme_support('custom_header') and a block theme is the current theme.

Define $customize_url at the beginning of the code section and outside of a conditional. That way it will be defined for all the conditionals.

$customize_url is unset after the conditionals are passed.

Trac ticket: https://core.trac.wordpress.org/ticket/54682

This ticket was mentioned in ​Slack in #core by afragen. ​View the logs.


5 years ago

#3 @SergeyBiryukov
5 years ago

  • Component General → Themes
  • Milestone Awaiting Review → 5.9

#4 @SergeyBiryukov
5 years ago

  • Focuses administration added

This ticket was mentioned in ​Slack in #core by afragen. ​View the logs.


5 years ago

#6 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 52415:

Administration: Make sure the $customize_url variable is always defined in the admin menu.

This avoids an Undefined variable PHP warning when displaying other admin menu items.

Follow-up to [52069], [52134], [52158], [52178], [52414].

Props afragen.
Fixes #54682.

Note: See TracTickets for help on using tickets.