From f14d8b826b32a3ca9fc55296289355de4d3c7d0b Mon Sep 17 00:00:00 2001 From: Khaled Abu Alqomboz Date: Tue, 22 Feb 2022 18:24:06 +0200 Subject: [PATCH] Adds an option to set a custom directory for the fonts folder. --- .../module-webfonts/src/Webfonts/Downloader.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/kirki-framework/module-webfonts/src/Webfonts/Downloader.php b/packages/kirki-framework/module-webfonts/src/Webfonts/Downloader.php index 2b94a0d9c..46804a789 100644 --- a/packages/kirki-framework/module-webfonts/src/Webfonts/Downloader.php +++ b/packages/kirki-framework/module-webfonts/src/Webfonts/Downloader.php @@ -68,15 +68,21 @@ protected function get_local_files_from_css( $css ) { $stored = get_option( 'kirki_downloaded_font_files', array() ); $change = false; // If in the end this is true, we need to update the cache option. + $fonts_dir = WP_CONTENT_DIR . '/fonts'; + + if ( defined( 'KIRKI_FONTS_DIR' ) && ! empty( KIRKI_FONTS_DIR ) ) { + $fonts_dir = KIRKI_FONTS_DIR; + } + // If the fonts folder don't exist, create it. - if ( ! file_exists( WP_CONTENT_DIR . '/fonts' ) ) { - $this->get_filesystem()->mkdir( WP_CONTENT_DIR . '/fonts', FS_CHMOD_DIR ); + if ( ! file_exists( $fonts_dir ) ) { + $this->get_filesystem()->mkdir( $fonts_dir, FS_CHMOD_DIR ); } foreach ( $font_files as $font_family => $files ) { // The folder path for this font-family. - $folder_path = WP_CONTENT_DIR . '/fonts/' . $font_family; + $folder_path = $fonts_dir . '/' . $font_family; // If the folder doesn't exist, create it. if ( ! file_exists( $folder_path ) ) {