WordPress.org

Forums

bbPress2 shortcode whitelist
[resolved] Warning: Invalid argument supplied for foreach() ... on line (14 posts)

  1. vsantoso
    Member
    Posted 3 years ago #

    I receive the following warning message:

    Warning: Invalid argument supplied for foreach() in plugins/bbpress2-shortcode-whitelist/class_bbpress-shortcode-whitelist.php on line 51

    I just activated, set the settings with only 1 shortcode

    http://wordpress.org/extend/plugins/bbpress2-shortcode-whitelist/

  2. vsantoso
    Member
    Posted 3 years ago #

    I managed to resolve this :)

    I added (array) casting before $tag_array, because probably the $tag_array was empty, and hence PHP throws out the warning message.

    The plugin managed to accomplish what it says, and everything seems working well so far. Hence i close this issue.

  3. antonchanning
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks. I'll have a look at working your fix for this bug into the next release.

  4. antonchanning
    Member
    Plugin Author

    Posted 3 years ago #

    I think you may have fixed the bug reported by a couple of other users.

    This will actually save me some work so thanks again!

    I'll have a look at why $tag_array was empty but not an array in the first place as it sounds more like curing a symptom to just cast it...

  5. web4work
    Member
    Posted 3 years ago #

    antonchanning,

    When will you be releasing the update to fix errors for bbpress2-shortcode-whitelist.1.3?

    I also get the error message: Warning: Invalid argument supplied for foreach() in plugins/bbpress2-shortcode-whitelist/class_bbpress-shortcode-whitelist.php on line 51

    If the update takes too long to be completed, can you at least explain step by step how to fix the bug that vsantoso corrected to get it working?

  6. csm2012
    Member
    Posted 3 years ago #

    I am having the same issue. I have found the file and line to edit however I am not sure exactly what or how to edit the "(array) casting before $tag_array". If someone could please post a step by step on how to edit the bbpress2-shortcode-whitelist/class_bbpress-shortcode-whitelist.php file or release update for the plugin.

    Thank you,

    C.S.

  7. vsantoso
    Member
    Posted 3 years ago #

    Hi csm2012,
    You just need to add this text: "(array)" before $tag_array on line 51.

    It's called casting $tag_array into array type.

    As mentioned by antonchanning, it's best if we could find out the root cause. Casting to array is a quick fix to solve the symptom only. But it's needed to get it working immediately for me.

    Regards,

  8. csm2012
    Member
    Posted 3 years ago #

    Hello Vsantos,

    Thank you for responding so quickly. Getting this plugin to work on my site fast is important to me too. I have gone in to the class_bbpress-shortcode-whitelist.php file and made the edit. I placed the(array) before $tag_array on line 51 and it returns a bigger error on the WP.

    Parse error: syntax error, unexpected T_ARRAY_CAST, expecting '(' in /home/csmontg1/public_html/diyitdept.com/wp-content/plugins/bbpress2-shortcode-whitelist/class_bbpress-shortcode-whitelist.php on line 51

    Here is my code below.

    function get_known_plugins($tag_array) {
    			$plugins = array();
    			foreach (array)($tag_array as $tag) {
    				$plugin = $this->get_known_plugin_by_tag($tag);
    				if(false !== $plugin) $plugins[] = $plugin;

    Thank you for your help or any other things you think I should try.

    Genuinely,

    C.S.

  9. vsantoso
    Member
    Posted 3 years ago #

    Hi csm2102,

    Sorry if i didn't make it clearer.
    You should put the "(array)" exactly before the $tag_array.
    Hence on line 51 it would look something like this:
    foreach ((array)$tag_array as $tag) {

  10. csm2012
    Member
    Posted 3 years ago #

    Vsanto,

    That did it, Thank you again for your quick responses. I am still learning so thanks for your patience. Maybe this will take care of the error message until antonchanning is able to find out what is causing the issue and release an update.

    Thank you again,

    C.S.

  11. vsantoso
    Member
    Posted 3 years ago #

    You're welcome :)

  12. antonchanning
    Member
    Plugin Author

    Posted 2 years ago #

    Apologies to everyone for my absence and neglect of this plugin whilst I moved house and settled into my new home/city/country. I'll be releasing this fix very soon...

  13. antonchanning
    Member
    Plugin Author

    Posted 2 years ago #

    @vsantoso Your fix is in the latest version of the plugin now. Thanks for spotting that one.

  14. vsantoso
    Member
    Posted 2 years ago #

    You're welcome @antonchanning

    Your plugin is very helpful. Thanks for that :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • bbPress2 shortcode whitelist
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic