Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#35524 new enhancement

Overwrite default widget templates

Reported by: sebastianpisula's profile 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)

35524.patch (4.4 KB) - added by sebastian.pisula 9 years ago.
First proposal
355241.patch (4.7 KB) - added by sebastian.pisula 9 years ago.
Second proposal

Download all attachments as: .zip

Change History (4)

@sebastian.pisula
9 years ago

First proposal

@sebastian.pisula
9 years ago

Second proposal

#1 @sebastian.pisula
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 @swissspidy
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.

Note: See TracTickets for help on using tickets.