error: custom-fonts/classes/class-bsf-custom-fonts-render.php?on line?194
-
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:
- I added a check to see if
$value['font_fallback']
exists and is not null usingisset()
:
php code:
if ( isset( $value['font_fallback'] ) && $value['font_fallback'] ) {
- 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.
- I added a check to see if
- You must be logged in to reply to this review.