Open giuliodelmastro opened 3 months ago
Thanks for your feedback.
Do you mean replacing the instance of the list table class with your own? Or ability to change the class name?
I'd love to hear more details on this. And what exactly do you need with that? Can't the current class satisfy the needs?
Oh excuse me for the late answer! I really appreciate your interest!
I would like to replace the class instance with mine. This is possible in the core through the hook
apply_filters( 'wp_list_table_class_name', string $class_name, array $args )
But using custom templates instead of the classic post type this hook obviously doesn’t work anymore.
Your table has no problem on simple CRUD, but working on complex architectures or with a lot of logic becomes a little limiting and with a result "dirty" approach to customize it using hooks
Hi @giuliodelmastro
Currently, the code to create an instance of list table class is this:
$this->list_table = new ListTable( [
'model' => $this->model,
] );
I'm going to change it to:
$args = [
'model' => $this->model,
];
$list_table = new ListTable( $args );
$this->list_table = apply_filters( 'mbct_list_table_object', $list_table, $args );
So this adds a filter to the object of the list table class (not the class name as in your code). This way, you can modify the object (create your own class, instantiate it and then pass to the filter).
Does that help you?
Thank you!!! This is great news! Can I test it and give you feedback?
Sure. Check your mail, I send a message.
Thank you!!
Using the extension MB Custom table is currently not possible to replace the table List_Table. It would therefore be useful to have a hook to replace it with a custom.