[wp-trac] [WordPress Trac] #33366: if (get_theme_mod()) returns false if 0

WordPress Trac noreply at wordpress.org
Fri Aug 14 12:08:52 UTC 2015


#33366: if (get_theme_mod()) returns false if 0
--------------------------+----------------------
 Reporter:  karlikdesign  |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Customize     |     Version:  4.2.4
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |     Focuses:
--------------------------+----------------------

Comment (by karlikdesign):

 oh whoops! You're right. That did work :)

 Really appreciate your help!!!

 Replying to [comment:1 westonruter]:
 > @karlikdesign: Thanks for the report. Actually this is not a bug because
 in PHP the value of `0` is “false-y”. You can see the values in PHP that
 are considered `false` in a boolean context via the
 [http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
 PHP Manual].
 >
 > So all you have to do is change your conditional to check for the
 `false` value explicitly with a not-identical comparison:
 >
 > {{{#!php
 > <?php if ( false !== get_theme_mod( 'apw_header_cta_padding_bottom' ) )
 : ?>
 > }}}
 >
 > You probably want to report such future issues to the
 [https://wordpress.org/support/ WordPress Support forums] first before
 opening a Core Trac ticket. Thanks!

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33366#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list