WordPress.org

Making WordPress.org

Changeset 2205


Ignore:
Timestamp:
12/18/2015 06:05:51 PM (5 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Display nested hash parameters in a nested fashion.

This just improves the hack used to parse hash parameter notation since the parser doesn't recognize hash parameters as anything more than a bunch of text. Previously it only displayed all hash parameters peer to each other regardless of nesting depth.

For examples of nested hash parameters, see:

Fixes #1479.

File:
1 edited

Legend:

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

    r2174 r2205  
    12121212            $part = preg_replace( '/\s+/', ' ', $part );
    12131213            list( $wordtype, $type, $name, $description ) = explode( ' ', $part, 4 );
     1214            $description = trim( $description );
     1215
     1216            $skip_closing_li = false;
     1217
     1218            // Handle nested hashes.
     1219            if ( '{' === $description[0] ) {
     1220                $description = substr( $description, 1 ) . '<ul class="param-hash">';
     1221                $skip_closing_li = true;
     1222            } elseif ( '}' === substr( $description, -1 ) ) {
     1223                $description = substr( $description, 0, -1 ) . "</li></ul>\n";
     1224            }
    12141225
    12151226            if ( '@type' != $wordtype ) {
     
    12281239                }
    12291240
    1230                 $new_text .= "<b>'" . substr( $name, 1 ) . "'</b><br /><i><span class='type'>({$type})</span></i> {$description}</li>\n";
     1241                $new_text .= "<b>'" . substr( $name, 1 ) . "'</b><br /><i><span class='type'>({$type})</span></i> {$description}";
     1242                if ( ! $skip_closing_li ) {
     1243                    $new_text .= '</li>';
     1244                }
     1245                $new_text .= "\n";
    12311246            }
    12321247        }
Note: See TracChangeset for help on using the changeset viewer.