From 181ea0fe877e50fb1d598f4780f456cdf53da5d9 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 25 Dec 2021 03:30:27 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@52415 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/menu.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/menu.php b/src/wp-admin/menu.php index 97d5f57984..5d550fb55d 100644 --- a/src/wp-admin/menu.php +++ b/src/wp-admin/menu.php @@ -214,11 +214,12 @@ if ( wp_is_block_theme() ) { ); } -// Hide Customize link on block themes unless a plugin or theme is using -// customize_register to add a setting. +$customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' ); + +// Hide Customize link on block themes unless a plugin or theme +// is using 'customize_register' to add a setting. if ( ! wp_is_block_theme() || has_action( 'customize_register' ) ) { - $customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' ); - $position = wp_is_block_theme() ? 7 : 6; + $position = wp_is_block_theme() ? 7 : 6; $submenu['themes.php'][ $position ] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' ); } @@ -237,7 +238,7 @@ if ( current_theme_supports( 'custom-background' ) && current_user_can( 'customi $submenu['themes.php'][20] = array( __( 'Background' ), $appearance_cap, esc_url( $customize_background_url ), '', 'hide-if-no-customize' ); } - unset( $customize_url ); +unset( $customize_url ); unset( $appearance_cap );