Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#6108 closed defect (bug) (fixed)

In admin, current widgets should show something more identifiable than the type of widget

Reported by: mdawaffe Owned by: mdawaffe
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.5
Component: Administration Keywords: widgets has-patch 2nd-opnion
Focuses: Cc:


Currently, if you have multiple text widgets, you just see them listed as "Text", "Text", ... in the "Current Widgets" section.

It'd be nice if the widgets instead were listed as "Text: foo", "Text: bar", ... where 'foo' and 'bar' are taken from the widget's title or content or something (for all widgets, not just text widgets).

Attached are two patches. Both output titles as "{widget_type}: {extracted_text}". The first patch accomplishes this via JS, the second via PHP.

JS Patch:

Each widget in the "Current Widgets" section is scanned for visible text inputs and textareas. If any are found, the first 22 text characters of the first input element found are used as the {extracted_text}.

Pros: Not much code change.
Cons: Not super robust.

PHP Patch:

The display of the "Current Widgets" section is switched to a hacked dynamic_sidebar() (similar in concept to the dashboard widgets code). While displaying each widget control form, the on-blog widget itself is output_buffered and its title extracted for use as the {extracted_text}.

The use of the dynamic_sidebar and output buffering is necessary because WP has no way of determining the title that will be displayed on-blog of some random widget; widget's neither store nor output their content in any standard way.

Pros: More robust. If a widget outputs a title on-blog, this code will catch it.
Cons: A lot of code change, much of which is a bit hacky.

Attachments (2)

widget-titles-js.diff (1.3 KB) - added by mdawaffe 10 years ago.
JS Patch
widget-titles-ob.diff (8.2 KB) - added by mdawaffe 10 years ago.
PHP Patch

Download all attachments as: .zip

Change History (7)

10 years ago

JS Patch

10 years ago

PHP Patch

#1 @mdawaffe
10 years ago

  • Owner changed from anonymous to mdawaffe
  • Status changed from new to assigned

#2 @mdawaffe
10 years ago

It should be said that the widget code is already a bit hacky :)

#3 @matt
10 years ago

This is good to go in, but for some reason my fickle patch tool will not apply it. Could it be done as a single patch? I don't want to screw it up applying by hand.

#4 @mdawaffe
10 years ago

They are separate and mutually exclusive patches. I'm sorry that was unclear.

We either pick the first method and use that patch: all JS.

Or we pick the second method and use that patch: all PHP.

#5 @ryan
10 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [7219]) Make titles for multiple instances of a widget distinct. Props mdawaffe. fixes #6108

Note: See TracTickets for help on using tickets.