Skip to:
Content

BuddyPress.org

Opened 20 months ago

Last modified 20 months ago

#7695 new enhancement

Move widget markup to theme templates

Reported by: boonebgorges Owned by:
Milestone: Awaiting Contributions 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:

  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().
  1. 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 (5)

#1 @boonebgorges
20 months ago

Possibly related: #7159

This ticket was mentioned in Slack in #buddypress by dcavins. View the logs.


20 months ago

#3 @DJPaul
20 months 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?

#4 @DJPaul
20 months ago

  • Component changed from Core to Templates
  • Milestone changed from Under Consideration to Awaiting Contributions

#5 @DJPaul
20 months ago

  • Type changed from defect (bug) to enhancement
Note: See TracTickets for help on using tickets.