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); } }
protected function _html() { $tags = self::getTagsList(); foreach (array_keys(array_diff_key($this->options, $tags)) as $tag) { if ($tag == 'default') { continue; } $tags[$tag] = array('caption' => '~' . $tag, 'group' => __('Inactive', $this->domain)); } $options = array('' => __('Select condition...', $this->domain)); $groups = array(); foreach ($tags as $tag => $data) { $options[$tag] = $data['caption']; $groups[$data['group']][] = $tag; } $html = HTML::div()->class($this->getCSSClass(__CLASS__))->data('name', $this->input_name); $ul = $html->addNew('ul')->class('conditions'); $ul->addNew('li')->class('default')->addNew('div')->add($this->options['default']->html()); foreach ($groups as $group_tags) { foreach ($group_tags as $tag) { if (!isset($this->options[$tag])) { continue; } $ul->addNew('li')->add(HTML::a()->class('button delete')->add(__('Delete', $this->domain)), HTML::label()->add(sprintf(__('On %s', $this->domain), '<span>' . $tags[$tag]['caption'] . '</span>' . HTML::makeSelect(null, $tag, $options, $groups)->style('display: none;')->html()), ':'), HTML::div()->add($this->options[$tag]->html())); } } $html->addNew('div')->class('controls')->addNew('a')->class('button customize')->add(__('Customize on...', $this->domain)); $html->addNew('div')->class('prototype')->add(HTML::a()->class('button delete')->style('display: none;')->add(__('Delete', $this->domain)), HTML::label()->add(sprintf(__('On %s', $this->domain), '<span style="display: none;"></span>' . HTML::makeSelect(null, '', $options, $groups)->html()), ':'), HTML::div()->add($this->prototype->html())); return $html; }
/** * Cart info * * @since 1.0 * * @param string $type * @param array $visible * @return string */ public static function woocommerceGetCartInfo($type, $visible = array('desktop', 'mobile')) { if (count($visible) == 0) { return ''; } // HTML $a = \Drone\HTML::a()->href($GLOBALS['woocommerce']->cart->get_cart_url())->title(__('Cart', 'everything'))->addClass('cart-info', $type); // Visibility if (count($visible) == 1) { $a->addClass($visible[0] . '-only'); } // Icon $a->addNew('i')->addClass('icon-woocommerce-cart', 'icon-' . Everything::to('woocommerce/cart/icon')); // Content if (Everything::to_('header/cart/content')->value('count')) { $a->addNew('span')->class('count')->add($GLOBALS['woocommerce']->cart->get_cart_contents_count()); } if (Everything::to_('header/cart/content')->value('total') && $GLOBALS['woocommerce']->cart->get_cart_contents_count()) { $cart_total = strip_tags($GLOBALS['woocommerce']->cart->get_cart_total()); $cart_total = preg_replace('/(' . preg_quote(get_option('woocommerce_price_decimal_sep'), '/') . ')([0-9]+)/', '\\1<small>\\2</small>', $cart_total); $a->addNew('span')->class('total')->add($cart_total); } return $a->html(); }
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'))); } }