Example #1
0
 /**
  * Get terms of one/many taxonomies
  *
  * @param string $taxonomy            The name of the taxonomy
  * @param string $terms_of_taxonomies Array of terms of taxonomies
  * @param array  $args                Array of query parameters
  */
 static function term_of_taxonomy($taxonomy, &$terms_of_taxonomies, $args = array())
 {
     $args = array_merge(array('hide_empty' => false), $args);
     $terms = get_terms(array($taxonomy), $args);
     $term_slug_name = array();
     foreach ($terms as $term) {
         $term_slug_name[PT_CV_Functions::term_slug_sanitize($term->slug)] = $term->name;
     }
     // Sort values of param by saved order
     $term_slug_name = apply_filters(PT_CV_PREFIX_ . 'settings_sort_single', $term_slug_name, $taxonomy . '-' . 'terms');
     $terms_of_taxonomies[$taxonomy] = $term_slug_name;
 }
Example #2
0
 /**
  * Get terms list of a post
  *
  * @param object $post The post object
  *
  * @return string
  */
 static function post_terms($post)
 {
     global $pt_cv_glb, $pt_cv_id;
     if (!isset($pt_cv_glb['item_terms'])) {
         $pt_cv_glb['item_terms'] = array();
     }
     // List of HTML link to terms
     $links = array();
     // Get list of taxonomies
     $taxonomies = get_taxonomies('', 'names');
     // List of taxonomies to show
     $taxonomies_to_show = apply_filters(PT_CV_PREFIX_ . 'taxonomies_to_show', $taxonomies);
     // Get post ID
     $post_id = is_object($post) ? $post->ID : $post;
     // Get lists of terms of this post
     $terms = wp_get_object_terms($post_id, $taxonomies);
     foreach ($terms as $term) {
         $include_this = apply_filters(PT_CV_PREFIX_ . 'terms_include_this', true, $term);
         if ($include_this && in_array($term->taxonomy, $taxonomies_to_show)) {
             $href = esc_url(get_term_link($term, $term->taxonomy));
             $text = __('View all posts in', 'content-views-query-and-display-post-page');
             $term_name = esc_attr($term->name);
             $class = esc_attr(PT_CV_PREFIX . 'tax-' . PT_CV_Functions::term_slug_sanitize($term->slug));
             $term_html = "<a href='{$href}' title='{$text} {$term_name}' class='{$class}'>{$term->name}</a>";
             $links[] = apply_filters(PT_CV_PREFIX_ . 'post_term_html', $term_html, $term);
         }
         // Add this term to terms list of an item
         if (!isset($pt_cv_glb['item_terms'][$post_id])) {
             $pt_cv_glb['item_terms'][$post_id] = array();
         }
         $pt_cv_glb['item_terms'][$post_id][PT_CV_Functions::term_slug_sanitize($term->slug)] = $term->name;
     }
     $separator = apply_filters(PT_CV_PREFIX_ . 'post_terms_separator', ', ');
     return implode($separator, apply_filters(PT_CV_PREFIX_ . 'terms_list', $links, $pt_cv_id));
 }
Example #3
0
 /**
  * Get terms list of a post
  *
  * @param object $post The post object
  *
  * @return string
  */
 static function post_terms($post)
 {
     global $pt_cv_glb, $pt_cv_id;
     if (!isset($pt_cv_glb['item_terms'])) {
         $pt_cv_glb['item_terms'] = array();
     }
     // List of HTML link to terms
     $links = array();
     // Get list of taxonomies
     $taxonomies = get_taxonomies('', 'names');
     $taxonomies = apply_filters(PT_CV_PREFIX_ . 'taxonomies_list', $taxonomies);
     // Get post ID
     $post_id = is_object($post) ? $post->ID : $post;
     // Get lists of terms of this post
     $terms = wp_get_object_terms($post_id, $taxonomies);
     foreach ($terms as $term) {
         $include_this = apply_filters(PT_CV_PREFIX_ . 'terms_include_this', true, $term);
         if ($include_this) {
             $href = esc_url(get_term_link($term, $term->taxonomy));
             $text = __('View all posts in', PT_CV_TEXTDOMAIN);
             $term_name = esc_attr($term->name);
             $class = esc_attr(PT_CV_PREFIX . 'tax-' . PT_CV_Functions::term_slug_sanitize($term->slug));
             $links[] = "<a href='{$href}' title='{$text} {$term_name}' class='{$class}'>{$term->name}</a>";
         }
         // Add this term to terms list of an item
         if (!isset($pt_cv_glb['item_terms'][$post_id])) {
             $pt_cv_glb['item_terms'][$post_id] = array();
         }
         $pt_cv_glb['item_terms'][$post_id][PT_CV_Functions::term_slug_sanitize($term->slug)] = $term->name;
     }
     // Adjust terms list
     return implode(', ', apply_filters(PT_CV_PREFIX_ . 'terms_list', $links, $pt_cv_id));
 }