From 63cc195ee0d2371b8efb82f908593a763c6e986c Mon Sep 17 00:00:00 2001 From: Matias Benedetto Date: Fri, 26 Apr 2024 12:47:41 -0300 Subject: [PATCH 1/3] fix custom fonts assets path --- admin/create-theme/theme-zip.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/admin/create-theme/theme-zip.php b/admin/create-theme/theme-zip.php index 3ba3fb03..629da5bb 100644 --- a/admin/create-theme/theme-zip.php +++ b/admin/create-theme/theme-zip.php @@ -34,7 +34,7 @@ public static function add_activated_fonts_to_zip( $zip, $theme_json_string ) { $theme_json = json_decode( $theme_json_string, true ); $font_families_to_copy = Theme_Fonts::get_user_activated_fonts(); - $theme_font_asset_location = '/assets/fonts/'; + $theme_font_asset_location = 'assets/fonts'; $font_slugs_to_remove = array(); if ( ! $font_families_to_copy ) { @@ -47,14 +47,15 @@ public static function add_activated_fonts_to_zip( $zip, $theme_json_string ) { } $font_slugs_to_remove[] = $font_family['slug']; foreach ( $font_family['fontFace'] as &$font_face ) { - $font_filename = basename( $font_face['src'] ); - $font_dir = wp_get_font_dir(); + $font_filename = basename( $font_face['src'] ); + $font_dir = wp_get_font_dir(); + $font_face_path = path_join( $theme_font_asset_location, $font_filename ); if ( str_contains( $font_face['src'], $font_dir['url'] ) ) { - $zip->addFileToTheme( $font_dir['path'] . '/' . $font_filename, $theme_font_asset_location . '/' . $font_filename ); + $zip->addFileToTheme( $font_dir['path'] . '/' . $font_filename, $font_face_path ); } else { // otherwise download it from wherever it is hosted $tmp_file = download_url( $font_face['src'] ); - $zip->addFileToTheme( $tmp_file, $theme_font_asset_location . '/' . $font_filename ); + $zip->addFileToTheme( $tmp_file, $font_face_path ); unlink( $tmp_file ); } From 418421833fa5da7ce9e4208d26f72a2bbb984391 Mon Sep 17 00:00:00 2001 From: Matias Benedetto Date: Tue, 30 Apr 2024 13:25:11 -0300 Subject: [PATCH 2/3] improve syntax --- admin/create-theme/theme-zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/create-theme/theme-zip.php b/admin/create-theme/theme-zip.php index 629da5bb..d856af5d 100644 --- a/admin/create-theme/theme-zip.php +++ b/admin/create-theme/theme-zip.php @@ -51,7 +51,7 @@ public static function add_activated_fonts_to_zip( $zip, $theme_json_string ) { $font_dir = wp_get_font_dir(); $font_face_path = path_join( $theme_font_asset_location, $font_filename ); if ( str_contains( $font_face['src'], $font_dir['url'] ) ) { - $zip->addFileToTheme( $font_dir['path'] . '/' . $font_filename, $font_face_path ); + $zip->addFileToTheme( path_join( $font_dir['path'], $font_filename ), $font_face_path ); } else { // otherwise download it from wherever it is hosted $tmp_file = download_url( $font_face['src'] ); From 78675bf71902d2fab2c950e33f8a1233e5671c33 Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Tue, 30 Apr 2024 12:25:16 -0400 Subject: [PATCH 3/3] Update admin/create-theme/theme-zip.php Co-authored-by: Vicente Canales <1157901+vcanales@users.noreply.github.com> --- admin/create-theme/theme-zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/create-theme/theme-zip.php b/admin/create-theme/theme-zip.php index 629da5bb..d856af5d 100644 --- a/admin/create-theme/theme-zip.php +++ b/admin/create-theme/theme-zip.php @@ -51,7 +51,7 @@ public static function add_activated_fonts_to_zip( $zip, $theme_json_string ) { $font_dir = wp_get_font_dir(); $font_face_path = path_join( $theme_font_asset_location, $font_filename ); if ( str_contains( $font_face['src'], $font_dir['url'] ) ) { - $zip->addFileToTheme( $font_dir['path'] . '/' . $font_filename, $font_face_path ); + $zip->addFileToTheme( path_join( $font_dir['path'], $font_filename ), $font_face_path ); } else { // otherwise download it from wherever it is hosted $tmp_file = download_url( $font_face['src'] );