Ejemplo n.º 1
0
 public function test_lets_translation_handler_create_term_when_enabled()
 {
     $plugin = $this->mockFactory->getUTCWMock();
     $handler = $this->getMockForAbstractClass('UTCW_TranslationHandler');
     $this->wpdb->expects($this->once())->method('get_results')->will($this->returnValue(array($this->term)));
     $handler->expects($this->once())->method('createTerm')->with($this->get_term(), $plugin);
     $plugin->set('translationHandler', $handler);
     $plugin->set('wpdb', $this->wpdb);
     $config = new UTCW_DataConfig(array(), $plugin);
     $plugin->set('dataConfig', $config);
     $data = new UTCW_Data($plugin);
     $data->getTerms();
 }
Ejemplo n.º 2
0
 function helper_query_contains($instance, $string, $authenticated = false)
 {
     $utcw = $authenticated ? $this->mockFactory->getUTCWAuthenticated() : $this->mockFactory->getUTCWNotAuthenticated();
     $utcw->expects($this->any())->method('checkTermTaxonomy')->will($this->returnValue(true))->with($this->anything(), $this->contains('post_tag'));
     $config = new UTCW_DataConfig($instance, $utcw);
     $db = $this->mockFactory->getWPDBMock();
     $db->expects($this->once())->method('get_results')->will($this->returnValue(array()))->with($this->stringContains($string));
     $utcw->set('wpdb', $db);
     $utcw->set('dataConfig', $config);
     $data = new UTCW_Data($utcw);
     $data->getTerms();
 }
Ejemplo n.º 3
0
 /**
  * Returns the cloud as a string
  *
  * @return string
  * @since 2.0
  */
 public function getCloud()
 {
     $markup = array();
     if ($this->css) {
         $markup[] = $this->plugin->applyFilters('utcw_render_css', $this->css);
     }
     if ($this->config->before_widget) {
         // If theme styling should be avoided, keep the utcw specific classes
         if ($this->config->avoid_theme_styling) {
             $markup[] = $this->config->before_widget;
         } else {
             $markup[] = str_replace('widget_utcw', 'widget_utcw widget_tag_cloud', $this->config->before_widget);
         }
     }
     if ($this->config->show_title_text) {
         if ($this->config->before_title) {
             $markup[] = $this->config->before_title;
         }
         $markup[] = $this->plugin->applyFilters('widget_title', $this->config->title);
         if ($this->config->after_title) {
             $markup[] = $this->config->after_title;
         }
     }
     $classes = array('utcw-' . $this->id);
     if (!$this->config->avoid_theme_styling) {
         $classes[] = 'tagcloud';
     }
     $markup[] = '<div class="' . join(' ', $classes) . '">';
     $termObjects = $this->plugin->applyFilters('utcw_render_terms', $this->data->getTerms());
     $terms = array();
     foreach ($termObjects as $term) {
         $color = $term->color ? ';color:' . $term->color : '';
         $title = '';
         if ($this->config->show_title) {
             $title = $this->getTitle($term);
         }
         $tag = $this->config->show_links ? 'a' : 'span';
         $tag = $this->plugin->applyFilters('utcw_render_tag', $tag);
         $displayName = $this->config->show_post_count ? sprintf('%s (%d)', $term->name, $term->count) : $term->name;
         $displayName = $this->plugin->applyFilters('utcw_render_term_display_name', $displayName, $term->name);
         $terms[] = sprintf('%s<%s class="tag-link-%s utcw-tag utcw-tag-%s" href="%s" style="font-size:%s%s"%s>%s</%s>%s', $this->config->prefix, $tag, $term->term_id, $term->slug, $term->link, $term->size, $color, $title, $displayName, $tag, $this->config->suffix);
     }
     if ($this->config->display === 'list') {
         $markup[] = '<ul>';
         $terms = array_map(create_function('$term', 'return sprintf("<li>%s</li>", $term);'), $terms);
     }
     $markup[] = join($this->config->separator, $terms);
     if ($this->config->display === 'list') {
         $markup[] = '</ul>';
     }
     $markup[] = '</div>';
     if ($this->config->debug) {
         $debug_object = clone $this->data;
         $debug_object->cleanupForDebug();
         $markup[] = sprintf("<!-- Ultimate Tag Cloud Debug information:\n%s -->", print_r($debug_object, true));
     }
     if ($this->config->after_widget) {
         $markup[] = $this->config->after_widget;
     }
     return do_shortcode(join('', $markup));
 }