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); } }
public function shortcode($atts, $content = null, $code = '') { $atts = $atts ? (array) $atts : array(); $this->options = $this->getOptions($atts); self::$call_stack[] = $this->tag; $html = HTML::make(); $this->onShortcode($content, $code, $html); $html = \Drone\apply_filters('shortcode_' . $this->tag . '_shortcode', $html, $this, $atts, $content, $code); array_pop(self::$call_stack); return $html->html(); }