Making WordPress.org


Ignore:
Timestamp:
12/20/2021 07:21:54 AM (3 years ago)
Author:
dd32
Message:

Handbooks: Table of Contents: The first <h[1-6]> element on the page may not be the one we wish to duplicate, if we've removed a HTML-only heading from the content.

Avoids PHP Notices and ensures that the correct heading level is generated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php

    r11366 r11390  
    132132        }
    133133
    134         $contents_header = 'h' . $items[0]['level']; // Duplicate the first <h#> tag in the document for the TOC header
     134        $contents_header = 'h' . reset( $items )['level']; // Duplicate the first <h#> tag in the document for the TOC header
    135135        $toc            .= $this->styles;
    136136        $toc            .= '<div class="table-of-contents">';
Note: See TracChangeset for help on using the changeset viewer.