Fixed All Tags not highlighted
This commit is contained in:
parent
190a69a57d
commit
dae88d68d3
|
|
@ -14,21 +14,9 @@ class MediaManager {
|
||||||
|
|
||||||
add_action('init', [ $this, 'register_structure' ]);
|
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('add_meta_boxes', [ $this, 'create_tag_management_box' ]);
|
||||||
add_action('edit_attachment', [ $this, 'save_tags' ]);
|
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('restrict_manage_posts', [ $this, 'show_list_filter' ]);
|
add_action('restrict_manage_posts', [ $this, 'show_list_filter' ]);
|
||||||
add_filter('pre_get_posts', [ $this, 'apply_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' => "<select name='attachments[{$post->ID}][ttgf_media_hidden]'><option></option><option value='hidden'>Hidden</option></select>"
|
|
||||||
];*/
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function show_list_filter() {
|
public function show_list_filter() {
|
||||||
global $typenow;
|
global $typenow;
|
||||||
|
|
||||||
|
|
@ -159,14 +126,17 @@ class MediaManager {
|
||||||
'orderby' => 'name',
|
'orderby' => 'name',
|
||||||
'hierarchical' => true,
|
'hierarchical' => true,
|
||||||
'value_field' => 'term_id',
|
'value_field' => 'term_id',
|
||||||
|
'selected' => 0,
|
||||||
'depth' => 3,
|
'depth' => 3,
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
'echo' => 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('<select ', '<select multiple ', $filter_dropdown);
|
$filter_dropdown = str_replace('<select ', '<select multiple ', $filter_dropdown);
|
||||||
$filter_dropdown = str_replace(" selected='selected'>", ">", $filter_dropdown);
|
if ( array_search("0", $selected) === false ) {
|
||||||
|
$filter_dropdown = str_replace(" selected='selected'>", ">", $filter_dropdown);
|
||||||
|
}
|
||||||
foreach ( $selected as $sid ) {
|
foreach ( $selected as $sid ) {
|
||||||
$filter_dropdown = str_replace("value=\"{$sid}\">", "value=\"{$sid}\" selected>", $filter_dropdown);
|
$filter_dropdown = str_replace("value=\"{$sid}\">", "value=\"{$sid}\" selected>", $filter_dropdown);
|
||||||
}
|
}
|
||||||
|
|
@ -178,19 +148,21 @@ class MediaManager {
|
||||||
'orderby' => 'name',
|
'orderby' => 'name',
|
||||||
'hierarchical' => true,
|
'hierarchical' => true,
|
||||||
'value_field' => 'term_id',
|
'value_field' => 'term_id',
|
||||||
|
'$selected' => 0,
|
||||||
'depth' => 3,
|
'depth' => 3,
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
'echo' => false
|
'echo' => false
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$selected = isset( $_GET[ $excluded_name ] ) ? $_GET[ $excluded_name ] : [ $this->tags->get_by_name("Generated")->id ];
|
$selected = array_key_exists($excluded_name, $_GET) && ! empty($_GET[$excluded_name]) ? $_GET[ $excluded_name ] : [ $this->tags->get_by_name("Generated")->id ];
|
||||||
$excluded_dropdown = str_replace('<select ', '<select multiple ', $excluded_dropdown);
|
$excluded_dropdown = str_replace('<select ', '<select multiple ', $excluded_dropdown);
|
||||||
$excluded_dropdown = str_replace(" selected='selected'>", ">", $excluded_dropdown);
|
if ( array_search(0, $selected) === false ) {
|
||||||
|
$excluded_dropdown = str_replace(" selected='selected'>", ">", $excluded_dropdown);
|
||||||
|
}
|
||||||
foreach ( $selected as $sid ) {
|
foreach ( $selected as $sid ) {
|
||||||
$excluded_dropdown = str_replace("value=\"{$sid}\">", "value=\"{$sid}\" selected>", $excluded_dropdown);
|
$excluded_dropdown = str_replace("value=\"{$sid}\">", "value=\"{$sid}\" selected>", $excluded_dropdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "<label for='{$filter_name}'>Inkludierte Tags</label>";
|
echo "<label for='{$filter_name}'>Inkludierte Tags</label>";
|
||||||
echo $filter_dropdown;
|
echo $filter_dropdown;
|
||||||
echo "<label for='{$excluded_name}'>Excludierte Tags</label>";
|
echo "<label for='{$excluded_name}'>Excludierte Tags</label>";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue