[wp-trac] [WordPress Trac] #56025: wp_validate_boolean() not doing what it describes, causes issues with [video] shortcode

WordPress Trac noreply at wordpress.org
Fri Aug 29 14:31:44 UTC 2025


#56025: wp_validate_boolean() not doing what it describes, causes issues with
[video] shortcode
------------------------------------+------------------------------
 Reporter:  arnodeleeuw             |       Owner:  (none)
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  General                 |     Version:  6.0
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+------------------------------

Comment (by callumbw95):

 Hi @karpstrucking,

 I have just come across this ticket, and after reviewing the initial
 "falsey list" approach, I'd like to propose we consider flipping the logic
 to use a "truthy list" instead. My main concern with the original approach
 is that it defaults to true for any unrecognised string, which could lead
 to unexpected behaviour.

 Here’s a quick summary of why I think a "truthy list" is a safer and more
 robust approach:

 - **It's Safer by Default**: This approach works on an "allow list"
 principle. We explicitly define what is true. Anything else—including
 typos, empty values, or unexpected inputs—will safely default to false.
 This prevents a feature from being accidentally enabled.

 - **It's More Explicit**: The code becomes self-documenting about what
 values are considered active or "on". There's no ambiguity.

 - **It Avoids Unintended Consequences**: With a "falsey list," an input
 like 'truu' or 'ok' would evaluate to true. The proposed method correctly
 identifies these as false.

 I have put in a [https://github.com/WordPress/wordpress-develop/pull/9670
 PR] in with this change now, so please let me know your thoughts. 😃

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


More information about the wp-trac mailing list