Making WordPress.org


Ignore:
Timestamp:
12/23/2015 08:25:53 PM (11 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Show array of arrays notation in nested fashion.

The docblock notation is like that of a hash parameter without a name, which visually had only appeared as an unnamed parameter with all nested elements peer to it.

For an example, see https://developer.wordpress.org/reference/classes/wp_date_query/__construct/

File:
1 edited

Legend:

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

    r2206 r2223  
    12161216
    12171217                        // Handle nested hashes.
    1218                         if ( '{' === $description[0] ) {
    1219                                 $description = substr( $description, 1 ) . '<ul class="param-hash">';
     1218                        if ( '{' === $description[0] || '{' === $name ) {
     1219                                $description = ltrim( $description, '{' ) . '<ul class="param-hash">';
    12201220                                $skip_closing_li = true;
    12211221                        } elseif ( '}' === substr( $description, -1 ) ) {
     
    12381238                                }
    12391239
    1240                                 $new_text .= "<b>'" . substr( $name, 1 ) . "'</b><br /><i><span class='type'>({$type})</span></i> {$description}";
     1240                                // Normalize argument name.
     1241                                if ( $name === '{' ) {
     1242                                        // No name is specified, generally indicating an array of arrays.
     1243                                        $name = '';
     1244                                } else {
     1245                                        // The name is defined as a variable, so remove the leading '$'.
     1246                                        $name = ltrim( $name, '$' );
     1247                                }
     1248                                if ( $name ) {
     1249                                        $new_text .= "<b>'{$name}'</b><br />";
     1250                                }
     1251                                $new_text .= "<i><span class='type'>({$type})</span></i> {$description}";
    12411252                                if ( ! $skip_closing_li ) {
    12421253                                        $new_text .= '</li>';
Note: See TracChangeset for help on using the changeset viewer.