WordPress.org

Ready to get started?Download WordPress

Forums

a warning displayed in a widget (12 posts)

  1. abhinandh
    Member
    Posted 4 years ago #

    here is the warning i get

    Warning: strpos() expects parameter 1 to be string, array given in D:\xampp\xampplite\htdocs\wp-includes\rss.php on line 577

    im trying to add a twitter widget - http://wordpress.org/extend/plugins/twitter-for-wordpress/ - with the call
    <?php twitter_messages('abhinandh', 3, true, true, '>>', true, true, false); ?>

    wordpress 2.8.4

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Looks like there's problem with that widget and WP 2.8.4

  3. FreekOne
    Member
    Posted 4 years ago #

    This happens because the fetch_rss function is deprecated (fetch_feed is the new function) and WP now uses SimplePie instead of the old MagPie. The widget tries to parse a SimplePie Object as a MagPie Object and that breaks things. Took me quite a few hours to figure it out but here's the fix I came up with:

    Open the wp-content/plugins/twitter-for-wordpress/twitter.php file.

    Find and delete - 2 instances

    include_once(ABSPATH . WPINC . '/rss.php');

    Find and replace - 2 instances

    $messages = fetch_rss('http://twitter.com/statuses/user_timeline/'.$username.'.rss');

    with:

    $messages = fetch_feed('http://twitter.com/statuses/user_timeline/'.$username.'.rss');

    Find and replace

    if ( empty($messages->items) ) {

    with

    $feed_count = $messages->get_item_quantity();
    if ( empty($feed_count) ) {

    Find and replace

    foreach ( $messages->items as $message ) {
    $msg = " ".substr(strstr($message['description'],': '), 2, strlen($message['description']))." ";
    if($encode_utf8) $msg = utf8_encode($msg);
    $link = $message['link'];

    with

    foreach ( $messages->get_items() as $message ) {
    $desc = $message->get_description();
    $date = $message->get_date();
    $msg = " ".substr(strstr($desc,': '), 2, strlen($desc))." ";
    if($encode_utf8) $msg = utf8_encode($msg);
    $link = $message->get_link();

    Find and replace

    $time = strtotime($message['pubdate']);

    with

    $time = strtotime($date);

    That should be it. Widget now works perfectly with WP 2.8.4, enjoy ;)

  4. thefuntastic
    Member
    Posted 4 years ago #

    Thank's you're a life saver!

    Though in my 'twitter for wordpress' the second instance of :

    $messages = fetch_rss('http://twitter.com/statuses/user_timeline/'.$username.'.rss');

    is actually:

    $messages = fetch_rss('http://twitter.com/statuses/user_timeline/'.$item['username'].'.rss');

    if I changed this to:

    $messages = fetch_feed('http://twitter.com/statuses/user_timeline/'.$item['username'].'.rss');

    its seems to work great for me.

  5. Darto KLoning
    Member
    Posted 4 years ago #

    i have the same problem as abhinandh, and thanks to FreekOne, help so much.

  6. thefake
    Member
    Posted 4 years ago #

    Same problem here, thx for the solution

  7. StevenBullen
    Member
    Posted 4 years ago #

    Thanks. It's a shame the owner doesn't update his plugin.

  8. korymath
    Member
    Posted 4 years ago #

    Spectacular fix!

    Thank you so much, absolutely perfect.

  9. mitchelvase
    Member
    Posted 4 years ago #

    after the fix from FreekOne i don't get errors anymore but the tweets aren't updating anymore :(

  10. jecko
    Member
    Posted 4 years ago #

    Fixed perfectly..!

  11. nicdvs
    Member
    Posted 4 years ago #

    Thanks for that solution, it works perfectly..

  12. Integrati
    Member
    Posted 4 years ago #

    Lovely, great work thank you, just implemented the code and no issues seamless update, maybe you could take over this plug in ;)

    Thank you!

    Integrati marketing team.

Topic Closed

This topic has been closed to new replies.

About this Topic