/** * Languages menus * * @since 1.0 */ public static function langMenu() { if (count($langs = icl_get_languages('skip_missing=0&orderby=code')) == 0) { return; } $html = \Drone\HTML::ul(); $main = $html->addNew('li'); $sub = $main->addNew('ul'); foreach ($langs as $lang) { $li = $sub->addNew('li'); $a = $li->addNew('a')->href($lang['url'])->title($lang['native_name'])->add($lang['native_name'], \Drone\HTML::span()->class('flag-' . $lang['language_code'])); if ($lang['active']) { $li->class = 'current'; $main->insertNew('a')->href('#')->title($lang['native_name'])->add(\Drone\HTML::span()->class('flag-' . $lang['language_code']), \Drone\HTML::i()->class('icon-down-open')); } } echo $html->html(); }
protected function onWidget(array $args, \Drone\HTML &$html) { if (!$this->wo('username')) { return; } $transient = $this->getTransientName('photos'); if (($data = get_transient($transient)) === false) { $api_key = $this->wo('api_key'); if (empty($api_key)) { $api_key = Func::FLICKR_API_KEY; } if (($data['userdata'] = Func::flickrGetUserdata($api_key, $this->wo('username'))) === false) { return; } if (($data['photos'] = Func::flickrGetPhotos($api_key, $data['userdata']['id'], $this->wo('count'))) === false) { return; } set_transient($transient, $data, $this->wo_('interval')->seconds()); } $html = HTML::ul(); foreach ($data['photos'] as $photo) { $li = HTML::li(); $li->addNew('a')->href($this->wo('url') == 'flickr' ? $photo['url'] : sprintf($photo['src'], 'b'))->title($photo['title'])->rel($this->id)->addNew('img')->src(sprintf($photo['src'], 's'))->alt($photo['title'])->width(75)->height(75); $li = \Drone\apply_filters('widget_' . str_replace('-', '_', $this->_id) . '_photo', $li, $this, $photo); if (is_callable(self::$_on_photo)) { _deprecated_function(__METHOD__ . '::$_on_photo', '5.0', 'drone_widget_' . str_replace('-', '_', $this->_id) . '_photo filter'); call_user_func_array(self::$_on_photo, array($this, $photo, &$li)); } $html->add($li); } }
protected function getSlider($query) { $html = HTML::ul()->class('slider'); while ($query->have_posts()) { $query->the_post(); if (!has_post_thumbnail()) { continue; } $li = $html->addNew('li'); // Date, title, teaser $caption = HTML::make(); if ($this->so('date')) { $caption->addNew('p')->class('small featured')->add(\Everything::getPostMeta('date')); } if ($this->so('title')) { $caption->addNew('h3')->add(get_the_title()); } if ($this->so('teaser') && ($excerpt = get_the_excerpt())) { $caption->addNew('p')->add($excerpt); } // Featured image $li->addNew('a')->attr(\Everything::getImageAttrs('a'))->href(get_permalink())->add(get_the_post_thumbnail(null, 'auto', array('title' => $caption->html()))); } wp_reset_postdata(); return $html; }