wp-google-font-picker-control
wp-google-font-picker-control copied to clipboard
Not quite working for me.
Hey Patrick, So I gave this a try. Installed the plugin and added the code to the functions.php file and I do not see the control/setting/section for the fonts in the customizer. I just copied and pasted what you had. What might I be missing here?
Thanks and happy T-day
Hi @digisavvy I just don't have to time to pursue this at the moment. Writing a book and maintaining some premium plugins takes up all my time. I'm sorry but I can't figure out why it's not working for you. :(
I'll leave this issue open incase anyone else can look into it.
You should add a setting so it can work.
## Hi, I have added the following in my functions.php after activating the plugin.
`function mytheme_fontsettings( $wp_customize ) { $wp_customize->add_section('mytheme_new_section_fonts', array( 'title' => esc_html__('Fonts', 'mytheme'), 'priority' => 30, ));
$wp_customize->add_setting( 'font_family', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ));
if (class_exists('Google_Font_Picker_Custom_Control')){ $wp_customize->add_control( new Google_Font_Picker_Custom_Control( $wp_customize, 'font_family_control', array( 'label' => __( 'Font Family', 'mytheme' ), 'section' => 'mytheme_new_section_fonts', 'settings' => 'font_family', 'choices' => $customFontFamilies->getFontFamilyNameArray(), 'fonts' => $customFontFamilies ))); } } add_action( 'customize_register', 'mytheme_fontsettings' );`
## and my fonts array is:
` $customFontFamilies; if (class_exists('Google_Font_Collection')) { $fonts[] = array( "title" => "Ubuntu Condensed", "location" => "Ubuntu+Condensed", "cssDeclaration" => "'Ubuntu Condensed', sans-serif", "cssClass" => "ubuntuCondensed", "title" => "Oswald", "location" => "Oswald", "cssDeclaration" => "'Oswald', sans-serif", "cssClass" => "Oswald" );
$customFontFamilies = new Google_Font_Collection($fonts);
}`
## and I'm getting the following error:
Fatal error: Uncaught Error: Call to a member function getFontFamilyNameArray() on null in C:\xampp\htdocs\appm\wp-content\themes\mytheme\functions.php:223
===================