[wp-trac] [WordPress Trac] #30351: Input field with HTML tag as default value
WordPress Trac
noreply at wordpress.org
Sun Dec 28 04:15:24 UTC 2014
#30351: Input field with HTML tag as default value
-----------------------------+---------------------------------------------
Reporter: GDragoN | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 4.0
Severity: normal | Resolution: worksforme
Keywords: reporter- | Focuses: ui, javascript, administration
feedback |
-----------------------------+---------------------------------------------
Changes (by valendesigns):
* status: new => closed
* resolution: => worksforme
Comment:
I was able to create a widget that works correctly by building off the
example code from [http://codex.wordpress.org/Widgets_API]. As well, I
sanitized `message`, because the way you had it would allow unwanted code
injections.
I believe the underlying issue was the way you wrote your `form` method
which does not allow the default value to be saved, because the value of
`message` was always an empty string. I didn't want to take too much time
hunting down the exact reason when there is an obvious solution, but it
has something to do with `wp_parse_args` and the order of your arrays. If
you change it to use `$instance = wp_parse_args( $defaults, $instance );`
or `$instance = array_merge( $instance, $defaults );` everything works.
However, the first fix feels wrong, and the second fix will work, but
there are other ways to accomplish your goals.
I don't believe this is an issue with the Core as much as how the code is
written to save/display the form values.
Cheers,
Derek
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30351#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list