function tb_get_cached_tweets_html($mode,$instance,$widget_id = '') { global $wp_json; // get options $tb_o = get_option('tweet-blender'); // figure out how many to get if ($mode == 'archive') { $tweets_to_show = $tb_o['archive_tweets_num']; // get data for all sources $sources = array(); } else { $tweets_to_show = $instance['widget_tweets_num']; // get data for this widget's sources only $sources = preg_split('/[\n\r]/m', trim($instance['widget_sources'])); } // get data from DB $tweets_html = ''; $tweets = tb_get_cached_tweets($sources, $tweets_to_show,$widget_id); foreach ($tweets as $t){ $tweet = $wp_json->decode($t->tweet_json); $tweet->{'div_id'} = $t->div_id; $tweets_html .= tb_tweet_html($tweet,$mode,$tb_o); } return $tweets_html; }
function tb_get_cached_tweets_html($mode, $instance, $widget_id = '', $sources = array()) { global $wp_json; // get options $tb_o = get_option('tweet-blender'); // if no explicit sources requisted, get the ones configured for the widget if (sizeof($sources) == 0) { $sources = array_values(array_filter(preg_split('/[\\n\\r]/m', trim($instance['widget_sources'])))); } $tweets_html = ''; if ($mode == 'chart') { // get data from DB $chart_data = tb_get_chart_data($sources, $instance['widget_chart_period'], $instance['widget_chart_type']); $tweets_html .= tb_wrap_javascript('TB_chartsData["' . $widget_id . '"] = eval(\'(' . $wp_json->encode($chart_data) . ')\');'); } else { // figure out how many to get if ($mode == 'archive') { $tweets_to_show = $tb_o['archive_tweets_num']; } else { $tweets_to_show = $instance['widget_tweets_num']; } // get data from DB $tweets = tb_get_cached_tweets($sources, $tweets_to_show, $widget_id); foreach ($tweets as $t) { $tweet = $wp_json->decode($t->tweet_json); $tweet->{'div_id'} = $t->div_id; $tweets_html .= tb_tweet_html($tweet, $mode, $tb_o); } } return $tweets_html; }