Ejemplo n.º 1
0
 /**
  * Returns the title attribute for the given term
  *
  * @param UTCW_Term $term
  *
  * @return string
  * @since 2.4
  */
 private function getTitle(UTCW_Term $term)
 {
     $title = '';
     switch ($this->config->title_type) {
         case 'counter':
             $term_title_singular = $this->plugin->applyFilters('utcw_render_term_title_singular', '%d topic');
             $term_title_plural = $this->plugin->applyFilters('utcw_render_term_title_plural', '%d topics');
             $title = _n($term_title_singular, $term_title_plural, $term->count, 'utcw');
             if (strpos($title, '%d') !== false) {
                 $title = sprintf(' title="' . $title . '"', $term->count);
             }
             break;
         case 'name':
             $title = sprintf(' title="%s"', $term->name);
             break;
         case 'custom':
             $template = $this->config->title_custom_template;
             $stringPosition = strpos($template, '%s');
             $numberPosition = strpos($template, '%d');
             $containsString = $stringPosition !== false;
             $containsNumber = $numberPosition !== false;
             $stringFirst = $stringPosition < $numberPosition;
             if ($containsString && $containsNumber && $stringFirst) {
                 $title = sprintf(' title="' . $template . '"', $term->name, $term->count);
             } elseif ($containsString && $containsNumber) {
                 $title = sprintf(' title="' . $template . '"', $term->count, $term->name);
             } elseif ($containsString) {
                 $title = sprintf(' title="' . $template . '"', $term->name);
             } elseif ($containsNumber) {
                 $title = sprintf(' title="' . $template . '"', $term->count);
             } else {
                 $title = sprintf(' title="%s"', $template);
             }
             break;
     }
     return $title;
 }