diff --git a/inc/fonts.php b/inc/fonts.php index ba28f0d..68b4984 100644 --- a/inc/fonts.php +++ b/inc/fonts.php @@ -7,16 +7,6 @@ namespace Pantheon\Fonts; -/** - * Store the value of wp_get_upload_dir() in a global variable. - * This is to resolve an infinite loop when wp_get_upload_dir is used inside - * our filter of font_dir (because upload_dir is also being filtered). - * - * @var array $wp_upload_dir The value of wp_get_upload_dir(). - * @see https://developer.wordpress.org/reference/functions/wp_get_upload_dir/ - */ -$_pantheon_upload_dir = wp_get_upload_dir(); // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - /** * Kick off our customizations to the WP_Font_Library. */ @@ -33,10 +23,11 @@ function bootstrap() { * @param array $defaults The default settings for the font directory. */ function pantheon_font_dir( $defaults ) { - global $_pantheon_upload_dir; + $upload_dir = wp_get_upload_dir(); + // Set our font directory. - $font_dir = $_pantheon_upload_dir['basedir'] . '/fonts'; - $font_url = $_pantheon_upload_dir['baseurl'] . '/fonts'; + $font_dir = $upload_dir['basedir'] . '/fonts'; + $font_url = $upload_dir['baseurl'] . '/fonts'; $defaults['path'] = $font_dir; $defaults['url'] = $font_url;