PHP error at td_wp_booster_functions.php

Posted in: Newspaper
Post count: 8

Hello,

I have a php error from a file shipped with the theme:


Warning: Invalid argument supplied for foreach() in ......./themes/mytheme/includes/wp_booster/td_wp_booster_functions.php on line 2212

The issue seems to be here :

//get our custom dynamic sidebars
$currentSidebars = td_util::get_option('sidebars');

//if we have user made sidebars, register them in wp
if (!empty($currentSidebars)) {
foreach ($currentSidebars as $sidebar) {

When executing a

//get our custom dynamic sidebars
$currentSidebars = td_util::get_option('sidebars');
var_dump($currentSidebars);

The result:

string(59) " M"

I cleared all transients without success.

Thanks for your help

Post count: 23312

Hello uper_nic0las,

Unfortunately, we do not have any bad reports in this regard, until now, sorry! Most likely you are using some untested plugins which can interact with the theme core file and cause a lot of unknown issues. Try to disable all of them, leave just Visual Composer to active, clear all your caches and check the results. Also, if the problem is still there, please try to make a new clean install from scratch via FTP way because this is the surest method in this regard.

Hope this helps and let us know how it goes!

Thanks for the message!

Post count: 8

OK, I am using bedrock boilerplate https://roots.io/bedrock

and here are the plugin list :

+--------------------+----------+--------+---------+
| name | status | update | version |
+--------------------+----------+--------+---------+
| worker | inactive | none | 4.2.16 |
| revslider | active | none | 5.3.1.5 |
| td-mobile-plugin | active | none | 1.1 |
| td-social-counter | active | none | 4.1 |
| td-speed-booster | active | none | 4.5 |
| td-api-plugin | active | none | 1.0 |
| js_composer | active | none | 5.0.1 |
| wp-super-cache | active | none | 1.4.9 |
| bedrock-autoloader | must-use | none | 1.0.0 |
| disallow-indexing | must-use | none | 1.0.0 |
| 0-worker | must-use | none | |
+--------------------+----------+--------+---------+

Disabling all the plugins did not help.

And this error did show up only after playing with sidebar / widget.

Post count: 23312

Hello super_nic0las,

You should re-install the latest version of the theme via FTP way, use only the plugins that come bundled with the theme packet and rule out any conflicting plugins. I suggest you install the theme again via this way because this is the surest method in this regard. A bad theme installing can cause this type of issues and that’s why it is very important to make a new fresh install from scratch and check the results.

Hope this helps and let us know how it goes!

Thanks for the message!

Post count: 3

I had this SAME ISSUE after I installed WAMPESERVER in my Local Disk to test scripts…

all you have to do is to INSTALL A DEMO without sample data, and all errors disapeer.

Try it…

Post count: 3

I Instaledd WAMPSERVER on localhost, than installed WordPress, than Newspaper theme 7.7.1 than imported theme setings from my live site….

and BANG this error starts to happen….

Warning: Invalid argument supplied for foreach() in ......./themes/mytheme/includes/wp_booster/td_wp_booster_functions.php on line 2212

checked this forum for help, and found nothing… then somehow I remmebered to install a DEMO without sample data, as I did in live site…

and all errors just vanished…

Hope it helps…

Post count: 8

And lot of people have the same problem as per google search results :
https://www.google.com/search?q=foreach()+in+%22td_wp_booster_functions.php%22+on+line+2212&*

Post count: 57

I am getting this error as well.

Post count: 8

@Tagdiv team, how about this fix ?


--- a/includes/wp_booster/td_wp_booster_functions.php
+++ b/includes/wp_booster/td_wp_booster_functions.php
@@ -2208,7 +2208,7 @@ function td_init_booster() {
$currentSidebars = td_util::get_option('sidebars');

//if we have user made sidebars, register them in wp
- if (!empty($currentSidebars)) {
+ if (is_array($currentSidebars)) {
foreach ($currentSidebars as $sidebar) {
register_sidebar(array(
'name' => $sidebar,

Post count: 23312

Hello super_nic0las,

First of all, thank you for your suggestion. We will add this problem to our list of improvements. What type of PHP version do you use? It is possible that if you are using the PHP 7.1 cause this problem.

Thanks for the message!

Post count: 3

Like I said, I Just FIXED this error with a simple step.
Installing a DEMO with NO DATA. just the settings, corrected all errors

Try it. you can unistall the DEMO and the errors are fixed.

  • This reply was modified 9 years by MaNunes. Reason: typo
Post count: 8

@Catalin, Exactly, we are runing wordpress under PHP version 7.1.1-1+deb.sury.org~trusty+1
Also, we are running it with Bedrock boilerplate https://roots.io/bedrock/


@MaNunes
, thanks for the advice however we prefer to not take any risk by loading some demo settings that might brake a lot of customisation work that have already been done.

Note that another dirty way is to “hide” the error by turning off the error level in wordpress wp-settings :

define('WP_DEBUG', false);

Thanks all!
Nicolas

Post count: 22421

Please do not use PHP version 7.1 The theme is only compatible with version 7.0 or bellow.

Thank you!

Post count: 8

Hi @bogdan-b,
Thanks for the suggestion,
Just downgraded to PHP 7.0.17-2+deb.sury.org~trusty+1
and the problem still occurs.

Best.

Post count: 22421

Try to switch demos if you switched php versions as the theme settings were created on php 7.1 and they need to be reset if you changed php versions.
Also try to recreate your sidebar widgets.
Thank you!

Viewing 15 posts - 1 through 15 (of 15 total)
The forum ‘Newspaper’ is closed to new topics and replies.