| <?php |
| |
| add_action('admin_menu', 'hwk_acf_taxonomy_submenu'); |
| function hwk_acf_taxonomy_submenu(){ |
| if(!acf_get_setting('show_admin')) |
| return; |
| |
| $cap = acf_get_setting('capability'); |
| add_submenu_page('edit.php?post_type=acf-field-group', 'Types', 'Types', $cap, 'edit-tags.php?taxonomy=acf-field-group-type'); |
| } |
| |
| add_filter('parent_file', 'hwk_acf_taxonomy_submenu_highlight'); |
| function hwk_acf_taxonomy_submenu_highlight($parent_file){ |
| global $submenu_file, $current_screen, $pagenow; |
| |
| if($current_screen->taxonomy == 'acf-field-group-type' && ($pagenow == 'edit-tags.php' || $pagenow == 'term.php')) |
| $parent_file = 'edit.php?post_type=acf-field-group'; |
| |
| return $parent_file; |
| } |
| |
| add_filter('manage_edit-acf-field-group_columns', 'hwk_acf_taxonomy_column', 11); |
| function hwk_acf_taxonomy_column($columns){ |
| $new = array(); |
| foreach($columns as $key => $value) { |
| if($key == 'title') |
| $new['type'] = 'Type'; |
| |
| $new[$key] = $value; |
| } |
| return $new; |
| } |
| |
| add_action('manage_acf-field-group_posts_custom_column' , 'hwk_acf_taxonomy_column_html', 10, 2 ); |
| function hwk_acf_taxonomy_column_html($column, $post_id){ |
| if($column == 'type'){ |
| if(!$terms = get_the_terms($post_id, 'acf-field-group-type')) |
| return; |
| |
| $final = array(); |
| foreach($terms as $term){ |
| $final[] = '<a href="' . admin_url('edit.php?acf-field-group-type='.$term->slug.'&post_type=acf-field-group') . '">' . $term->name . '</a>'; |
| } |
| |
| echo implode(', ', $final); |
| } |
| } |
| |
| add_filter('views_edit-acf-field-group', 'hwk_acf_taxonomy_column_views', 9); |
| function hwk_acf_taxonomy_column_views($views){ |
| if(!$terms = get_terms('acf-field-group-type', array('hide_empty' => false))) |
| return $views; |
| |
| foreach($terms as $term){ |
| $count = ''; |
| if($term->count > 0) |
| $count = '<span class="count">(' . $term->count . ')</span>'; |
| |
| $views['type-' . $term->slug] = '<a href="' . admin_url('edit.php?acf-field-group-type=' . $term->slug . '&post_type=acf-field-group') . '">' . $term->name . '</a>' . $count; |
| } |
| return $views; |
| } |