Using WP_List_Table in a Plugin

I am not completely familiar with OOP, but I know the basics. I am creating a Wordpress plugin and you need to create a table (html) on the plugin page. I read that in WP 3.1 there is a WP_List_Table class that can generate the necessary markup.

Can someone give me a very basic idea on how to use this? Do I need to create a child class to use it?

+4
source share
3 answers
+1
source

Yes, you need to create a child class to extend the properties of the parent class. I duplicated wp-admin/plugins.php and wp-admin/includes/class-wp-plugins-list-table.php and moved these files to my plugin.

Then I did all the engineering work to make it work with the current plugin I was working on. I also found an error in the process that was already reported and about the work.

Error found at http://core.trac.wordpress.org/ticket/15386 .

In short, this is never executed when the child class is executed from the plugin.

 list($columns, $hidden) = $this->get_column_info(); 

As a job, I commented on the code above and directly passed the method to what it was looking for:

 $columns = $this->get_columns(); $hidden = $sortable = array(); 

If you have hidden or sortable columns, you can also call their methods directly, but I don't need them for my implementation.

After a few hours, I now understand what the class is doing, and I have a working model. and when the error is fixed, it will be a little better;)

+1
source

This article is very good regarding WP-List-Table: http://wp.smashingmagazine.com/2011/11/03/native-admin-tables-wordpress/

+1
source

Source: https://habr.com/ru/post/1343084/


All Articles