[wp-trac] [WordPress Trac] #24478: The `theme_action_links` filter passes different arguments in different places.

WordPress Trac noreply at wordpress.org
Sat Jun 1 16:45:54 UTC 2013


#24478: The `theme_action_links` filter passes different arguments in different
places.
-----------------------------+--------------------------------------
 Reporter:  georgestephanis  |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Themes           |    Version:  3.5.1
 Severity:  normal           |   Keywords:  needs-patch dev-feedback
-----------------------------+--------------------------------------
 Since r20029 at least, there has been an inconsistency in how core uses
 the `theme_action_links` filter.

 Ordinarily, it's used like this:

 http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/class-wp-
 themes-list-table.php#L151
 `$actions = apply_filters( 'theme_action_links', $actions, $theme );`

 with $theme being a WP_Theme object.

 However, in the Multi Site theme admin panel, it's used like this:

 http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/class-wp-
 ms-themes-list-table.php#L287
 `$actions = apply_filters( 'theme_action_links', array_filter( $actions ),
 $stylesheet, $theme, $context );`

 which means that for any module to successfully function in both contexts,
 it needs to do the following:

 {{{
 function theme_action_links_filter( $actions, $theme, $ms_theme = null ) {
     if ( is_a( $ms_theme, 'WP_Theme' ) ) {
         $theme = $ms_theme;
     }
     // stuff with $theme
     return $actions;
 }
 }}}

 as can be seen in this changeset for a practical implementation:
 http://plugins.trac.wordpress.org/changeset/721178

 If we're using a filter in core, I feel that we should be consistent with
 what sequence parameters are being passed to it, or at least leave a
 comment to devs giving them a heads up that they need to account for the
 other sequence.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/24478>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list