Home > Mobile >  Warning: Undefined variable $g_fonts in
Warning: Undefined variable $g_fonts in

Time:08-25

Jevelin theme error. Maeby somebody can help with this error. theme error Code

public function get_google_font( $font ) { $fonts = $this->get_fonts();

        foreach ( $fonts['google']['items'] as $g_font ) {
            if ( $font === $g_font['family'] ) {
                return $g_font;
            }
        }
    
    return false;
}

CodePudding user response:

It seems the $fonts variable is empty. Could you try to do this:

public function get_google_font($font) {

    $fonts = $this->get_fonts();

    if (!empty($fonts)) {
        foreach ($fonts['google']['items'] as $g_font) {
            if ($font === $g_font['family']) {
                return $g_font;
            }
        }
    }
}

CodePudding user response:

Can you check the error from website roaylwebservice.com Here is the general.php code. Error starts from line "foreach"

function fw_get_google_fonts() { $cache_key = 'fw_google_fonts';

try {
    return FW_Cache::get( $cache_key );
} catch ( FW_Cache_Not_Found_Exception $e ) {
    $g_fonts   = json_decode( fw_get_google_fonts_v2(), true );
    $old_fonts = include( dirname( __FILE__ ) . '/fw-google-fonts.json.php' );
    $fonts     = array();

    foreach ( $g_fonts['items'] as $font ) {
        $fonts[ $font['family'] ] = array(
            'family'   => $font['family'],
            'variants' => $font['variants'],
            'position' => isset( $old_fonts[ $font['family'] ] )
                ? $old_fonts[ $font['family'] ]['position']
                : 99999
        );
    }

    $fonts = apply_filters( 'fw_google_fonts', $fonts );

    FW_Cache::set( $cache_key, $fonts );

    return $fonts;
}

}

  • Related