Just curious what developers think about extending the WP_List_Table
class for use on plug-ins.
I am working on a plug-in that will show a list of users (ID, name, email) then pull data from another plug-in that created a subscription date and access level in the user meta table.
The plug-in will be in the admin area of WP and only available to administrators.
I was hoping to use the class to be able to select multiple users and edit the data of multiple users at one time.
Is the class safe to use in this case or should the table be re-created?
Its not a private class, only its methods (some) are defined as private so as long as you extend the class and use your own instance of theme extention you should bs safe and fine.
Known issue
The only thing were you shouldn’t use the
class WP_List_Table
without checking if it is already in use, is inside a meta box.Reason
Using it would break the columns of one of the meta boxes as there’s only one filter to setup the screen columns per screen.
Filters
manage_{$screen->id}_columns
insideget_column_headers()
manage_{$screen->id}_columnshidden
insideget_hidden_columns()
They’re located in
~/wp-admin/includes/screen.php
.Solution #1
Check if there’s already a callback attached to those filters.
Disclaimer: I’m not aware of other issues, but there maybe some.
Solution #2
As @Bainternet described and as you can read in the Codex, here’s a short example:
Then simply use your own instance like this: