protected function onWidget(array $args, \Drone\HTML &$html) { if (!$this->wo('username')) { return; } if (($tweets = get_transient($this->getTransientName('tweets'))) === false || get_transient($this->getTransientName('valid')) === false) { $new_tweets = Func::twitterGetTweets($this->wo_('oauth')->toArray(), $this->wo('username'), $this->wo('include_retweets'), $this->wo('exclude_replies'), $this->wo('count')); if ($new_tweets !== false) { $tweets = $new_tweets; $interval = $this->wo_('interval')->seconds(); set_transient($this->getTransientName('valid'), true, $interval); set_transient($this->getTransientName('tweets'), $tweets, $interval + self::TWEETS_BACKUP_INTERVAL); } else { if ($tweets === false) { return; } } } $html = HTML::ul(); foreach ($tweets as $tweet) { $li = HTML::li()->add($tweet['html'], HTML::br(), HTML::small()->add(HTML::a()->href($tweet['url'])->add(sprintf(__('%s ago', $this->_domain), human_time_diff($tweet['date']))))); $li = \Drone\apply_filters('widget_' . str_replace('-', '_', $this->_id) . '_tweet', $li, $this, $tweet); if (is_callable(self::$_on_tweet)) { _deprecated_function(__METHOD__ . '::$_on_tweet', '5.0', 'drone_widget_' . str_replace('-', '_', $this->_id) . '_tweet filter'); call_user_func_array(self::$_on_tweet, array($this, $tweet, &$li)); } $html->add($li); } }