Jake Vanderwerf
5 days ago a9b3b28d001941921aa70d37fdc87c758a163a44
inc/helpers/terms.php
@@ -1,9 +1,24 @@
<?php
use JVBase\registrar\Registrar;
if (!defined('ABSPATH')) {
   exit;
}
function jvbGetTermOwners(int $termID, bool $includeManagers = true):array
{
   $owners = get_term_meta($termID, BASE.'owners', true);
   $owners = empty($owners) ? [] : $owners;
   if ($includeManagers) {
      $managers = get_term_meta($termID, BASE.'managers', true);
      $managers = empty($managers) ? [] : $managers;
      $owners = array_merge($owners, $managers);
   }
   return $owners;
}
/**
 * @param string $term
 * @param int|false $ID
@@ -41,6 +56,29 @@
    return $out;
}
function jvbMetaTermList(string $value, string $tax, bool $icon = true):string
{
   if ($value === '') {
      return '';
   }
   $tax = jvbCheckBase($tax);
   $terms = array_map('absint', explode(',', $value));
   $out = [];
   foreach ($terms as $t) {
      $term = get_term($t, $tax);
      if ($term && !is_wp_error($term)) {
         $url = get_term_link($t, $tax);
         $out[] = '<li><a href="'.$url.'" title="View more in '.$term->name.'" rel="tag">'.$term->name.'</a></li>';
      }
   }
   $registrar = Registrar::getInstance($tax);
   $icon = ($icon && $registrar) ? $registrar->getIcon() : '';
   $icon = ($icon === '') ? '' : jvbIcon($icon);
   $title = $registrar ? '<li class="title">'.$icon.$registrar->getSingular().'</li>' : '';
   return (!empty($out)) ? '<ul class="term-list row left '.jvbNoBase($tax).'">'.$title.implode('',$out).'</ul>' : '';
}
/**
 * @param int $artistID
 * @param string $taxonomy
@@ -103,7 +141,8 @@
    if ($users === '') {
        $term = get_term($termID);
        $taxonomy = $term->taxonomy;
        if (taxIsJVBContentTax($taxonomy)) {
      $registrar = Registrar::getInstance($taxonomy);
        if ($registrar->hasFeature('is_content')) {
            $posts = new WP_Query([
                'post_type'    => jvbCheckBase($user),
                'posts_per_page'    => -1,