Skip to content

Commit

Permalink
Rename function. Props @swissspidy.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Mar 21, 2024
1 parent f9e41b2 commit 22764e3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/wp-includes/fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ function wp_font_dir( $create_dir = true ) {
* directly and when the upload directory is filtered in the Font Face
* REST API endpoint.
*/
add_filter( 'upload_dir', 'wp_filter_font_directory' );
add_filter( 'upload_dir', '_wp_filter_font_directory' );
$font_dir = wp_upload_dir( null, $create_dir, false );
remove_filter( 'upload_dir', 'wp_filter_font_directory' );
remove_filter( 'upload_dir', '_wp_filter_font_directory' );
return $font_dir;
}

Expand All @@ -151,7 +151,7 @@ function wp_font_dir( $create_dir = true ) {
* @param string $font_dir The font directory.
* @return string The modified font directory.
*/
function wp_filter_font_directory( $font_dir ) {
function _wp_filter_font_directory( $font_dir ) {
if ( doing_filter( 'font_dir' ) ) {
// Avoid an infinite loop.
return $font_dir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ protected function sanitize_src( $value ) {
protected function handle_font_file_upload( $file ) {
add_filter( 'upload_mimes', array( 'WP_Font_Utils', 'get_allowed_font_mime_types' ) );
// Filter the upload directory to return the fonts directory.
add_filter( 'upload_dir', 'wp_filter_font_directory' );
add_filter( 'upload_dir', '_wp_filter_font_directory' );

$overrides = array(
'upload_error_handler' => array( $this, 'handle_font_file_upload_error' ),
Expand All @@ -874,7 +874,7 @@ protected function handle_font_file_upload( $file ) {

$uploaded_file = wp_handle_upload( $file, $overrides );

remove_filter( 'upload_dir', 'wp_filter_font_directory' );
remove_filter( 'upload_dir', '_wp_filter_font_directory' );
remove_filter( 'upload_mimes', array( 'WP_Font_Utils', 'get_allowed_font_mime_types' ) );

return $uploaded_file;
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/fonts/font-library/fontLibraryHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ protected function upload_font_file( $font_filename ) {
$font_file_path = DIR_TESTDATA . '/fonts/' . $font_filename;

add_filter( 'upload_mimes', array( 'WP_Font_Utils', 'get_allowed_font_mime_types' ) );
add_filter( 'upload_dir', 'wp_filter_font_directory' );
add_filter( 'upload_dir', '_wp_filter_font_directory' );
$font_file = wp_upload_bits(
$font_filename,
null,
file_get_contents( $font_file_path )
);
remove_filter( 'upload_dir', 'wp_filter_font_directory' );
remove_filter( 'upload_dir', '_wp_filter_font_directory' );
remove_filter( 'upload_mimes', array( 'WP_Font_Utils', 'get_allowed_font_mime_types' ) );

return $font_file;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/fonts/font-library/wpFontsDir.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function test_fonts_dir_filters_do_not_trigger_infinite_loop() {
* This emulates the approach a plugin developer may take to
* add the filter when extending the font library functionality.
*/
add_filter( 'upload_dir', 'wp_filter_font_directory' );
add_filter( 'upload_dir', '_wp_filter_font_directory' );

add_filter(
'upload_dir',
Expand Down

0 comments on commit 22764e3

Please sign in to comment.