Error In Wordpress On All Pages Just Below The Header (Using Theme elumine)

Stack Overflow Asked by Pallav on November 10, 2020

The error is in below lines of the addressed file below (Line 186 & 187):

Website (Live):

Tried restoring an earlier back-up(24 hours back), but that didn’t work also.

Line 186 & 187 from source line:

$collections = get_option('google_typography_collections');
$google_fonts_all = $this->get_fonts();
$import_fonts = array();
if ($collections) {
    foreach ($collections as $collection) {
        $font_family = $collection['font_family'];
        $font_index = array_search($font_family,
                              array_column($google_fonts_all,'family'));//Line 186
        $font_variants = implode(',', $google_fonts_all[$font_index ['variants']); //Line 187
                        'font_family' => $collection['font_family'],
                        'font_variant' => $font_variants,

Error Messages (On All Pages Of Website, these are just few of the lines):

content/themes/elumine/includes/integrations/google-typography/google-typography.php on line 186

Warning: array_search() expects parameter 2 to be array, null given in /home/customer/www/ on line 186

Warning: Illegal string offset 'variants' in /home/customer/www/ on line 187

Warning: implode(): Invalid arguments passed in /home/customer/www/ on line 187

2 Answers

Wisdom Labs has posted a patch to fix the problem.

Answered by Gary Theilman on November 10, 2020

You are getting the errors because on line 186 the $google_fonts_all either does not contain an array with 'family' key or it is not an array. In either case the expression, array_column($google_fonts_all, 'family'), returns empty.

You can extract the later expression into a variable: $family = array_column((array)$google_fonts_all, 'family');

On the line 187, check for the isset( $google_fonts_all[$font_index]['variants'] ) either in a conditional statement or itenary.

Regards Eliasu

Answered by Eliasu on November 10, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP