WordPress.org

Making WordPress.org

Changeset 5205


Ignore:
Timestamp:
03/30/2017 05:57:41 AM (2 years ago)
Author:
dd32
Message:

Plugin Directory: When the Short description isn't provided, pull it from the main plugin description after markdown has been parsed - this allows the parser to strip out unwanted markup in the description.

Fixes #2643

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php

    r5195 r5205  
    319319        $this->sections = array_filter( $this->sections );
    320320
    321         // Use the first line of the description for the short description if not provided.
    322         if ( empty( $this->short_description ) && ! empty( $this->sections['description'] ) ) {
    323             $this->short_description = array_filter( explode( "\n", $this->sections['description'] ) )[0];
    324         }
    325 
    326321        // Use the short description for the description section if not provided.
    327322        if ( empty( $this->sections['description'] ) ) {
     
    352347        $this->upgrade_notice = array_map( array( $this, 'parse_markdown' ), $this->upgrade_notice );
    353348        $this->faq            = array_map( array( $this, 'parse_markdown' ), $this->faq );
     349
     350        // Use the first line of the description for the short description if not provided.
     351        if ( ! $this->short_description && ! empty( $this->sections['description'] ) ) {
     352            $this->short_description = array_filter( explode( "\n", $this->sections['description'] ) )[0];
     353        }
    354354
    355355        // Sanitize and trim the short_description to match requirements.
     
    576576        $heading_style = 'bold'; // 'heading' or 'bold'
    577577        foreach ( $trimmed_lines as $trimmed ) {
    578             if ( $trimmed[0] == '#' || $trimmed[0] == '=' ) {
     578            if ( $trimmed && ( $trimmed[0] == '#' || $trimmed[0] == '=' ) ) {
    579579                $heading_style = 'heading';
    580580                break;
Note: See TracChangeset for help on using the changeset viewer.