-
AuthorPosts
-
August 20th, 2016 at 03:48 #38482
1.) What I do
If I run on the shell wp-cli
( from https://github.com/sinebridge/wp-cli-about ):
$ wp-cli about
2.) What I get:
Warning: Invalid argument supplied for foreach() in ~/wp-content/themes/parabola/includes/theme-styles.php on line 13
3.) Inspection of the Line is:
foreach ($parabolas as $key => $value) { ${"$key"} = $value ;}
4.) Question:
What is wrong?5.) Information:
Wordpress version : 4.5.3
parabola : 1.7.4
PHP version : 5.5.386.) Side Information
I do not get this error on any of the other WP installations (about 12 or so).
However, this is the only one, where I use your beautiful Parabola Plugin.—
Thank you for any help,
CruisenAugust 29th, 2016 at 14:09 #38691ZedCryout Creations mastermindI am not sure how wp-cli works, but it could be that the global namespaces $parabolas (from line 12) is not available at the moment this utility scans/processes the files, triggering the warning.
If you like our creations, help us share by rating them on WordPress.org.
Please check the available documentation and search the forums before starting a topic.January 25th, 2017 at 10:42 #42223Got the same error.
Try this one:
`global $parabolas;
if (is_array($parabolas)) {
foreach ($parabolas as $key => $value) { ${“$key”} = $value ;}
}`January 28th, 2017 at 08:04 #42267Thanks, ronschi, this works perfect for my installed WP too!
I expect your code will be included in future versions. wp-cli is widely deployed. I saved it as a patch.
--- wp-content/themes/parabola/includes/theme-styles.php 2017-01-27 13:07:55.627920010 +0100 +++ wp-content/themes/parabola/includes/theme-styles.php 2017-01-28 05:44:28.000000000 +0100 @@ -10,7 +10,7 @@ function parabola_register_styles() { global $parabolas; - foreach ($parabolas as $key => $value) { ${"$key"} = $value ;} + if (is_array($parabolas)) {foreach ($parabolas as $key => $value) { ${"$key"} = $value ;}} wp_register_style( 'parabola-style', get_stylesheet_uri(), NULL, _CRYOUT_THEME_VERSION );
February 5th, 2017 at 13:02 #42454ZedCryout Creations mastermindUnfortunately, the previous workaround does solve the warning but doesn’t solve the main problem with the options array not being available resulting in unpredictable results.
If you like our creations, help us share by rating them on WordPress.org.
Please check the available documentation and search the forums before starting a topic. -
AuthorPosts
The topic ‘Invalid argument supplied for foreach()’ is closed to new replies.