Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #55942, comment 63


Ignore:
Timestamp:
05/02/2023 08:34:49 PM (13 months ago)
Author:
azaozz
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #55942, comment 63

    initial v1  
    1414>  - `add_option( 'my_option', false );`
    1515
    16 This touches on "best practices" when using the options API: "All options should be set (and preferably autoloaded)". Currently when you do `add_option( 'my_option', false );` and then `get_option( 'my_option' );`, you get an empty string. That makes it possible to see if the option was set to `false`, but I don't think this is a "good behavior". Ideally whatever you save in the DB should come back the same. Returning strings for boolean and integer values is a long-standing inconsistency. Adding this param would make it easier to fix that.
     16This touches on "best practices" when using the options API: "All options should be set (and preferably autoloaded)". Currently when you do `add_option( 'my_option', false );` and then `get_option( 'my_option' );`, you get an empty string. That makes it possible to see if the option was set to `false`, but I don't think this is a "good behavior". Ideally whatever you save in the DB should come back the same. Returning strings for boolean and integer values is a long-standing inconsistency. Adding this param would make it easier to fix that, and it also reduces calls to maybe_unserialize() a little.