WordPress.org

Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#9797 closed defect (bug) (fixed)

Widget will not be shown in case of its id includes upper characters

Reported by: kamiyeye Owned by: azaozz
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.8
Component: Widgets Keywords: has-patch commit
Focuses: Cc:

Description

Pre-requisite:

A widget with its id/id_base includes at least one upper character

Repro Steps:

  1. Access the back-end page 'Appearance->Widget'
  1. Drag the widget to a sidebar
  1. Simply refresh the page

Expected Results:

The widget is shown on that sidebar

Actual Results:

The widget isn't shown on that sidebar

Cause:

Before a widget is registered ,the field 'id' is lowered, say:

-- line 557,function wp_register_sidebar_widget,file widgets.php---

  $id = strtolower($id);

But 'id' stored in new WP_Widget class is not lowered:

-- line 90, function __construct, file widgets.php-----------------

$this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : $id_base;

I gathered from these that why the widget isn't shown is because no widgets with such an id(has some upper characters) found in the registered widgets(all ids are lowered), am i right?

P.S.

It tooks me several hours on this issue, i reviewed my widget codes again and again, every time, couldn't found any fault.I were almost mad before i caught the damned issue. Now, it's yours.

Attachments (2)

9797.diff (443 bytes) - added by Denis-de-Bernardy 12 years ago.
9797.2.diff (760 bytes) - added by Denis-de-Bernardy 12 years ago.

Download all attachments as: .zip

Change History (7)

#1 @Denis-de-Bernardy
12 years ago

  • Milestone changed from Unassigned to 2.8

#2 @Denis-de-Bernardy
12 years ago

  • Keywords has-patch commit added; widget removed

either of the above two approaches should work. but the second one might be preferred, if the strtolower() was anything useful.

#3 @ryan
12 years ago

  • Owner set to azaozz

#4 @azaozz
12 years ago

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

(In [11308]) Lowercase widgets $id_base, props Denis-de-Bernardy, fixes #9797

#5 @azaozz
12 years ago

Think it has to be set to lower case since allowing mixed/upper case in wp_register_sidebar_widget() could break older widgets.

Note: See TracTickets for help on using tickets.