From 34b6a27002aa9784ef69280acd5c6708b69cd1fc Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 6 Apr 2024 13:33:05 -0700 Subject: [PATCH] Reuse WP_HTML_Processor::is_void() --- .../class-od-html-tag-processor.php | 34 ++----------------- plugins/optimization-detective/readme.txt | 1 + 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/plugins/optimization-detective/class-od-html-tag-processor.php b/plugins/optimization-detective/class-od-html-tag-processor.php index 1c2a660087..9c543e0c6c 100644 --- a/plugins/optimization-detective/class-od-html-tag-processor.php +++ b/plugins/optimization-detective/class-od-html-tag-processor.php @@ -21,36 +21,6 @@ */ final class OD_HTML_Tag_Processor { - /** - * HTML void tags (i.e. those which are self-closing). - * - * @link https://html.spec.whatwg.org/multipage/syntax.html#void-elements - * @see WP_HTML_Processor::is_void() - * @todo Reuse `WP_HTML_Processor::is_void()` once WordPress 6.4 is the minimum-supported version. - * - * @var string[] - */ - const VOID_TAGS = array( - 'AREA', - 'BASE', - 'BASEFONT', // Obsolete. - 'BGSOUND', // Obsolete. - 'BR', - 'COL', - 'EMBED', - 'FRAME', // Deprecated. - 'HR', - 'IMG', - 'INPUT', - 'KEYGEN', // Obsolete. - 'LINK', - 'META', - 'PARAM', // Deprecated. - 'SOURCE', - 'TRACK', - 'WBR', - ); - /** * Raw text tags. * @@ -225,7 +195,7 @@ public function open_tags(): Generator { // Immediately pop off self-closing and raw text tags. if ( - in_array( $tag_name, self::VOID_TAGS, true ) + WP_HTML_Processor::is_void( $tag_name ) || in_array( $tag_name, self::RAW_TEXT_TAGS, true ) || @@ -236,7 +206,7 @@ public function open_tags(): Generator { } else { // If the closing tag is for self-closing or raw text tag, we ignore it since it was already handled above. if ( - in_array( $tag_name, self::VOID_TAGS, true ) + WP_HTML_Processor::is_void( $tag_name ) || in_array( $tag_name, self::RAW_TEXT_TAGS, true ) ) { diff --git a/plugins/optimization-detective/readme.txt b/plugins/optimization-detective/readme.txt index a18f4a72b6..6d4b7d3cc8 100644 --- a/plugins/optimization-detective/readme.txt +++ b/plugins/optimization-detective/readme.txt @@ -140,6 +140,7 @@ The [plugin source code](https://github.com/WordPress/performance/tree/trunk/plu = 0.1.1 = * Use plugin slug for generator tag. ([1103](https://github.com/WordPress/performance/pull/1103)) +* Reuse `WP_HTML_Processor::is_void()` now that WP 6.4 is minimum supported version. ([1115](https://github.com/WordPress/performance/pull/1115)) = 0.1.0 =