• in lines 194 of following path, there was a problem …

    In the provided code snippet, the issue was occurring in the remove_custom_font_google_url method. This method is responsible for removing custom fonts from the Google fonts URL array.

    The problem was with the line:

    php code:

    if ( $value['font_fallback'] ) {

    Here, the code was trying to access the font_fallback index of $value directly without ensuring that $value['font_fallback'] exists and is not null. This could lead to issues if $value['font_fallback'] is not set.

    To fix this, I made the following changes:

    1. I added a check to see if $value['font_fallback'] exists and is not null using isset():

    php code:

    if ( isset( $value['font_fallback'] ) && $value['font_fallback'] ) {

    1. If $value['font_fallback'] exists and is not null, then $value['font_fallback'] is appended to $font_key. Otherwise, $font_key remains the same.

    By adding this check, we ensure that the code doesn’t try to access an undefined index, which could lead to the “Trying to access array offset on value of type bool” warning. Instead, it first checks if the index exists before attempting to access it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter revayatejahad

    (@revayatejahad)

    this is the replacement of that public function and worked fine for me:

    public function remove_custom_font_google_url( $fonts ) {
        $custom_fonts = Bsf_Custom_Fonts_Taxonomy::get_fonts();
        if ( ! empty( $custom_fonts ) ) {
            foreach ( $custom_fonts as $key => $value ) {
                $font_key = "'" . $key . "'";
                if ( isset( $value['font_fallback'] ) && $value['font_fallback'] ) {
                    $font_key .= ', ' . $value['font_fallback'];
                }
                if ( array_key_exists( $font_key, $fonts ) ) {
                    unset( $fonts[ $font_key ] );
                }
            }
        }
        return $fonts;
    }
    Plugin Support Herman Asrori (BSF)

    (@bsfherman)

    Hi @revayatejahad,

    Would you please raise a PR on our GitHub?

    We really appreciate your contributions and review!

    Kind regards,
    Herman ??

    hello my friend
    I also had this problem
    To solve the problem, just add at least one alternative font wherever you use the desired font, like the following code:

    font-family:"iran sans normal", Helvetica, Arial, sans-serif;

    The first font is my favorite font, and then I added some Google fonts

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this review.