WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9704 closed enhancement (wontfix)

Make the Name of the Widget optional

Reported by: hakre Owned by:
Milestone: Priority: low
Severity: minor Version: 2.8
Component: Widgets Keywords: has-patch
Focuses: Cc:

Description

Per default a Widget should have the name of it's own class. That helps prototyping new Widgets because there is no need to over-ride the default Widgets Class constructor.

This established Documentation conform behavior as well because it is written:

 * This class must be extended for each widget and WP_Widget::widget(), WP_Widget::update()
 * and WP_Widget::form() need to be over-ridden.

Without the patch the constructor function needs to be over-ridden as well. With the patch, the comment above is true then.

Attachments (2)

9704.patch (1.2 KB) - added by hakre 5 years ago.
making $name optional by defaulting to the class'es name.
9704.2.patch (1.2 KB) - added by hakre 5 years ago.
Defaults to nice default-id or id if no name present.

Download all attachments as: .zip

Change History (9)

hakre5 years ago

making $name optional by defaulting to the class'es name.

comment:1 hakre5 years ago

  • Keywords has-patch added

comment:2 Denis-de-Bernardy5 years ago

same for id_base

comment:3 Denis-de-Bernardy5 years ago

err. disregard that last remake. it would make more sense to make the id_base optional imo. but it's probably a bit too late now. there have been a few posts on the dev blog related to how to create wp widgets, and surely quite a few blogs have picked them up and parroted the stuff in it.

comment:4 follow-up: azaozz5 years ago

  • Priority changed from normal to low
  • Severity changed from normal to minor
  • Type changed from defect (bug) to enhancement

The important setting here is $id_base as it's used for the name of option when the widget's data is saved as well as for the css classname and some other places.

The $name is displayed to the user so it should be user friendly. We can make it optional with default = $id_base, but preferably all widgets should have proper names.

comment:5 azaozz5 years ago

  • Component changed from General to Widgets
  • Owner anonymous deleted

comment:6 in reply to: ↑ 4 Denis-de-Bernardy5 years ago

  • Milestone 2.8 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Replying to azaozz:

The $name is displayed to the user so it should be user friendly.

and thus translatable. closing as wontfix as a result.

comment:7 hakre5 years ago

Yeah preferable, all _should_ (as you write) have propper names but must not. Same for translation.

Let's say you write a prototype widget and want to get it run fast. If the name is optional as well, you can fully skip to subclass the constructor. that easy it is.

so i see no problem at all with not having a super-propper name or no translations afterwards with it. it is just for rapid prototyping. what's the deal?

hakre5 years ago

Defaults to nice default-id or id if no name present.

Note: See TracTickets for help on using tickets.