From 673ab18bfa4ad5fd1bba54856a750bb1be25fbc8 Mon Sep 17 00:00:00 2001 From: Tom Usborne Date: Tue, 30 Apr 2024 12:05:48 -0600 Subject: [PATCH] Tweak: Add Customizer support for Font Library --- inc/customizer/helpers.php | 6 +++++ .../GeneratePressFontManagerControlForm.js | 25 +++++++++++++++++++ src/customizer-controls/font-manager/utils.js | 12 +++++++++ 3 files changed, 43 insertions(+) diff --git a/inc/customizer/helpers.php b/inc/customizer/helpers.php index 70f32030..c3e8a613 100644 --- a/inc/customizer/helpers.php +++ b/inc/customizer/helpers.php @@ -370,6 +370,12 @@ function generate_do_control_inline_scripts() { 'palette' => $colors, 'showGoogleFonts' => apply_filters( 'generate_font_manager_show_google_fonts', true ), 'colorPickerShouldShift' => function_exists( 'did_filter' ), + 'gpFontLibrary' => class_exists( 'GeneratePress_Font_Library' ) + ? GeneratePress_Font_Library::get_font_families() + : array(), + 'gpFontLibraryURI' => class_exists( 'GeneratePress_Font_Library' ) + ? GeneratePress_Font_Library::get_font_library_uri() + : '', ) ); diff --git a/src/customizer-controls/font-manager/GeneratePressFontManagerControlForm.js b/src/customizer-controls/font-manager/GeneratePressFontManagerControlForm.js index d1d512ea..c78da0d1 100644 --- a/src/customizer-controls/font-manager/GeneratePressFontManagerControlForm.js +++ b/src/customizer-controls/font-manager/GeneratePressFontManagerControlForm.js @@ -104,6 +104,8 @@ const GeneratePressFontManagerControlForm = ( props ) => { } ); const fontFamilyExists = ( fontFamily ) => fonts.filter( ( font ) => font.fontFamily === fontFamily ).length > 0; + const gpFontLibrary = generateCustomizerControls.gpFontLibrary; + const gpFontLibraryURI = generateCustomizerControls.gpFontLibraryURI; return (
@@ -305,6 +307,29 @@ const GeneratePressFontManagerControlForm = ( props ) => { } ) } + { !! gpFontLibrary.length > 0 && gpFontLibrary.map( ( font, index ) => ( +
+
+ + { font.name } + + + { !! gpFontLibraryURI && ( + + + + ) } +
+
+ ) ) } +