#14776 closed defect (bug) (fixed)
'manage_' . screen . '_columns' filter not working
Reported by: | arena | Owned by: | |
---|---|---|---|
Milestone: | 3.1 | Priority: | normal |
Severity: | major | Version: | |
Component: | Administration | Keywords: | |
Focuses: | Cc: |
Description
in 3.0 i am using this filter to initialize the columns list in order to have them checkable with the "screen options" tab.
in 3.1 this do not work !
Change History (10)
#1
@
14 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
#2
@
14 years ago
- Resolution invalid deleted
- Status changed from closed to reopened
- Type changed from defect (bug) to feature request
Ok, but could you give a sample how to use your classes for an admin page plugin (list and page)
thank you
#3
@
14 years ago
- Resolution set to worksforme
- Status changed from reopened to closed
Sure.
Example class:
class Example_List_Table extends WP_List_Table { function __construct() { parent::WP_List_Table( array( 'screen' => 'item', 'plural' => 'items', ) ); } function prepare_items() { $this->items = get_items(); $this->set_pagination_args( array( 'total_items' => 100, 'per_page' => 10 ) ); } function get_columns() { return array( 'cb' => '<input type="checkbox" />', 'name' => 'Name', 'color' => 'Color', ); } function column_cb( $item ) { return '<input type="checkbox" name="delete_items[]" value="' . $item->id . '">'; } function column_name( $item ) { return $item->name; } function column_color( $item ) { return $item->color; } function column_default( $item, $column_name ) { return apply_filters( "manage_items_custom_column", '', $column_name, $item->id ); } }
How you use it:
function example_init() { require dirname(__FILE__) . '/example-list-table.class.php'; global $wp_list_table; $wp_list_table = new Example_List_Table; } add_action('admin_init', 'example_init'); // later... $wp_list_table->prepare_items(); $wp_list_table->display();
Mockup get_items() function:
function get_items() { $items = array(); $items[] = (object) array( 'id' => 1, 'name' => 'First item', 'color' => 'red', ); $items[] = (object) array( 'id' => 2, 'name' => 'Second item', 'color' => 'green', ); return $items; }
Note: you don't need to re-open the ticket to leave a reply.
#5
@
14 years ago
I'm afraid the loss of this filter will break existing plugins. It'll break mine as far as I can tell.
#6
@
14 years ago
The filter is still there.
It just needs either register_column_headers() or a WP_List_Table instance called first.
#7
@
14 years ago
- Milestone set to 3.1
- Resolution worksforme deleted
- Severity changed from major to blocker
- Status changed from closed to reopened
- Type changed from feature request to defect (bug)
Per discussion in IRC.
#8
@
14 years ago
- Severity changed from blocker to major
As a clarification, this only affects plugins that create completely new tables.
I.e., it still works for tables of posts, comments etc.
As I've said in #14651 (http://core.trac.wordpress.org/ticket/14651#comment:11) you should be using register_column_headers() instead.