Making WordPress.org

Changeset 13292


Ignore:
Timestamp:
03/07/2024 02:46:32 AM (3 years ago)
Author:
dd32
Message:

Plugin Directory: Readme: Parse the first readme header when the readme contains a '=== Plugin Name ===' header.

Follow up to [13162].

See #7428.

File:
1 edited

Legend:

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

    r13262 r13292  
    240240                $this->name = $this->sanitize_text( trim( $line, "#= \t\0\x0B" ) );
    241241
     242                // It's possible to leave the plugin name header off entirely..
     243                if ( $this->parse_possible_header( $line, true /* only valid headers */ ) ) {
     244                        array_unshift( $contents, $line );
     245
     246                        $this->warnings['invalid_plugin_name_header'] = true;
     247                        $this->name                                   = false;
     248                }
     249
    242250                // Strip Github style header\n==== underlines.
    243251                if ( ! empty( $contents ) && '' === trim( $contents[0], '=-' ) ) {
    … …  
    255263                        if ( strlen( $line ) < 50 && ! $this->parse_possible_header( $line, true /* only valid headers */ ) ) {
    256264                                $this->name = $this->sanitize_text( trim( $line, "#= \t\0\x0B" ) );
    257                         }
    258                 }
    259 
    260                 // It's possible to leave the plugin name header off entirely.
    261                 if ( $this->parse_possible_header( $this->name, true /* only valid headers */ ) ) {
    262                         array_unshift( $contents, $line );
    263 
    264                         $this->warnings['invalid_plugin_name_header'] = true;
    265                         $this->name                                   = false;
     265                        } else {
     266                                // Put it back on the stack to be processed.
     267                                array_unshift( $contents, $line );
     268                        }
    266269                }
    267270
Note: See TracChangeset for help on using the changeset viewer.