Beispiel #1
0
 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);
     }
 }
 function widget($args, $instance)
 {
     ob_start();
     parent::widget($args, $instance);
     $output = ob_get_clean();
     $output = Everything::woocommerceWidgetParseList($output);
     $output = preg_replace_callback('#' . '<li>' . '<a[^>]*?href="(?P<url>[^"]*)"[^>]*?>\\s*(?P<thumbnail><img[^>]*>)(?P<title>[^<>]*)</a>' . '<div[^>]*class="star-rating"[^>]*><span[^>]*><strong class="rating">(?P<average>[,\\.0-9]+)</strong>[^>]*</span></div>' . '<span class="reviewer">(?P<author>[^<>]*)</span>' . '</li>' . '#i', function ($m) {
         $html = \Drone\HTML::li();
         $html->addNew('figure')->class('alignright fixed')->addNew('a')->attr(Everything::getImageAttrs('a', array('border' => true, 'hover' => '', 'fanbcybox' => false)))->href($m['url'])->title($m['title'])->add($m['thumbnail']);
         $html->addNew('h3')->addNew('a')->href($m['url'])->title($m['title'])->add($m['title']);
         $html->add(Everything::getShortcodeOutput('rating', array('rate' => $m['average'] . '/5', 'author' => $m['author'])));
         return $html->html();
     }, $output);
     echo $output;
 }
Beispiel #3
0
 /**
  * drone_widget_posts_list_post filter
  *
  * @internal filter: drone_widget_posts_list_post
  * @since 1.0
  *
  * @param object $li
  * @param object $widget
  * @param object $post
  */
 public function filterWidgetPostsListPost($li, $widget, $post)
 {
     $li = \Drone\HTML::li();
     if ($widget->wo('thumbnail') && has_post_thumbnail($post->ID)) {
         $li->addNew('figure')->class('alignleft fixed')->addNew('a')->attr(Everything::getImageAttrs('a', array('border' => true, 'hover' => '', 'fanbcybox' => false)))->href(get_permalink($post->ID))->add(get_the_post_thumbnail($post->ID, 'post-thumbnail-mini-crop'));
     }
     if ($widget->wo('date')) {
         $GLOBALS['post'] = $post;
         $li->addNew('p')->class('small')->add(Everything::getPostMeta('date'));
         wp_reset_postdata();
     }
     $li->addNew('h3')->addNew('a')->href(get_permalink($post->ID))->title(esc_attr($post->post_title))->add(wp_trim_words($post->post_title, $widget->wo('limit')));
     if ($widget->wo('comments')) {
         $GLOBALS['post'] = $post;
         $li->addNew('p')->class('small')->add(Everything::getPostMeta('comments_number'));
         wp_reset_postdata();
     }
     return $li;
 }
Beispiel #4
0
 protected function onShortcode($content, $code, \Drone\HTML &$html)
 {
     $html = HTML::li()->title($this->so('title', '__empty', '&nbsp;'))->add(Func::wpShortcodeContent($content));
     if ($this->so('active')) {
         $html->addClass('active');
     }
 }