ThemeFuse / Unyson

A WordPress framework that facilitates the development of WP themes
http://unyson.io
923 stars 219 forks source link

Warning: Invalid argument supplied for foreach() in /home/customer/www/digitalmarketingevolutions.com/public_html/wp-content/plugins/unyson/framework/includes/option-types/typography-v2/class-fw-option-type-typography-v2.php on line 148 Warning: Invalid argument supplied for foreach() in /home/customer/www/digitalmarketingevolutions.com/public_html/wp-content/plugins/unyson/framework/includes/option-types/typography-v2/class-fw-option-type-typography-v2.php on line 148 #4261

Open DigitalMarketingEvolutions opened 1 year ago

DigitalMarketingEvolutions commented 1 year ago

How to remove this? I already updated unyson but still there. image

Tom2710 commented 1 year ago

Same problem

DBrthinfo commented 1 year ago

Same problem since this weekend. Mine is Warning: Invalid argument supplied for foreach() in /home/customer/www/doulaschool.ca/public_html/wp-content/plugins/unyson/framework/helpers/general.php on line 1275

wingedangeldawn commented 1 year ago

Same issue.

Warning: Invalid argument supplied for foreach() in /home/customer/www/afexsystems.com/public_html/wp-content/plugins/unyson/framework/includes/option-types/typography-v2/class-fw-option-type-typography-v2.php on line 148

Warning: Invalid argument supplied for foreach() in /home/customer/www/afexsystems.com/public_html/wp-content/plugins/unyson/framework/helpers/general.php on line 1275

IamOri commented 1 year ago

Same problem here. Looks like Google Fonts API key is invalid on unyson cache site. Tried to generate my own api key and change url directly to google, but it looks like the old response is saved in some kind of cache. Idea how to clear the cache?

tikyta commented 1 year ago

Hi! same issue... do you found a solution?

Nebseo commented 1 year ago

Same issue here : Warning: Invalid argument supplied for foreach() in /home/customer/www/nebseo.com/public_html/wp-content/plugins/unyson/framework/includes/option-types/typography-v2/class-fw-option-type-typography-v2.php on line 148

tikyta commented 1 year ago

I share the solution that worked for me...

Added an "array" to the line 148..

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

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

return false;

}

Nebseo commented 1 year ago

I share the solution that worked for me...

Added an "array" to the line 148..

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

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

return false;

}

I've tried it and it works for me too!!!

Thanks @tikyta

Tom2710 commented 1 year ago

@tikyta for me it's always there image

IamOri commented 1 year ago

I share the solution that worked for me...

Added an "array" to the line 148..

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

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

return false;

}

I belive it just force variable to convert to array, so u dont get error, but fonts are still not loaded.

IamOri commented 1 year ago

Probably best solution, since unyson cache site seems to be back online. Unyson is saving fonts data in database for 7 days and loads them from their own site, so it cached wrong data when the site was down.

Delete cached fonts data in your database: in table "wp_options" find row with "option_name"="fw_google_fonts" and update/delete value in "option_value" column to be empty string.

Or use this command and replace {{YOUR_DATABASE_NAME}} with your wp database name:

UPDATE {{YOUR_DATABASE_NAME}}.wp_options SET option_value='' WHERE option_name="fw_google_fonts";

After updating db reload your page twice.(Probably best if you turn off all cache plugins before that).

First reload you will get errors like this, because script expects some arrays and values we deleted: Warning: Illegal string offset 'last_update' in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309 Warning: A non-numeric value encountered in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309

But it will also load new data into db, so next time there should be no errors.

jls556 commented 1 year ago

Probably best solution, since unyson cache site seems to be back online. Unyson is saving fonts data in database for 7 days and loads them from their own site, so it cached wrong data when the site was down.

Delete cached fonts data in your database: in table "wp_options" find row with "option_name"="fw_google_fonts" and update/delete value in "option_value" column to be empty string.

Or use this command and replace {{YOUR_DATABASE_NAME}} with your wp database name:

UPDATE {{YOUR_DATABASE_NAME}}.wp_options SET option_value='' WHERE option_name="fw_google_fonts";

After updating db reload your page twice.(Probably best if you turn off all cache plugins before that).

First reload you will get errors like this, because script expects some arrays and values we deleted: Warning: Illegal string offset 'last_update' in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309 Warning: A non-numeric value encountered in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309

But it will also load new data into db, so next time there should be no errors.

My problem is that I can't find "wp_options". It is just not there!

IamOri commented 1 year ago

My problem is that I can't find "wp_options". It is just not there!

Maybe you have different prefix for wordpress tables? I think all tables that are created by wp should have the same prefix. Try to look for tables that have common prefix with others. (xyz_options, myCustomPrefix_options, ...) Not sure if its possible to have no prefix. If thats the case, it would be just "options" or "_options".

jls556 commented 1 year ago

@IamOri Thanks. But I didn't change or set up any other prefix. I have a lot of files and folders with "wp" but no options. If I search for it, no result. I found 1 file, not the content I'd expected.

IamOri commented 1 year ago

@jls556 Oh.. you need to login to your database and edit database, not script files. If you are on web hosting, usually there is phpMyAdmin portal that you can use to access your database. If you have site on VPS or other self administered server, you will have to login to your server and use comandline utility or install phpMyAdmin, or use some other client.

jls556 commented 1 year ago

Worked! Thank you.

yourwebchick commented 1 year ago

Probably best solution, since unyson cache site seems to be back online. Unyson is saving fonts data in database for 7 days and loads them from their own site, so it cached wrong data when the site was down.

Delete cached fonts data in your database: in table "wp_options" find row with "option_name"="fw_google_fonts" and update/delete value in "option_value" column to be empty string.

Or use this command and replace {{YOUR_DATABASE_NAME}} with your wp database name:

UPDATE {{YOUR_DATABASE_NAME}}.wp_options SET option_value='' WHERE option_name="fw_google_fonts";

After updating db reload your page twice.(Probably best if you turn off all cache plugins before that).

First reload you will get errors like this, because script expects some arrays and values we deleted: Warning: Illegal string offset 'last_update' in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309 Warning: A non-numeric value encountered in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309

But it will also load new data into db, so next time there should be no errors.

THANK YOU SO MUCH, @IamOri! Such a quick and simple solution, but I never would have thought of it on my own. Fixed the issue for me, even though my error was the /unyson/framework/helpers/general.php error and not the /unyson/framework/includes/option-types/typography...etc error. Thank you thank you thank you!!!

odofincaleb commented 1 year ago

I can't find that fw_google_fonts in my datable wp-options table

odofincaleb commented 1 year ago
image

This is my database wp-options with options_name arranged alphabetically

odofincaleb commented 1 year ago

Found it table=sgqepm_options

and it worked.

Please Note I was looking here , wp-options table

image

But i found it here sgqepm_options

image
odofincaleb commented 1 year ago

Probably best solution, since unyson cache site seems to be back online. Unyson is saving fonts data in database for 7 days and loads them from their own site, so it cached wrong data when the site was down.

Delete cached fonts data in your database: in table "wp_options" find row with "option_name"="fw_google_fonts" and update/delete value in "option_value" column to be empty string.

Or use this command and replace {{YOUR_DATABASE_NAME}} with your wp database name:

UPDATE {{YOUR_DATABASE_NAME}}.wp_options SET option_value='' WHERE option_name="fw_google_fonts";

After updating db reload your page twice.(Probably best if you turn off all cache plugins before that).

First reload you will get errors like this, because script expects some arrays and values we deleted: Warning: Illegal string offset 'last_update' in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309 Warning: A non-numeric value encountered in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309

But it will also load new data into db, so next time there should be no errors.

Thank you for helping me solve the issue

yura-x commented 1 year ago

This happens because 'unyson.io' domain was not payed at some moment of time and fonts list in the JSON format was not saved in the wp_options in the option key called 'fw_google_fonts'.

If you have this error or if your Customizer options are disappeared, you can try to add this code into your 'functions.php' file.

add_action( 'wp', function () {
    $fonts = get_option( 'fw_google_fonts', false );
    if (
        is_array( $fonts )
        &&
        ! empty( $fonts['fonts'] )
        &&
        false !== stripos( $fonts['fonts'], '<!DOCTYPE html>' )
    ) {
        update_option( 'fw_google_fonts', '' );
    }
});

then just reload your page. Problem should disappear. After that you can remove this code.

IamOri commented 1 year ago

Good job 👍 , same solution as mine, just doing it in code.

joossii commented 1 year ago

Probably best solution, since unyson cache site seems to be back online. Unyson is saving fonts data in database for 7 days and loads them from their own site, so it cached wrong data when the site was down.

Delete cached fonts data in your database: in table "wp_options" find row with "option_name"="fw_google_fonts" and update/delete value in "option_value" column to be empty string.

Or use this command and replace {{YOUR_DATABASE_NAME}} with your wp database name:

UPDATE {{YOUR_DATABASE_NAME}}.wp_options SET option_value='' WHERE option_name="fw_google_fonts";

After updating db reload your page twice.(Probably best if you turn off all cache plugins before that).

First reload you will get errors like this, because script expects some arrays and values we deleted: Warning: Illegal string offset 'last_update' in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309 Warning: A non-numeric value encountered in {{hosting_root}}/wp-content/plugins/unyson/framework/helpers/general.php on line 1309

But it will also load new data into db, so next time there should be no errors.

Hey @IamOri,

I've tried to clear the fw_google_fonts, but the option_value is already cleared. I'm only getting this when putting up a stage or pushing a stage to live

image image

IamOri commented 1 year ago

@joossii Hi, this general error message can mean anything. Plugin should populate fw_google_fonts automaticaly when its needed. So i guess its not really related to this issue. I suggest trying to get more specific informations about whats going on and create new issue.

PioPas commented 1 year ago

@joossii Hi, this general error message can mean anything. Plugin should populate fw_google_fonts automaticaly when its needed. So i guess its not really related to this issue. I suggest trying to get more specific informations about whats going on and create new issue.

It looks like when I set the empty string the plug in is not updating the value. How to force it or do you have a strick which I can paste there maybe to check if it will solve the problem?

PioPas commented 1 year ago

@joossii Hi, this general error message can mean anything. Plugin should populate fw_google_fonts automaticaly when its needed. So i guess its not really related to this issue. I suggest trying to get more specific informations about whats going on and create new issue.

It looks like when I set the empty string the plug in is not updating the value. How to force it or do you have a strick which I can paste there maybe to check if it will solve the problem?

I managed to get it update but I have now this: a:2:{s:11:"last_update";i:1670799466;s:5:"fonts";s:39:"Error : Failed to get Google Fonts list";}