Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font Library: Refactor logic to disable font library in the frontend. #54748

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/experimental/fonts/font-library/font-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ function wp_register_font_collection( $config ) {
}
}

add_action(
'enqueue_block_editor_assets',
function () {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalFontLibrary = true', 'before' );
}
);

$default_font_collection = array(
'id' => 'default-font-collection',
Expand Down
10 changes: 10 additions & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-webfonts.php';
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 @@ -22,7 +22,9 @@ function ScreenTypography() {
/>
<div className="edit-site-global-styles-screen-typography">
<VStack spacing={ 6 }>
{ window.__experimentalFontLibrary && <FontFamilies /> }
{ ! window.__experimentalDisableFontLibrary && (
<FontFamilies />
) }
<TypographyElements />
</VStack>
</div>
Expand Down
Loading