Skip to content

Commit

Permalink
remove our global for the upload_dir infinite loop (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence authored Mar 4, 2024
1 parent 6f799a5 commit 8898aab
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions inc/fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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;
Expand Down

0 comments on commit 8898aab

Please sign in to comment.