Skip to content

Commit

Permalink
Font Library: disable font library UI using a PHP filter (#57818)
Browse files Browse the repository at this point in the history
* disable font library UI

Co-authored-by: Jeff Ong <5375500+jffng@users.noreply.github.com>

* remove php code no longer used

Co-authored-by: Jeff Ong <5375500+jffng@users.noreply.github.com>

---------

Co-authored-by: Jeff Ong <5375500+jffng@users.noreply.github.com>
  • Loading branch information
matiasbenedetto and jffng authored Jan 12, 2024
1 parent 0e48342 commit 203ca9e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
9 changes: 0 additions & 9 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,6 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-web-fonts.php';
} elseif ( ! class_exists( 'WP_Fonts' ) ) {

// Disables the Font Library.
// @core-merge: this should not go to core.
add_action(
'enqueue_block_editor_assets',
function () {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalDisableFontLibrary = true', 'before' );
}
);

// Turns off Font Face hooks in Core.
// @since 6.4.0.
remove_action( 'wp_head', 'wp_print_font_faces', 50 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*/
import { __ } from '@wordpress/i18n';
import { __experimentalVStack as VStack } from '@wordpress/components';
import { store as editorStore } from '@wordpress/editor';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -12,6 +14,12 @@ import FontFamilies from './font-families';
import ScreenHeader from './header';

function ScreenTypography() {
const fontLibraryEnabled = useSelect(
( select ) =>
select( editorStore ).getEditorSettings().fontLibraryEnabled,
[]
);

return (
<>
<ScreenHeader
Expand All @@ -22,9 +30,7 @@ function ScreenTypography() {
/>
<div className="edit-site-global-styles-screen-typography">
<VStack spacing={ 6 }>
{ ! window.__experimentalDisableFontLibrary && (
<FontFamilies />
) }
{ fontLibraryEnabled && <FontFamilies /> }
<TypographyElements />
</VStack>
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/store/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SETTINGS_DEFAULTS } from '@wordpress/block-editor';
* @property {boolean} richEditingEnabled Whether rich editing is enabled or not
* @property {boolean} codeEditingEnabled Whether code editing is enabled or not
* @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
* @property {boolean} fontLibraryEnabled Whether the font library is enabled or not.

This comment has been minimized.

Copy link
@creativecoder

creativecoder Jan 12, 2024

Contributor

Looks like this line needs to be moved down, to just above * @property {number} autosaveInterval, so it doesn't break up the enableCustomFields description.

This comment has been minimized.

Copy link
@creativecoder

This comment has been minimized.

Copy link
@matiasbenedetto

matiasbenedetto Jan 12, 2024

Author Contributor

Thanks for noticing that. PR with the fix #57820

* true = the user has opted to show the Custom Fields panel at the bottom of the editor.
* false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
* undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
Expand All @@ -27,5 +28,6 @@ export const EDITOR_SETTINGS_DEFAULTS = {
richEditingEnabled: true,
codeEditingEnabled: true,
enableCustomFields: undefined,
fontLibraryEnabled: true,
defaultRenderingMode: 'post-only',
};

0 comments on commit 203ca9e

Please sign in to comment.