Forums

a warning displayed in a widget (4 posts)

  1. abhinandh
    Member
    Posted 3 months 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
    Member
    Posted 3 months ago #

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

  3. FreekOne
    Member
    Posted 3 months 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 2 months 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.

Reply

You must log in to post.

About this Topic