Skip to content

Commit

Permalink
Relocates Font Face & Fonts Library to fonts dir (#53747)
Browse files Browse the repository at this point in the history
Relocates the PHP files for Font Face and Fonts Library into`lib/experimental/fonts/`.

Why?
To align the directory structure with Core.

Font Face and Fonts Library are both part of fonts management. WordPress Core has an existing `wp-includes/fonts/` directory. The `lib/experimental/fonts/` directory was intended to align to Core's fonts directory.
  • Loading branch information
hellofromtonya authored Aug 16, 2023
1 parent e29c0da commit c14792d
Show file tree
Hide file tree
Showing 40 changed files with 33 additions and 63 deletions.
File renamed without changes.
40 changes: 20 additions & 20 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,30 @@ function gutenberg_is_experiment_enabled( $name ) {
*/
if ( defined( 'FONTS_LIBRARY_ENABLE' ) && FONTS_LIBRARY_ENABLE ) {
// Loads the Fonts Library.
require __DIR__ . '/experimental/fonts-library/class-wp-fonts-library.php';
require __DIR__ . '/experimental/fonts-library/class-wp-font-family-utils.php';
require __DIR__ . '/experimental/fonts-library/class-wp-font-family.php';
require __DIR__ . '/experimental/fonts-library/class-wp-rest-fonts-library-controller.php';
require __DIR__ . '/experimental/fonts-library/fonts-library.php';
require __DIR__ . '/experimental/fonts/fonts-library/class-wp-fonts-library.php';
require __DIR__ . '/experimental/fonts/fonts-library/class-wp-font-family-utils.php';
require __DIR__ . '/experimental/fonts/fonts-library/class-wp-font-family.php';
require __DIR__ . '/experimental/fonts/fonts-library/class-wp-rest-fonts-library-controller.php';
require __DIR__ . '/experimental/fonts/fonts-library/fonts-library.php';

if ( ! class_exists( 'WP_Font_Face' ) ) {
require __DIR__ . '/experimental/fonts/class-wp-font-face.php';
require __DIR__ . '/experimental/fonts/class-wp-font-face-resolver.php';
require __DIR__ . '/experimental/fonts/fonts.php';
require __DIR__ . '/experimental/fonts/font-face/class-wp-font-face.php';
require __DIR__ . '/experimental/fonts/font-face/class-wp-font-face-resolver.php';
require __DIR__ . '/experimental/fonts/font-face/fonts.php';

// Load the BC Layer. Do no backport to WP Core.
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-fonts-provider.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-fonts-utils.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-fonts.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-fonts-provider-local.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-fonts-resolver.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-gutenberg-fonts-api-bc-layer.php';
require __DIR__ . '/experimental/fonts/bc-layer/webfonts-deprecations.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-webfonts-utils.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-webfonts-provider.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-webfonts-provider-local.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-webfonts.php';
require __DIR__ . '/experimental/fonts/bc-layer/class-wp-web-fonts.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-fonts-provider.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-fonts-utils.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-fonts.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-fonts-provider-local.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-fonts-resolver.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-gutenberg-fonts-api-bc-layer.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/webfonts-deprecations.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-webfonts-utils.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-webfonts-provider.php';
require __DIR__ . '/experimental/fonts/font-face/bc-layer/class-wp-webfonts-provider-local.php';
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' ) ) {
// Fonts API files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function set_up_before_class() {
parent::set_up_before_class();

if ( self::$requires_switch_theme_fixtures ) {
self::$theme_root = realpath( __DIR__ . '/../data/themedir1' );
self::$theme_root = realpath( __DIR__ . '/../../data/themedir1' );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@

require_once __DIR__ . '/../wp-font-face-tests-dataset.php';

/*
* This code is only needed if the Font API is enabled.
* @todo remove this code when Font Library is merged into Gutenberg.
*/
if ( ! class_exists( 'WP_Font_Face' ) ) {
require_once __DIR__ . '/../../../lib/experimental/fonts/class-wp-font-face.php';
require_once __DIR__ . '/../../../lib/experimental/fonts/class-wp-font-face-resolver.php';
require_once __DIR__ . '/../../../lib/experimental/fonts/fonts.php';
}

/**
* Test WP_Font_Face::generate_and_print().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@

require_once __DIR__ . '/../wp-font-face-testcase.php';

/*
* This code is only needed if the Font API is enabled.
* @todo remove this code when Font Library is merged into Gutenberg.
*/
if ( ! class_exists( 'WP_Font_Face' ) ) {
require_once __DIR__ . '/../../../lib/experimental/fonts/class-wp-font-face.php';
require_once __DIR__ . '/../../../lib/experimental/fonts/class-wp-font-face-resolver.php';
require_once __DIR__ . '/../../../lib/experimental/fonts/fonts.php';
}

/**
* Tests WP_Font_Face_Resolver::get_fonts_from_theme_json().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@

require_once __DIR__ . '/wp-font-face-testcase.php';

/*
* This code is only needed if the Font API is enabled.
* @todo remove this code when Font Library is merged into Gutenberg.
*/
if ( ! class_exists( 'WP_Font_Face' ) ) {
require_once __DIR__ . '/../../../lib/experimental/fonts/class-wp-font-face.php';
require_once __DIR__ . '/../../../lib/experimental/fonts/class-wp-font-face-resolver.php';
require_once __DIR__ . '/../../../lib/experimental/fonts/fonts.php';
}

/**
* Test wp_print_font_faces().
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers WP_Font_Family::__construct
*/
class Tests_FontsLibrary_WpFontFamily_Construct extends WP_UnitTestCase {
class Tests_Fonts_WpFontFamily_Construct extends WP_UnitTestCase {

public function test_should_initialize_data() {
$property = new ReflectionProperty( WP_Font_Family::class, 'data' );
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers WP_Font_Family::get_data
*/
class Tests_FontsLibrary_WpFontsLibrary_GetData extends WP_UnitTestCase {
class Tests_Fonts_WpFontsLibrary_GetData extends WP_UnitTestCase {

/**
* @dataProvider data_should_get_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers WP_Font_Family::get_data_as_json
*/
class Tests_FontsLibrary_WpFontFamily_GetDataAsJson extends WP_UnitTestCase {
class Tests_Fonts_WpFontFamily_GetDataAsJson extends WP_UnitTestCase {

/**
* @dataProvider data_should_get_data_as_json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @covers WP_Font_Family::get_font_post
*/
class Tests_FontsLibrary_WpFontFamily_GetFontPost extends WP_Font_Family_UnitTestCase {
class Tests_Fonts_WpFontFamily_GetFontPost extends WP_Font_Family_UnitTestCase {

public function test_should_return_post() {
// Set up the post.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers WP_Font_Family::has_font_faces
*/
class Tests_FontsLibrary_WpFontFamily_HasFontFaces extends WP_UnitTestCase {
class Tests_Fonts_WpFontFamily_HasFontFaces extends WP_UnitTestCase {

public function test_should_return_true_when_check_succeeds() {
$font_data = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @covers WP_Font_Family::install
*/
class Tests_FontsLibrary_WpFontFamily_Install extends WP_Font_Family_UnitTestCase {
class Tests_Fonts_WpFontFamily_Install extends WP_Font_Family_UnitTestCase {

/**
* @dataProvider data_should_not_download_when_no_fontface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @covers WP_Font_Family::uninstall
*/
class Tests_FontsLibrary_WpFontFamily_Uninstall extends WP_Font_Family_UnitTestCase {
class Tests_Fonts_WpFontFamily_Uninstall extends WP_Font_Family_UnitTestCase {

public function test_should_return_error_when_font_not_found() {
// Set up.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers WP_Font_Family_Utils::get_filename_from_font_face
*/
class Tests_FontsLibrary_WpFontsFamilyUtils_GetFilenameFromFontFace extends WP_UnitTestCase {
class Tests_Fonts_WpFontsFamilyUtils_GetFilenameFromFontFace extends WP_UnitTestCase {

/**
* @dataProvider data_should_get_filename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers WP_Font_Family_Utils::has_font_mime_type
*/
class Tests_FontsLibrary_WpFontsFamilyUtils_HasFontMimeType extends WP_UnitTestCase {
class Tests_Fonts_WpFontsFamilyUtils_HasFontMimeType extends WP_UnitTestCase {

/**
* @dataProvider data_should_succeed_when_has_mime_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers WP_Font_Family_Utils::merge_fonts_data
*/
class Tests_FontsLibrary_WpFontsFamilyUtils_MergeFontsData extends WP_UnitTestCase {
class Tests_Fonts_WpFontsFamilyUtils_MergeFontsData extends WP_UnitTestCase {

/**
* @dataProvider data_should_fail_merge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers WP_Fonts_Library::get_fonts_dir
*/
class Tests_FontsLibrary_WpFontsLibrary_GetFontsDir extends WP_UnitTestCase {
class Tests_Fonts_WpFontsLibrary_GetFontsDir extends WP_UnitTestCase {

public function test_get_fonts_dir() {
$this->assertStringEndsWith( '/wp-content/uploads/fonts', WP_Fonts_Library::get_fonts_dir() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @covers WP_Fonts_Library::set_upload_dir
*/
class Tests_FontsLibrary_WpFontsLibrary_SetUploadDir extends WP_UnitTestCase {
class Tests_Fonts_WpFontsLibrary_SetUploadDir extends WP_UnitTestCase {

public function test_should_set_fonts_upload_dir() {
$defaults = array(
Expand Down

0 comments on commit c14792d

Please sign in to comment.