From ef36c115feedeccc3047914ce6d40e3e2fd6bfb0 Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Tue, 24 Oct 2023 21:33:09 +0200 Subject: [PATCH 1/2] Replace null with empty string on add menu page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Achieves the same effect — keeping those submenus from being displayed — while avoiding PHP errors. Closes: https://github.com/WordPress/create-block-theme/issues/168 --- admin/class-manage-fonts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/class-manage-fonts.php b/admin/class-manage-fonts.php index 4a318d15..d128ad0f 100644 --- a/admin/class-manage-fonts.php +++ b/admin/class-manage-fonts.php @@ -38,11 +38,11 @@ function create_admin_menu() { $google_fonts_page_title = _x( 'Embed Google font in the active theme', 'UI String', 'create-block-theme' ); $google_fonts_menu_title = $google_fonts_page_title; - add_submenu_page( null, $google_fonts_page_title, $google_fonts_menu_title, 'edit_theme_options', 'add-google-font-to-theme-json', array( 'Google_Fonts', 'google_fonts_admin_page' ) ); + add_submenu_page( '', $google_fonts_page_title, $google_fonts_menu_title, 'edit_theme_options', 'add-google-font-to-theme-json', array( 'Google_Fonts', 'google_fonts_admin_page' ) ); $local_fonts_page_title = _x( 'Embed local font in the active theme', 'UI String', 'create-block-theme' ); $local_fonts_menu_title = $local_fonts_page_title; - add_submenu_page( null, $local_fonts_page_title, $local_fonts_menu_title, 'edit_theme_options', 'add-local-font-to-theme-json', array( 'Local_Fonts', 'local_fonts_admin_page' ) ); + add_submenu_page( '', $local_fonts_page_title, $local_fonts_menu_title, 'edit_theme_options', 'add-local-font-to-theme-json', array( 'Local_Fonts', 'local_fonts_admin_page' ) ); } function has_file_and_user_permissions() { From 8d4ecd8bce3611c575935ce7d31a5d93fe497152 Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Wed, 25 Oct 2023 17:40:03 +0200 Subject: [PATCH 2/2] Set page title for manage font submenus pages --- admin/class-manage-fonts.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/admin/class-manage-fonts.php b/admin/class-manage-fonts.php index d128ad0f..6b70a907 100644 --- a/admin/class-manage-fonts.php +++ b/admin/class-manage-fonts.php @@ -5,7 +5,6 @@ require_once( __DIR__ . '/manage-fonts/google-fonts-page.php' ); require_once( __DIR__ . '/manage-fonts/local-fonts-page.php' ); require_once( __DIR__ . '/manage-fonts/font-form-messages.php' ); - class Manage_Fonts_Admin { public function __construct() { @@ -36,6 +35,14 @@ function create_admin_menu() { $manage_fonts_menu_title = $manage_fonts_page_title; add_theme_page( $manage_fonts_page_title, $manage_fonts_menu_title, 'edit_theme_options', 'manage-fonts', array( 'Fonts_Page', 'manage_fonts_admin_page' ) ); + // Check if the admin page title is set, and if not, set one. + // This is needed to avoid a warning in the admin menu, due to the admin page title not being set in + // the add_submenu_page() function for the Google Fonts and Local Fonts pages. + global $title; + if ( ! isset( $title ) ) { + $title = $manage_fonts_page_title; + } + $google_fonts_page_title = _x( 'Embed Google font in the active theme', 'UI String', 'create-block-theme' ); $google_fonts_menu_title = $google_fonts_page_title; add_submenu_page( '', $google_fonts_page_title, $google_fonts_menu_title, 'edit_theme_options', 'add-google-font-to-theme-json', array( 'Google_Fonts', 'google_fonts_admin_page' ) );