Making WordPress.org


Ignore:
Timestamp:
09/29/2020 06:46:43 AM (5 years ago)
Author:
dd32
Message:

Plugin Directory: When splitting the post content into sections, trim any leading newlines off the content to prevent the section -> content pairs being off.

This prevents a PHP Notice when the resulting array was previously [ '', 'description', 'content here..', .. instead of [ 'description', '..

File:
1 edited

Legend:

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

    r10267 r10316  
    15181518     */
    15191519    public function split_post_content_into_pages( $content ) {
    1520         $_pages        = preg_split( '#<!--section=(.+?)-->#', $content, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
     1520        $_pages        = preg_split( '#<!--section=(.+?)-->#', ltrim( $content ), - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
    15211521        $content_pages = array(
    15221522            'screenshots' => '[wporg-plugins-screenshots]',
     
    15291529            // Don't overwrite existing tabs.
    15301530            if ( ! isset( $content_pages[ $_pages[ $i ] ] ) ) {
    1531                 $content_pages[ $_pages[ $i ] ] = $_pages[ $i + 1 ];
     1531                $content_pages[ $_pages[ $i ] ] = $_pages[ $i + 1 ] ?? '';
    15321532            }
    15331533        }
Note: See TracChangeset for help on using the changeset viewer.