Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Ruben Jusiong

Issues with acp/filtering/dropdown_args hook

Hello Support

Today we upgraded the plugin from an older version to 6.4+ which means that the dropdowns is now populated through AJAX.
Unfortunately we are no longer able to modify the dropdowns anymore with the dropdown_args hook.

We follow the procedure as outlined here: https://github.com/codepress/admin-columns-hooks/blob/master/acp-filtering-dropdown_args.php

Here is our code that is no longer working:

function acp_custom_7it_dato_sortering( $args, AC\Column $column ) {
	if ( $column instanceof AC\Column\Meta && 'dato_for_levering' === $column->get_meta_key() ) {
		$new = $args['options'];
		uksort($new,function($a,$b){
			$au = strtotime(str_replace("/","-",$a));
			$bu = strtotime(str_replace("/","-",$b));
			return $bu <=> $au;
		});
		$args['options'] = $new;
		unset($args['order']);
	}
	$args['limit'] = 1000;
	return $args;
}

add_filter( 'acp/filtering/dropdown_args', 'acp_custom_7it_dato_sortering', 10, 2 );

We are only receiving 500-ish results with AJAX, even with the
$args['limit'] = 1000;

This implies that the hook is not working at all. Are there new hooks implemented for the new AJAX methods?

Best regards,
Patrick @ 7it ApS

3 weeks ago
Stefan van den Dungen Gronovius
Developer

Since 6.4, our Filtering logic now works on top of our Smart Filtering logic. The old method that filtering used to populate the drop-down boxes was very heavy on performance. The list of options can now be searched on the fly. Depending on the column type, we use the WordPress queries to fetch the available options. That said, there is no uniform way to alter the options in the drop-down, because every query might be different. I don’t see an alternative to what you’re trying to do in your example.

1 week ago

You must be logged in to reply to this topic.