Opened 7 years ago
Closed 10 months ago
#7695 closed enhancement (wontfix)
Move widget markup to theme templates
Reported by: | boonebgorges | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Templates | Keywords: | 2nd-opinion |
Cc: |
Description
Widget markup is currently hardcoded into the widget classes. See eg BP_Groups_Widget::widget()
. This is bad for two broad reasons:
- 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 bygroups_ajax_widget_groups_list()
.
- 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?
Change History (6)
This ticket was mentioned in Slack in #buddypress by dcavins. View the logs.
7 years ago
#3
@
7 years ago
- Milestone changed from Awaiting Review to Under Consideration
Broadly agree that this would be nice, and would fit in line with moving the profile field type partials out.
Do you have interest in doing this work for one of the next few releases?
Possibly related: #7159