Twitter Feed Widget works intermittently .
I wondering how this effects the mysql and if theres a way I can make sure the MySQL  doesn't update if a null result. 
>  the above doesn't seem possible as there are tweets in the MySQL but they're not being included. 
>  on line 571 of wp=twitter-widget.php then you'll see the code
if ( count( $tweets ) == 0 ) 
which runs the 'No Tweets Available' message. 
line 555 . 
$tweets = $this->_getTweets( $args );
line 737 
    private function _getTweets( $widgetOptions ) {
        $key = 'twp_' . md5( $this->_getFeedUrl( $widgetOptions ) );
        return tlc_transient( $key )
            ->prevent_background()
            ->expires_in( 5 ) // cache for 5 minutes
            ->updates_with( array( $this, 'parseFeed' ), array( $widgetOptions ) )
            ->get();
    }
I can't find anywhere that writes to the database - having said I can see the tweets come up in 'wp_options'  listed under '_transient_twp_'
if I do a search for most recent and 
SELECT *
FROM `wp_options`
WHERE `option_name` LIKE '%_transient_twp_%'
ORDER BY `option_id` DESC
LIMIT 1
this will bring back the result I want. 
$lasttweetrow = $wpdb->get_row("SELECT * FROM $wpdb->wp_options WHERE `option_name` LIKE '%_transient_twp_%'
ORDER BY `option_id` DESC
LIMIT 1");
Which has made the if ( count( $tweets ) == 0 )  code into. 
    if ( count( $tweets ) == 0 ) {
    // here I'm going to check the database for any old results
$lasttweetrow = $wpdb->get_row("SELECT * FROM $wpdb->wp_options WHERE `option_name` LIKE '%_transient_twp_%'
ORDER BY `option_id` DESC
LIMIT 1");
$options = $lasttweetrow->option_value;   
$options_array = explode(';', $options);
$tweetrow = $options_array[11];       
$tweet_array = explode(':', $tweetrow);
$tweet = $tweet_array[2];
}
No comments:
Post a Comment