WordPress.org

Forums

Twitget
[resolved] Warning printed (4 posts)

  1. tomdxw
    Member
    Posted 1 year ago #

    WordPress 3.7.1. Twitget 3.2.

    With WP_DEBUG enabled and when the widget is added to a widget area but the plugin isn't configured yet the following error occurs:

    PHP Warning: Invalid argument supplied for foreach() in /var/vhosts/wp/wp-content/plugins/twitget/twitget.php on line 483

    Tom Adams,
    dxw

    http://wordpress.org/plugins/twitget/

  2. Boštjan Cigan
    Member
    Plugin Author

    Posted 1 year ago #

    Will look into it ASAP, because it isn't an issue that can crash the plugin.

    Cheers and thanks for the notice.

  3. dr_blue
    Member
    Posted 1 year ago #

    Hiya, having the same resulting E_WARNING but probably when no tweets could be loaded (API temporarily unavailable), the array $tweet_date_array will be empty and can't be iterated with foreach, resulting in a E_WARNING.

    This should fix it though:

    --- twitget_orig.php    2014-01-02 08:33:54.182842200 +0100
    +++ twitget_mod.php     2014-01-02 08:33:46.322842200 +0100
    @@ -480,7 +480,7 @@
                                    <?php
                                            }
                                    ?>
    -                               <?php foreach($tweet_date_array as $c => $val) { ?>
    +                               <?php if (!empty($tweet_date_array)) { foreach($tweet_date_array as $c => $val) { ?>
                                    var date_val_<?php echo $c; ?> = <?php echo $val; ?>;
                                    <?php if($options["show_relative_time"]) { ?>
                                    var date_<?php echo $c; ?> = moment.unix(date_val_<?php echo $c; ?>).fromNow();
    @@ -488,7 +488,7 @@
                                    var date_<?php echo $c; ?> = moment.unix(date_val_<?php echo $c; ?>).format("<?php echo $moment_js_time; ?>");
                                    <?php } ?>
                                    jQuery(".<?php echo $c; ?>_tweet_date").html(date_<?php echo $c; ?>);
    -                               <?php } ?>
    +                               <?php } } ?>
                            });
                    </script>

    Couldn't find the project on github so I was unable to submit this patch as a proposed bug-fix.

  4. Boštjan Cigan
    Member
    Plugin Author

    Posted 1 year ago #

    Fixed in 3.3.

    Cheers and thanks for the notice.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Twitget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.