Support » Fixing WordPress » a warning displayed in a widget

  • abhinandh

    (@abhinandh)


    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

Viewing 11 replies - 1 through 11 (of 11 total)
  • esmi

    (@esmi)

    Forum Moderator

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

    FreekOne

    (@freekone)

    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 😉

    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.

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

    Same problem here, thx for the solution

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

    Spectacular fix!

    Thank you so much, absolutely perfect.

    after the fix from FreekOne i don’t get errors anymore but the tweets aren’t updating anymore 🙁

    Fixed perfectly..!

    Thanks for that solution, it works perfectly..

    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.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘a warning displayed in a widget’ is closed to new replies.