WordPress.org

Making WordPress.org

Changeset 1540


Ignore:
Timestamp:
05/04/2015 08:19:43 PM (6 years ago)
Author:
iandunn
Message:

WordCamp Post Types: Maintain boolean values during str_to_bool() conversion.

This fixes a bug introduced in r1539 where a boolean passed to this function would be unintentionally converted to a string, but later treated as though it might still be a boolean.

See #1016
See https://wordpress.slack.com/archives/meta/p1430769561000761

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    r1539 r1540  
    829829    /**
    830830     * Convert a string representation of a boolean to an actual boolean
     831     *
     832     * @param string|bool
     833     *
     834     * @return bool
    831835     */
    832836    function str_to_bool( $value ) {
    833         $value = strtolower( trim( $value ) );
    834 
    835         if ( true === $value || in_array( $value, array( 'yes', 'true', '1' ) ) ) {
     837        if ( true === $value ) {
     838            return true;
     839        }
     840
     841        if ( in_array( strtolower( trim( $value ) ), array( 'yes', 'true', '1' ) ) ) {
    836842            return true;
    837843        }
Note: See TracChangeset for help on using the changeset viewer.