Make WordPress Core

Opened 8 years ago

Last modified 2 years ago

#38805 new defect (bug)

A hook is missing in class WP_List_Table

Reported by: madvic's profile madvic Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 4.6.1
Component: Administration Keywords: 2nd-opinion has-patch
Focuses: Cc:

Description

If I want to add a column to a WP_List_Table, I used this hooks :

  • manage_{$this->screen->id}_columns
  • manage_{$this->screen->id}_sortable_columns
  • manage_{$screen->id}_custom_column

But the last one doesn't exist in WP_List_Table, I can create a column but I can't insert data into.

Here the documentation :
https://make.wordpress.org/docs/plugin-developer-handbook/10-plugin-components/custom-list-table-columns/#output-table-cell-contents

Here the source of WP_List_Table :
https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-list-table.php

Actually, I want to hook a plugin with this hook, I can't add columns.

Thanks

Attachments (2)

38805.diff (1.1 KB) - added by johnregan3 2 years ago.
Initial patch
38805a.diff (1.1 KB) - added by johnregan3 2 years ago.
Same patch. Updated formatting.

Download all attachments as: .zip

Change History (9)

#2 in reply to: ↑ 1 @madvic
8 years ago

Yes it is, but not in WP_List_Table, we can't hook this class. WP_List_Table is not abstract. Ant it used in many projects.

Replying to SergeyBiryukov:

But the last one doesn't exist in WP_List_Table, I can create a column but I can't insert data into.

It exists in classes that extend WP_List_Table though:

Version 0, edited 8 years ago by madvic (next)

#3 follow-ups: @desrosj
5 years ago

  • Keywords 2nd-opinion added

Marking this for a second opinion. The WP_List_Table is meant to be a base class, but the other two filters do exist in WP_List_Table today. So I could see adding this filter.

@madvic is this still a pain point for you?

#4 in reply to: ↑ 3 @madvic
5 years ago

Hi @desrosj ,

I have to used it for projects.
For me the code is not consistent. That's why my ticket.

Replying to desrosj:

Marking this for a second opinion. The WP_List_Table is meant to be a base class, but the other two filters do exist in WP_List_Table today. So I could see adding this filter.

@madvic is this still a pain point for you?

#5 @valentinbora
5 years ago

I'd love to see more thoughts (re. 2nd-opinion) on this from Core folks.

#6 in reply to: ↑ 3 @emilymoran84
4 years ago

  • Severity changed from normal to major

Replying to desrosj:

Marking this for a second opinion. The WP_List_Table is meant to be a base class, but the other two filters do exist in WP_List_Table today. So I could see adding this filter.

@madvic is this still a pain point for you?

@desrosj Has there been any progress on this? I found this thread in my own search for a solution. I am trying to add a custom column to a custom table of an installed plugin. I too followed the same article as @madvic https://make.wordpress.org/docs/plugin-developer-handbook/10-plugin-components/custom-list-table-columns/#output-table-cell-contents

I was able to add the column to the table with

manage_{$this->screen->id}_columns

using the screen ID of that plugin's table page. However, as stated, the

manage_{$screen->id}_custom_column

doesn't seem to exist, so my content won't display in the columns.

As this table isn't a custom post type, or any of the other class available as stated by @SergeyBiryukov , I'm unable to add content with any of those options. This is the screen object readout for that table's page, and you can see that there's no post type, taxonomy, etc for me to use, and since {$screen->id} doesn't work, I'm at a loss:

WP_Screen Object ( [action] => [base] => memberpress_page_memberpress-members [columns:WP_Screen:private] => 0 [id] => memberpress_page_memberpress-members [in_admin:protected] => site [is_network] => [is_user] => [parent_base] => [parent_file] => [post_type] => [taxonomy] => [_help_tabs:WP_Screen:private] => Array ( ) [_help_sidebar:WP_Screen:private] => [_screen_reader_content:WP_Screen:private] => Array ( ) [_options:WP_Screen:private] => Array ( ) [_show_screen_options:WP_Screen:private] => [_screen_settings:WP_Screen:private] => [is_block_editor] => ) 

Being able to add content to the column in this table would be a huge help. I'd love to know if there is a way to do this yet. Thank you!

@johnregan3
2 years ago

Initial patch

#7 @johnregan3
2 years ago

  • Keywords has-patch added

@SergeyBiryukov @desrosj Initial patch added in case there is no more discussion needed.

@johnregan3
2 years ago

Same patch. Updated formatting.

Note: See TracTickets for help on using tickets.