[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 21:57:10 UTC 2023


#59587: Pass column count to "after_plugin_row" action hooks in
WP_Plugins_List_Table
----------------------------+-------------------------
 Reporter:  TobiasBg        |       Owner:  (none)
     Type:  enhancement     |      Status:  closed
 Priority:  normal          |   Milestone:
Component:  Administration  |     Version:
 Severity:  normal          |  Resolution:  worksforme
 Keywords:                  |     Focuses:
----------------------------+-------------------------
Changes (by TobiasBg):

 * keywords:  has-patch dev-feedback =>
 * status:  new => closed
 * resolution:   => worksforme
 * milestone:  6.5 =>


Comment:

 @afragen, thanks for your persistence! Your suggestion will in fact work
 nicely, with just a small modification.
 There's no need to reinstantiate WP_Plugins_List_Table, but we can simply
 reuse the existing global variable that is already available:
 So, instead of
 {{{
 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
 }}}
 this line will do:
 {{{
 global $wp_list_table;
 }}}

 This does not suffer from the duplicated class instantiation and the
 involved computational cost but allows retrieving that column count number
 from inside the action hook handler -- so no need for passing that as a
 parameter anymore :-)

 I'll resolve this as "worksforme", as we found a suitable solution (which
 even is an optimization for your plugin). Thanks for working on this with
 me!

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


More information about the wp-trac mailing list