Make WordPress Core

Opened 2 months ago

Closed 2 months ago

Last modified 2 months ago

#65550 closed enhancement (reported-upstream)

Add hook to disable Font Library

Reported by: oglekler Owned by:
Priority: normal Milestone:
Component: Editor Version: 7.0
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

For sites with custom themes where fonts are part of the brand identity, there is no need to have the ability to install fonts from the interface. This is only available for users with the ability to edit theme options, but in practice, managers have admin rights, and the developer's task is to unclutter the interface and remove things that are not in use or can potentially break something.

Change History (4)

#1 @oglekler
2 months ago

  • Component GeneralEditor

This ticket was mentioned in PR #12342 on WordPress/wordpress-develop by @khokansardar.


2 months ago
#2

  • Keywords has-patch has-unit-tests added

Adds a developer hook to disable the Font Library, allowing sites to remove the feature from the admin interface. Useful for sites where fonts are managed by the theme and the ability to install fonts from the UI is not needed.

What the problem was:

  • The Font Library (admin menu item + standalone admin screen, new in 7.0) is only gated by the edit_theme_options capability, which is shared with many unrelated features and cannot be repurposed to switch the feature off.
  • There was no way for a developer to remove the Font Library from the interface for managers who hold admin rights but should not install fonts.

What the fix does:

  • Introduces wp_is_font_library_enabled() and the wp_is_font_library_enabled filter (default true).
  • When the filter returns false, the "Fonts" admin submenu item is not registered and the Font Library admin screen (font-library.php) returns a 403.
  • Adds unit tests covering the default value, disabling via filter, and boolean casting of the filtered value.

Trac ticket: https://core.trac.wordpress.org/ticket/65550

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.8
Used for: Ticket analysis and tests cases. All changes were reviewed, validated against the codebase, and are taken responsibility for by me.

#3 @wildworks
2 months ago

  • Milestone Awaiting Review
  • Resolutionreported-upstream
  • Status newclosed

I believe this issue has already been reported upstream. To avoid fragmenting the discussion, let's close this ticket.

https://github.com/WordPress/gutenberg/issues/79019

@wildworks commented on PR #12342:


2 months ago
#4

Thanks for the PR. As a pull request for this has already been submitted to the Gutenberg repository, let me close this.

https://github.com/WordPress/gutenberg/pull/79027

Note: See TracTickets for help on using tickets.