Ticket #6549 (new defect)

Opened 5 months ago

Last modified 2 months ago

Output broken in wp-admin/widgets.php

Reported by: hakre Assigned to: anonymous
Priority: normal Milestone: 2.9
Component: General Version:
Severity: normal Keywords: Output
Cc:

Description

While calling my.blog/wp-admin/widgets.php the output is somewhat incomplete. Take a look in the source and you find stuff like:

"<label for="categories-title-%i%">"

that is not only invalid output it looks like the work in the file has not been finished or there has been put one % to much in a (s)printf call.

Change History

04/02/08 14:41:35 changed by mtekk

tom, could you provide more information into what you did to produce this bug? At the minimum it would be nice to know what widgets you used when you observed the bug.

04/02/08 15:20:00 changed by hakre

Yes I will do later on, just wanted to ticket my observation because this is live in a customers project. Will upload more info later on, I guess this is easily patchable.

04/03/08 00:06:50 changed by hakre

Okay, now I have got more Infos on the Issue:

This is "by Design". The %i% inside the ID is part of a codeblock that is used by some javascript as a pattern to create valid sourcecode later on. See line 62ff in widgets.js (?ver=20080319).

One solution which comes into my tired getting mind is to put the pattern-sourcecode inside a html comment (<!-- ... -->) and then use jQuery to create the elements later on. This would only slightly modify the code and would work quite the same. The only problem that comes into my mind is when a widget has got a HTML comment in it's own output.

I could verify this Idea by modifying the source:

wp-admin/includes/widgets.php line 91 ff

$widget_control_template = sprintf('%s<!-- %s -->%s', $sidebar_args['before_widget'], $widget_control_template, $sidebar_args['after_widget']);

wp-admin/js/widget.js: ~ line 63

		var oldLi = $(this).parents('li:first').find('ul.widget-control-info li');		
		var comment = oldLi.html();
		var pattern = comment.substr(5, comment.length - 8);
		var newLi = oldLi.clone();
		newLi.html(pattern);

I dunno wether this work with "multi widgets" because I know none sothat I could test it against it. But if I read the code right, it should work. With all the other widgets, this worked.

(follow-up: ↓ 5 ) 04/16/08 23:42:19 changed by Denis-de-Bernardy

imo, this is asking for trouble... any widget with, not just a -->, but also a --, will break.

(in reply to: ↑ 4 ) 06/13/08 04:57:45 changed by hakre

Replying to Denis-de-Bernardy:

imo, this is asking for trouble... any widget with, not just a -->, but also a --, will break.

can you explain to me why even -- will break it?

07/15/08 16:24:07 changed by ryan

  • milestone changed from 2.5.2 to 2.9.

Milestone 2.5.2 deleted