[buddypress-trac] [BuddyPress Trac] #7695: Move widget markup to theme templates

buddypress-trac noreply at wordpress.org
Mon Feb 19 15:09:26 UTC 2018


#7695: Move widget markup to theme templates
--------------------------+-----------------------------
 Reporter:  boonebgorges  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Core          |    Version:
 Severity:  normal        |   Keywords:  2nd-opinion
--------------------------+-----------------------------
 Widget markup is currently hardcoded into the widget classes. See eg
 `BP_Groups_Widget::widget()`. This is bad for two broad reasons:

 1. AJAX callbacks have to completely duplicate the markup. That is: on
 first render, `BP_Groups_Widget::widget()` builds the markup, but when you
 click one of the AJAX filters like 'Active', it's built completely
 separately by `groups_ajax_widget_groups_list()`.

 2. In general, there are no hooks or filters available within the
 `widget()` methods to customize output. Your only choice is to fork the
 widget, which because of 1, also means forking the AJAX callback.

 The most natural way to solve this would be by moving the markup to
 template files, which could then be overridden in the normal WP way. That
 change would require a bit of thought, as we'd need to have an idiomatic
 way of passing in the `$args` and `$instance` variables from the
 `WP_Widget::widget()` method; while they'd be in scope inside of
 `get_template_part()`, we generally use template functions rather than
 directly referencing variables in templates.

 There are other ways to increase customizability, but I think this is the
 most WPish way. What do others think?

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7695>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list