Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 protected function onShortcode($content, $code, \Drone\HTML &$html)
 {
     $content = preg_replace('/ *(\\[(vector|image)_icon[^\\]]*\\]) */', '</span>\\1<span>', trim($content));
     $content = preg_replace('#^<span></span>|<span></span>$#', '', "<span>{$content}</span>");
     $html = HTML::a()->addClass('button', $this->so('size'), $this->so('advanced/class'))->style($this->so('advanced/style'));
     $html->add(Func::wpShortcodeContent($content));
     if ($this->so('href')) {
         $html->href = $this->so('href');
         if ($this->so('new_window')) {
             $html->target = '_blank';
         }
     }
     if ($this->so('color')) {
         $html->style .= sprintf('border-color: %1$s; color: %1$s;', $this->so('color'));
     }
     if ($this->so('background/opacity') == 0) {
         $html->style .= 'background-color: transparent;';
     } else {
         if ($this->so('background/color')) {
             $html->style .= 'background-color: ' . Func::cssHexToRGBA($this->so('background/color'), $this->so('background/opacity') / 100) . ';';
         }
     }
     if ($this->so('caption')) {
         $html = HTML::p()->class('horizontal-align text-right')->add($html, '<br />', HTML::small()->class('caption')->add($this->so('caption')));
     }
 }