[wp-trac] [WordPress Trac] #38133: Default widget title used if instance title is "0" (was: Widget output empty if input is zero)
WordPress Trac
noreply at wordpress.org
Thu Sep 22 20:16:01 UTC 2016
#38133: Default widget title used if instance title is "0"
---------------------------+-----------------------------
Reporter: hardeepasrani | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Widgets | Version: 2.6
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: administration
---------------------------+-----------------------------
Changes (by westonruter):
* keywords: => needs-patch
* version: trunk => 2.6
* milestone: Awaiting Review => Future Release
Old description:
> If you put a single zero 0 in default widgets, it won't output any thing.
> You can try putting a 0 in any widget title or content. It works if you
> put 00 or anything else.
>
> The reason being our use of `empty( $variable )` and `! empty( $variable
> )` in the default widgets. `empty` returns FALSE if var exists and has a
> non-empty, non-zero value.
>
> So it will be better to use `isset( $variable) && $variable != ''`
> instead. Wanted to submit a patch but wanted to know if above method will
> be the best one.
New description:
If you put a single zero 0 as the title in default widgets, it won't
output any thing. You can try putting a 0 in any widget title or content.
It works if you put 00 or anything else.
The reason being our use of `empty( $variable )` and `! empty( $variable
)` in the default widgets. `empty` returns FALSE if var exists and has a
non-empty, non-zero value.
So it will be better to use `isset( $variable) && $variable != ''`
instead. Wanted to submit a patch but wanted to know if above method will
be the best one.
--
Comment:
@hardeepasrani good catch. Yes, the `isset( $variable) && $variable !==
''` check would be better over using `! empty( $variable )`. (Note `!==`
instead of `!=`.)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38133#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list