Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP 8.1 errors caused by missing page titles #462

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions admin/class-manage-fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -36,13 +35,21 @@ 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( 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() {
Expand Down
Loading