From dae88d68d3829f9abd71742fd797b18a8bd36366 Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 24 Apr 2026 21:09:21 +0200 Subject: [PATCH] Fixed All Tags not highlighted --- src/media.php | 50 +++++++++++--------------------------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/src/media.php b/src/media.php index 9f7a226..35b542c 100644 --- a/src/media.php +++ b/src/media.php @@ -14,20 +14,8 @@ class MediaManager { add_action('init', [ $this, 'register_structure' ]); - add_filter('attachment_fields_to_edit', [ $this, 'create_edit_media_control' ], 10, 2); add_action('add_meta_boxes', [ $this, 'create_tag_management_box' ]); - add_action('edit_attachment', [ $this, 'save_tags' ]); - - // Dont know what it does - add_filter( 'update_post_term_count_statuses', function( $statuses, $taxonomy ) { - - if( 'folders' === $taxonomy->name ) { - $statuses[] = 'inherit'; - $statuses = array_unique( $statuses ); - } - return $statuses; - - }, 25, 2 ); + add_action('edit_attachment', [ $this, 'save_tags' ]); add_action('restrict_manage_posts', [ $this, 'show_list_filter' ]); add_filter('pre_get_posts', [ $this, 'apply_list_filter' ]); @@ -121,27 +109,6 @@ class MediaManager { } } - public function create_edit_media_control( $fields, $post ) { - - /*$terms = get_terms([ 'taxonomy' => 'ttgf_media_tags', 'hide_empty' => false ]); - - $fields['ttgf_media_tags'] = [ - 'label' => 'Tags', - 'input' => 'html', - 'html' => $this->_build_dropdown("attachments[{$post->ID}][ttgf_media_tags]", - array_map(function ($term) { return [ 'value' => $term->id, 'name' => $term->name ]; }, $terms), - $post->ID) - ]; - - $fields['ttgf_media_hidden'] = [ - 'label' => 'Folder Attributes', - 'input' => 'html', - 'html' => "" - ];*/ - - return $fields; - } - public function show_list_filter() { global $typenow; @@ -159,14 +126,17 @@ class MediaManager { 'orderby' => 'name', 'hierarchical' => true, 'value_field' => 'term_id', + 'selected' => 0, 'depth' => 3, 'hide_empty' => false, 'echo' => false ]); - $selected = isset( $_GET[ $filter_name ] ) ? $_GET[ $filter_name ] : []; + $selected = array_key_exists($filter_name, $_GET) && ! empty($filter_name) ? $_GET[ $filter_name ] : [ "0" ]; $filter_dropdown = str_replace('", ">", $excluded_dropdown); + if ( array_search(0, $selected) === false ) { + $excluded_dropdown = str_replace(" selected='selected'>", ">", $excluded_dropdown); + } foreach ( $selected as $sid ) { $excluded_dropdown = str_replace("value=\"{$sid}\">", "value=\"{$sid}\" selected>", $excluded_dropdown); } - echo ""; echo $filter_dropdown;