Skip to content

Commit

Permalink
Font Face & Library: load files if ! class_exists (#54103)
Browse files Browse the repository at this point in the history
Prevents Font Face and Font Library PHP files from loading into memory if each main class already exists in memory (i.e. meaning already in WordPress Core).
  • Loading branch information
hellofromtonya authored Sep 1, 2023
1 parent e2941e9 commit c2d1300
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,21 @@ function gutenberg_is_experiment_enabled( $name ) {
( defined( 'FONTS_LIBRARY_ENABLE' ) && FONTS_LIBRARY_ENABLE )
) {
// Loads the Font Library.
require __DIR__ . '/experimental/fonts/font-library/class-wp-font-collection.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-font-library.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-font-family-utils.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-font-family.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-font-library-controller.php';
require __DIR__ . '/experimental/fonts/font-library/font-library.php';
if ( ! class_exists( 'WP_Font_Library' ) ) {
require __DIR__ . '/experimental/fonts/font-library/class-wp-font-collection.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-font-library.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-font-family-utils.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-font-family.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-font-library-controller.php';
require __DIR__ . '/experimental/fonts/font-library/font-library.php';
}

// Load the Font Face.
require __DIR__ . '/compat/wordpress-6.4/fonts/font-face/class-wp-font-face.php';
require __DIR__ . '/compat/wordpress-6.4/fonts/font-face/class-wp-font-face-resolver.php';

// A general purpose file for all fonts PHP functions and hooks.
require __DIR__ . '/compat/wordpress-6.4/fonts/fonts.php';
if ( ! class_exists( 'WP_Font_Face' ) ) {
require __DIR__ . '/compat/wordpress-6.4/fonts/font-face/class-wp-font-face.php';
require __DIR__ . '/compat/wordpress-6.4/fonts/font-face/class-wp-font-face-resolver.php';
require __DIR__ . '/compat/wordpress-6.4/fonts/fonts.php';
}

// Load the BC Layer to avoid fatal errors of extenders using the Fonts API.
// @core-merge: do not merge the BC layer files into WordPress Core.
Expand Down

0 comments on commit c2d1300

Please sign in to comment.