id = sanitize_key($id);
$this->taxonomy = jvbCheckBase($taxonomy);
$this->name = jvbNoBase($taxonomy);
$this->base = $config['base']??'';
$this->config = wp_parse_args($config, [
'types' => false, //for feed block implementation
'max' => 0,
'search' => true,
'createNew' => false,
'required' => false,
'hidden' => false,
'update' => false,
]);
$this->plural = JVB_TAXONOMY[$taxonomy]['plural'];
$this->singular = JVB_TAXONOMY[$taxonomy]['singular'];
}
/**
* Mark that selectors are present (called when rendering toggles)
*/
public static function markSelectorsPresent(): void {
self::$hasSelectors = true;
}
/**
* Get the full path for a term (for hierarchical taxonomies)
*
* @param WP_Term $term The term object
* @return string The full term path
*/
public static function getTermPath($term): string {
if (!$term || is_wp_error($term)) {
return '';
}
if (!is_taxonomy_hierarchical($term->taxonomy)) {
return $term->name;
}
$path = [];
$currentTerm = $term;
while ($currentTerm) {
array_unshift($path, $currentTerm->name);
if ($currentTerm->parent) {
$currentTerm = get_term($currentTerm->parent);
if (is_wp_error($currentTerm)) {
break;
}
} else {
break;
}
}
return implode(' → ', $path);
}
/**
* Output the single modal dialog in footer
*/
public static function outputSelector(): void {
echo self::getSingleModalHTML();
remove_action('wp_footer', [self::class, 'outputSelector']);
}
/**
* Get the single modal HTML structure
*/
public static function getSingleModalHTML(): string {
ob_start();
?>
{ loading items } { nothing found }