WordPress.org

WordPress Developer Blog

Snippet: How to disable the Font Library

Snippet: How to disable the Font Library

As a theme author, I often want tight control over typography options to offer users a curated set of fonts that work well for the theme. One of the first things I do is disable the Font Library in WordPress, ensuring that only the typesets I specifically chose are available to users. This completely disables the user’s ability to upload or manage custom fonts.

Whether it’s for a client site or a publicly distributed project, you might run into a similar scenario when designing a theme. To disable the Font Library, you can filter block_editor_settings_all and set the fontLibraryEnabled argument to false by adding this code to your theme’s functions.php file:

add_filter( 'block_editor_settings_all', 'devblog_block_editor_settings' );

function devblog_block_editor_settings( $settings ) {
	$settings['fontLibraryEnabled'] = false;

	return $settings;
}

Check out 15 ways to curate the WordPress editing experience for more techniques to customize the Editor.

Props to @psykro and @welcher for feedback and review.

Leave a Reply

Your email address will not be published. Required fields are marked *