Skip to content

Commit

Permalink
adds option to hide terms
Browse files Browse the repository at this point in the history
  • Loading branch information
kasprzyk-sz committed Nov 14, 2024
1 parent 8b03b95 commit bc4260d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
padding: 2px 5px;
background-color: #E58F9E;
}
.statusHidden {
width: fit-content;
padding: 2px 5px;
background-color: #D0D0CE;
}



Expand Down
13 changes: 11 additions & 2 deletions wp-content/plugins/embl-taxonomy/includes/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,16 @@ public function embl_taxonomy_column_content($content, $column_name, $term_id) {
// $content = '<code>' . get_term_meta($term_id, EMBL_Taxonomy::META_NAME, true) . '</code>';
} elseif ($column_name === 'embl_taxonomy_meta_deprecated') {
$deprecatedValue = get_term_meta($term_id, EMBL_Taxonomy::META_DEPRECATED, true);
$statusClass = $deprecatedValue == '1' ? 'statusDeprecated' : 'statusActive';
$statusText = $deprecatedValue == '1' ? 'Deprecated' : 'Active';
$excludeTerms = get_field('field_embl_taxonomy_exclude', 'option'); // Get excluded terms

// Check if the current term is in the excluded terms
if (in_array($term_id, $excludeTerms)) {
$statusClass = 'statusHidden';
$statusText = 'Hidden';
} else {
$statusClass = $deprecatedValue == '1' ? 'statusDeprecated' : 'statusActive';
$statusText = $deprecatedValue == '1' ? 'Deprecated' : 'Active';
}

$content = '<p class="' . $statusClass . '">' . $statusText . '</p>';
}
Expand Down Expand Up @@ -140,6 +148,7 @@ public function register_taxonomy() {
'hierarchical' => false,
'public' => $is_news_theme, // true only for the news theme
'show_ui' => true,
'meta_box_cb' => false,
'show_in_menu' => true,
'show_admin_column' => true,
'show_in_rest' => true,
Expand Down
28 changes: 28 additions & 0 deletions wp-content/plugins/embl-taxonomy/includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,34 @@ function acf_init() {
)
);

acf_add_local_field(
array(
'parent' => 'group_embl_taxonomy_setings',
'key' => 'field_embl_taxonomy_exclude',
'label' => 'Exclude terms',
'name' => 'embl_taxonomy_exclude',
'type' => 'taxonomy',
'instructions' => 'Select terms that should by excluded by taxonomy sync',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'taxonomy' => 'embl_taxonomy',
'add_term' => 0,
'save_terms' => 0,
'load_terms' => 0,
'return_format' => 'id',
'field_type' => 'multi_select', // Changed to multi_select for multiple selections
'allow_null' => 1,
'bidirectional' => 0,
'multiple' => 1, // Set to 1 to allow multiple selections
'bidirectional_target' => [],
)
);

// New field group specifically for Deprecated checkbox
acf_add_local_field_group(array(
'key' => 'group_embl_taxonomy_deprecated',
Expand Down

0 comments on commit bc4260d

Please sign in to comment.