WordPress.org

Making WordPress.org

Changeset 1539


Ignore:
Timestamp:
05/04/2015 07:48:18 PM (6 years ago)
Author:
iandunn
Message:

WordCamp Post Type: Accept shortcode parameters regardless of case.

Fixes #1016
Props pixolin

File:
1 edited

Legend:

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

    r1538 r1539  
    277277        ), $attr );
    278278
     279        foreach ( array( 'orderby', 'order', 'track', 'speaker_link' ) as $key_for_case_sensitive_value ) {
     280            $attr[ $key_for_case_sensitive_value ] = strtolower( $attr[ $key_for_case_sensitive_value ] );
     281        }
     282
    279283        $attr['show_avatars'] = $this->str_to_bool( $attr['show_avatars'] );
    280284        $attr['orderby']      = in_array( $attr['orderby'],      array( 'date', 'title', 'rand' ) ) ? $attr['orderby']      : 'date';
     
    406410
    407411        $attr['show_avatars'] = $this->str_to_bool( $attr['show_avatars'] );
     412        $attr['orderby'] = strtolower( $attr['orderby'] );
    408413        $attr['orderby'] = ( in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ) ? $attr['orderby'] : 'date';
    409414
     
    457462            'session_link' => 'permalink', // permalink|anchor|none
    458463        ), $attr );
     464
     465        foreach ( array( 'tracks', 'speaker_link', 'session_link' ) as $key_for_case_sensitive_value ) {
     466            $attr[ $key_for_case_sensitive_value ] = strtolower( $attr[ $key_for_case_sensitive_value ] );
     467        }
    459468
    460469        if ( ! in_array( $attr['speaker_link'], array( 'anchor', 'wporg', 'permalink', 'none' ) ) )
     
    819828
    820829    /**
    821      * Converts 'true'/'yes'/true to true, the rest are false.
     830     * Convert a string representation of a boolean to an actual boolean
    822831     */
    823832    function str_to_bool( $value ) {
    824         if ( $value == 'yes' || $value == 'true' || $value === true )
     833        $value = strtolower( trim( $value ) );
     834
     835        if ( true === $value || in_array( $value, array( 'yes', 'true', '1' ) ) ) {
    825836            return true;
     837        }
     838
    826839        return false;
    827840    }
     
    851864
    852865        // Clean up other attributes.
     866        foreach ( array( 'track', 'speaker_link', 'orderby', 'order' ) as $key_for_case_sensitive_value ) {
     867            $attr[ $key_for_case_sensitive_value ] = strtolower( $attr[ $key_for_case_sensitive_value ] );
     868        }
     869
    853870        $attr['avatar_size'] = absint( $attr['avatar_size'] );
    854871
     
    10201037        ), $attr );
    10211038
     1039        $attr['link'] = strtolower( $attr['link'] );
    10221040        $terms = $this->get_sponsor_levels();
    10231041
Note: See TracChangeset for help on using the changeset viewer.