webfonts = $webfonts; $this->googlefonts = $googlefonts; add_action( 'wp_footer', array( $this, 'add_styles' ) ); add_action( 'admin_footer', array( $this, 'add_styles' ) ); } /** * Webfont Loader for Google Fonts. * * @access public * @since 3.0.28 */ public function add_styles() { // Go through our fields and populate $this->fonts. $this->webfonts->loop_fields( $this->config_id ); $this->googlefonts->process_fonts(); $hosted_fonts = $this->googlefonts->get_hosted_fonts(); // Early exit if we don't need to add any fonts. if ( empty( $hosted_fonts ) ) { return; } // Make sure we only do this once per font-family. $hosted_fonts = array_unique( $hosted_fonts ); // Start CSS. $css = ''; foreach ( $hosted_fonts as $family ) { // Add the @font-face CSS for this font-family. $css .= Kirki_Fonts_Google_Local::init( $family )->get_css(); } // If we've got CSS, add to the footer. if ( $css ) { echo ''; // WPCS: XSS ok. } } }