Opened 3 years ago

Closed 3 years ago

#15318 closed defect (bug) (fixed)

Can't add custom columns to the plugins admin page

Reported by: scribu Owned by:
Priority: normal Milestone: 3.1
Component: Administration Version: 3.1
Severity: normal Keywords: needs-patch
Cc: WordPress@…, edward@…

Description

The Plugins list table is different from all the rest, in the sense that it uses more than one row per item (simplified):

<tr>
  <td>Plugin Name</td>
  <td>Description</td>
</tr>

<tr class="second">
  <td>Activate | Delete</td>
  <td>Version 1.0 | By: someone</td>
</tr>

<tr class="plugin-update-tr">
  <td class="plugin-update" colspan="3">There's an update available</td>
</tr>

I assume this approach was chosen to make the action links stay at the bottom, when the description is larger.

Problems:

  • plugins can't add custom columns
  • columns can't be hidden

Supposing these two problems were fixed, we'd still have to have a weird workaround for the colspan attribute in the update notification row.

I suggest we switch to a single row per item and use CSS to position the elements.

Attachments (7)

class-wp-plugins-list-table.16235.diff (3.6 KB) - added by edward mindreantre 3 years ago.
Selected checkbox fix, description tr td fixed.
class-wp-plugins-list-table.17732.diff (3.6 KB) - added by edward mindreantre 3 years ago.
common.dev.js.17732.diff (1.0 KB) - added by edward mindreantre 3 years ago.
list-table.dev.js-17732.diff (588 bytes) - added by edward mindreantre 3 years ago.
2010-11-13_1646.diff (5.2 KB) - added by edward mindreantre 3 years ago.
All patches in one file.
15318.ms.themes.patch (6.9 KB) - added by ocean90 3 years ago.
colspan_magic.patch (5.1 KB) - added by ocean90 3 years ago.

Download all attachments as: .zip

Change History (29)

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 3.1
  • Version set to 3.1

At the moment we have the problem with the "Show on screen" and "Description" option, see screenshot: http://grab.by/7dY4

  • Cc WordPress@… added

If someone's going to refactor class-wp-plugins-list-table.php maybe they could also add column sorting.

#14987 might be possible to implement at the same time.

Note: CSS positioning on table-cells doesn't work.

Selected checkbox fix, description tr td fixed.

  • Cc edward@… added

Two things have been fixed:

  1. Accessability rules say that (1) each checkbox needs a label and (2) every label should be unique. I've whipped something up that fulfills both criteria.
  1. Lower down I've moved the description stuff around. It's all now just one tr per plugin and the description gets hidden when using that there "show on screen" checkbox. The more observant of y'all will notice that the select checkbox column becomes enormous when the description is hidden, so a line or two in the css should solve that problem if my solution is satisfactory.

edward mindreantre, thx for the patch. 2 things:

Notice: Undefined variable: plugin_name in /wordpress/wp-admin/includes/class-wp-plugins-list-table.php on line 386

Also after a reload or using the navigation, only the title will be hidden again.

Fixed: Description column is hidden when reloading
Fixed: Namn column width is set to auto in order for the checkbox column to not take up half the table.

That should do it. I have no idea why the checkbox and name columns want 50% each...

Anything else broken?

Switching to a next site via AJAX page navi hides the title only again.

I believe the new list-table.js will solve your problem.

Unfortunately it has to run the .hide column() routine thing when switching pages which makes it look sorta weird for a few milliseconds. I haven't found where it sets each column width to 50% per default.

I tried setting the cb-column width to max-width 40px or whatever but it doesn't listen. Not after running .hide() on that column. It seems as if .hide() makes the table recalculate column widths.

Can we has-patch this yet? :)

  • Keywords has-patch added; needs-patch removed

I so hate it when I don't receive email notifications on tickets I've openened.

Common practice is to have all modified files in a single patch.

All patches in one file.

(In [16346]) Move network only status check out of foreach. See #15318

(In [16347]) Introduce WP_Plugins_List_table:single_row(). See #15318

(In [16348]) Add 'manage_plugin_custom_column' action and properly hide plugin columns. See #15318

(In [16349]) Rename action to 'manage_plugins_custom_column' to be consistent with other screens. See #15318

Initial commit was [16345]

(In [16350]) Make custom plugin columns hideable. See #15318

  • Keywords needs-patch added; has-patch removed

Only thing left is to figure out what to do with plugin-update-tr.

comment:19 follow-up: ↓ 20   scribu3 years ago

ocean90 pointed out that WP_MS_Themes_List_Table needs the same treatment.

ocean903 years ago

comment:20 in reply to: ↑ 19   ocean903 years ago

Replying to scribu:

ocean90 pointed out that WP_MS_Themes_List_Table needs the same treatment.

Done with 15318.ms.themes.patch.

(In [16361]) Rework WP_MS_Themes_List_Table column display. Props ocean90. See #15318

ocean903 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [16368]) Introduce WP_List_Table::get_column_count() and take care of update notice <tr>. Props ocean90 for initial patch. Fixes #15318

Note: See TracTickets for help on using tickets.