Skip to content

Commit

Permalink
Revert "WP 6.5 Font Library: Filter the font directory to work with t…
Browse files Browse the repository at this point in the history
…he VIP Filesystem (#5265)"

This reverts commit a0b1c87.
  • Loading branch information
noahtallen committed Apr 2, 2024
1 parent 5dcdedd commit efcb620
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 37 deletions.
16 changes: 0 additions & 16 deletions files/class-vip-filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ private function add_filters() {
add_filter( 'get_attached_file', [ $this, 'filter_get_attached_file' ], 20 );
add_filter( 'wp_generate_attachment_metadata', [ $this, 'filter_wp_generate_attachment_metadata' ], 10, 2 );
add_filter( 'wp_read_image_metadata', [ $this, 'filter_wp_read_image_metadata' ], 10, 2 );
add_filter( 'font_dir', [ $this, 'filter_wp_font_dir' ], 10, 1 );

/**
* The core's function recurse_dirsize would call to opendir() which is not supported by the
Expand All @@ -125,7 +124,6 @@ private function remove_filters() {
remove_filter( 'get_attached_file', [ $this, 'filter_get_attached_file' ], 20 );
remove_filter( 'wp_generate_attachment_metadata', [ $this, 'filter_wp_generate_attachment_metadata' ] );
remove_filter( 'wp_read_image_metadata', [ $this, 'filter_wp_read_image_metadata' ], 10, 2 );
remove_filter( 'font_dir', [ $this, 'filter_wp_font_dir' ], 10, 1 );
remove_filter( 'pre_recurse_dirsize', '__return_zero' );
}

Expand Down Expand Up @@ -463,18 +461,4 @@ public function filter_wp_read_image_metadata( $meta, $file ) {

return $meta;
}

/**
* Changes the Font Library directory to work with the VIP Filesystem.
*/
public function filter_wp_font_dir( $defaults ) {
$upload_dir = wp_upload_dir();

$defaults['basedir'] = $upload_dir['basedir'] . '/fonts';
$defaults['baseurl'] = $upload_dir['baseurl'] . '/fonts';
$defaults['path'] = $defaults['basedir'];
$defaults['url'] = $defaults['baseurl'];

return $defaults;
}
}
23 changes: 2 additions & 21 deletions tests/files/test-vip-filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class VIP_Filesystem_Test extends WP_UnitTestCase {

public static function configure_constant_mocker(): void {
Constant_Mocker::clear();
define( 'LOCAL_UPLOADS', '/tmp/uploads' );
define( 'WP_CONTENT_DIR', '/tmp/wordpress/wp-content' );
define( 'LOCAL_UPLOADS', '/wp/uploads' );
define( 'WP_CONTENT_DIR', '/wp/wordpress/wp-content' );
}

public function setUp(): void {
Expand Down Expand Up @@ -386,23 +386,4 @@ public function data_get_transport_for_path(): iterable {
[ constant( 'WP_CONTENT_DIR' ) . '/languages/test.txt', 'direct' ],
];
}

public function test_wp_font_dir() {
// Only available in WP 6.5 and newer:
if ( ! function_exists( '\wp_get_font_dir' ) ) {
$this->markTestSkipped( 'test_wp_font_dir does not need to run for WP < 6.5.' );
return;
}

$font_dir = \wp_get_font_dir();

$this->assertEquals( $font_dir, [
'path' => 'vip://wp-content/uploads/fonts',
'basedir' => 'vip://wp-content/uploads/fonts',
'url' => 'http://example.org/wp-content/uploads/fonts',
'baseurl' => 'http://example.org/wp-content/uploads/fonts',
'subdir' => '',
'error' => false,
] );
}
}

0 comments on commit efcb620

Please sign in to comment.