Skip to content

Enhancements: Use theme supports for disabling Font Library#79027

Open
Mustafabharmal wants to merge 1 commit into
WordPress:trunkfrom
Mustafabharmal:fix/79019-font-library-theme-support
Open

Enhancements: Use theme supports for disabling Font Library#79027
Mustafabharmal wants to merge 1 commit into
WordPress:trunkfrom
Mustafabharmal:fix/79019-font-library-theme-support

Conversation

@Mustafabharmal

Copy link
Copy Markdown
Contributor

What?

Closes #79019

Introduce a font-library theme support that provides a single mechanism for enabling or disabling the Font Library across both the Block Editor and the WP Admin interface.

When the Font Library is disabled using remove_theme_support( 'font-library' ), the Font Library UI is no longer available in the editor and the Fonts admin screen is removed and cannot be accessed directly.

Why?

Prior to this change, developers could disable the Font Library in the editor by setting fontLibraryEnabled to false via the block_editor_settings_all filter.

However, after the introduction of the dedicated Fonts admin screen, this approach no longer fully disabled the feature. The editor UI could be hidden while the Fonts screen under Appearance remained accessible through both the menu and direct URLs.

This creates an inconsistent experience and requires developers to implement multiple custom solutions to fully disable the feature.

Providing a dedicated font-library theme support aligns with existing WordPress patterns and offers a single, centralized way to control Font Library availability.

How?

This PR introduces a new font-library theme support and uses it as the source of truth for Font Library availability.

Font Library Admin Screen

  • Core's Fonts submenu registration is removed to avoid duplicate menu items.

  • The Gutenberg Fonts screen is only registered when the active theme supports font-library.

  • When the feature is disabled, direct access to:

    • themes.php?page=font-library.php
    • themes.php?page=font-library-wp-admin

    is blocked and returns an error response.

Block Editor Settings

  • gutenberg_get_block_editor_settings() now derives fontLibraryEnabled from current_theme_supports( 'font-library' ).
  • This ensures the editor UI automatically reflects the enabled/disabled state of the feature.
  • Existing customizations using block_editor_settings_all continue to work because they can still override the setting through the existing filter.

Testing Instructions

Default Behavior

  1. Activate Gutenberg.
  2. Open the Site Editor.
  3. Verify the Font Library is available from the Typography tools.
  4. Navigate to Appearance → Fonts.
  5. Verify the Fonts screen is accessible.

Disable the Font Library

  1. Add the following to the active theme:
add_action(
	'after_setup_theme',
	function() {
		remove_theme_support( 'font-library' );
	}
);
  1. Refresh the WP Admin.
  2. Verify the Fonts submenu is no longer visible under Appearance.
  3. Open the Site Editor.
  4. Verify Font Library controls are no longer available.

Direct URL Access

  1. With the theme support removed, visit:
/wp-admin/themes.php?page=font-library.php
  1. Verify access is denied.

  2. Visit:

/wp-admin/themes.php?page=font-library-wp-admin
  1. Verify access is denied.

Backward Compatibility

  1. Add the following filter:
add_filter(
	'block_editor_settings_all',
	function( $settings ) {
		$settings['fontLibraryEnabled'] = false;
		return $settings;
	}
);
  1. Verify the Font Library is still disabled in the editor.
  2. Verify no regressions are introduced to existing customization workflows.

Screenshots or screencast

Before After

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mustafabharmal <mustafabharmal@git.wordpress.org>
Co-authored-by: justintadlock <greenshady@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Feature] Font Library labels Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hook for disabling font library no longer covers all cases (WordPress 7.0)

2 participants