[wp-trac] [WordPress Trac] #59587: Pass column count to "after_plugin_row" action hooks in WP_Plugins_List_Table

WordPress Trac noreply at wordpress.org
Tue Oct 10 19:19:18 UTC 2023


#59587: Pass column count to "after_plugin_row" action hooks in
WP_Plugins_List_Table
----------------------------+-----------------------
 Reporter:  TobiasBg        |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  6.5
Component:  Administration  |    Version:
 Severity:  normal          |   Keywords:  has-patch
  Focuses:                  |
----------------------------+-----------------------
 A site's list of plugins on /wp-admin/plugins.php is generated by the
 WP_Plugins_List_Table class.

 This generates an HTML table with one row for each plugin.
 The number of columns in that table can vary, depending on a user's
 capabilities, singlesite/multisite, etc.
 The number of columns is available via the inherited `get_column_count()`
 method, and it's e.g. used when Core shows an update notice in a row with
 a `colspan` (where the `colspan` has to match the number of columns, to
 not break the HTML code).

 The WP_Plugins_List_Table also offers actions hooks `after_plugin_row` and
 `after_plugin_row_{$plugin_file}` that run after each printed table row,
 commonly used by plugins to also insert extra rows into the HTML table.
 (As the hooks run in between the rendering of an HTML table, inserting a
 new row is pretty much the only possible output that such an action can
 do.)

 However, plugins then face the challenge that they do not know the number
 of visible columns in the table, as they can not access the
 `get_column_count()` method from within the action hook function, as they
 don't have access to the WP_Plugins_List_table object.

 Therefore, it would be reasonable to pass the `get_column_count()` value
 as an extra parameter to the `after_plugin_row` and
 `after_plugin_row_{$plugin_file}` action hooks.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59587>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list