[wp-trac] [WordPress Trac] #51699: The only correct method to check for existence of option

WordPress Trac noreply at wordpress.org
Tue Nov 3 13:49:28 UTC 2020


#51699: The only correct method to check for existence of option
--------------------------+------------------------------
 Reporter:  ttodua        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by apedog):

 Testing with {{{if ( get_option('some_option') !== false )}}} will not
 return false negatives for {{{null}}}, {{{0}}}, {{{''}}}.
 But will still miss boolean {{{false}}}... :/

 This seems to me like a useful method.
 I think {{{SELECT 1}}} in the query would be more appropriate. You don't
 want to return the option. You want to return a boolean.

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


More information about the wp-trac mailing list