Making WordPress.org


Ignore:
Timestamp:
09/10/2014 10:55:43 PM (11 years ago)
Author:
coffee2code
Message:

Code Reference: properly detect optional status of parameters defined using hash notation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r836 r853  
    500500                        $types[ $i ] = "<span class=\"{$v}\">{$v}</span>";
    501501                    }
     502
     503                    // Normalize spacing at beginning of hash notation params.
     504                    if ( '{' == $tag['content'][0] ) {
     505                        $tag['content'] = '{ ' . trim( substr( $tag['content'], 1 ) );
     506                    }
     507
    502508                    $params[ $tag['variable'] ]['types'] = implode( '|', $types );
    503509                    if ( strtolower( substr( $tag['content'], 0, 9 ) ) == "optional." ) {
    504510                        $params[ $tag['variable'] ]['required'] = 'Optional';
    505511                        $params[ $tag['variable'] ]['content'] = substr( $tag['content'], 10 );
     512                        $encountered_optional = true;
     513                    } elseif ( strtolower( substr( $tag['content'], 2, 9 ) ) == "optional." ) { // Hash notation param
     514                        $params[ $tag['variable'] ]['required'] = 'Optional';
     515                        $params[ $tag['variable'] ]['content'] = '{ ' . substr( $tag['content'], 12 );
    506516                        $encountered_optional = true;
    507517                    } elseif ( $encountered_optional ) {
Note: See TracChangeset for help on using the changeset viewer.