Opened 9 years ago
Last modified 5 years ago
#35524 new enhancement
Overwrite default widget templates
Reported by: | sebastian.pisula | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Widgets | Keywords: | |
Focuses: | Cc: |
Description
I have two proposal for layout in default widget. I think that developer should have possibility to overwrite widget layout. I suggest value of widget method add to new directory: wp-includes/widget-templates and add if:
<?php public function widget( $args, $instance ) { $widget_template = 'widget-templates/recent-posts.php'; if ( $template = locate_template( $widget_template ) ) { include $template; } else { include ABSPATH . WPINC . '/' . $widget_template; } }
Developer can overwrite widget layout in theme.
Attachments (2)
Change History (4)
#1
@
9 years ago
But I think now that if user want overwrite widget then he can unregister WordPress widget and register custom. What is the situation when selling theme? ThemeForest accept if developer remove native wordpress widgets?
#2
@
9 years ago
But I think now that if user want overwrite widget then he can unregister WordPress widget and register custom.
That's how it currently works, yes. The difficulty with the proposed patch is that each widget is just so different. If you create a template file for a widget, you as a developer have no idea what variables you have access to.
It would probably make more sense to just being able to filter the whole widget output, though I currently do not see any value in that.
What is the situation when selling theme? ThemeForest accept if developer remove native wordpress widgets?
That's not something we should or need to care about.
First proposal