Home / Disable WordPress 6.5 Font Library
Duplicate Snippet

Embed Snippet on Your Site

Disable WordPress 6.5 Font Library

Deactivate the font library feature added in WordPress 6.5.

200+
Code Preview
php
<?php
add_filter( 'block_editor_settings_all', function( $editor_settings ) {
	$editor_settings['fontLibraryEnabled'] = false;
   	return $editor_settings; 
} );
// Disable the REST API for the font library.
add_filter( 'register_post_type_args', function( $arg, $post_type ) {
	if ( 'wp_font_family' === $post_type || 'wp_font_face' === $post_type ) {
		$arg['show_in_rest'] = false;
	}
	return $arg;
}, 10, 2 );
add_filter( 'rest_endpoints', function( $endpoints ) {
	foreach ( $endpoints as $route => $endpoint ){
		if ( str_starts_with( $route, '/wp/v2/font-collections' ) ) {
			unset( $endpoints[ $route ] );
		}
	}
	return $endpoints;
} );

Comments

Add a Comment