Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#54682 closed defect (bug) (fixed)

PHP Notice when adding 'custom_header' support to block theme

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

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.


3 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.


3 years ago

#3 @SergeyBiryukov
3 years ago

  • Component changed from General to Themes
  • Milestone changed from Awaiting Review to 5.9

#4 @SergeyBiryukov
3 years ago

  • Focuses administration added

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


3 years ago

#6 @SergeyBiryukov
3 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to 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.