From c77b836dfc52399110f829ca837bee058e26de4d Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 6 Nov 2026 15:40:04 +0400 Subject: [PATCH 1/2] HTML API: Correct the output comment in the class_list() example. The example prints each class name followed by a space, so its output has no quotes and ends with a space. The output comment wrapped that output in quotes, so the Code Reference showed output the code never prints. The comment now states the output as a JSON-encoded string, which shows the trailing space. --- src/wp-includes/html-api/class-wp-html-tag-processor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index 7e047c4808081..d129f378ba2d1 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -1197,7 +1197,7 @@ public function paused_at_incomplete_token(): bool { * foreach ( $p->class_list() as $class_name ) { * echo "{$class_name} "; * } - * // Outputs: "free lang-en " + * // Outputs (JSON-encoded): "free lang-en " * ``` * * @since 6.4.0 From 1410702e13723493da67e0b93b3b1e8b8d5b96b3 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 6 Nov 2026 21:50:51 +0400 Subject: [PATCH 2/2] HTML API: Print one class name per line in the class_list() example. A JSON-encoded output comment is harder to read than the output it states. Printing each class name on its own line lets the multiline output comment state the output as plain text, with a final empty line for the trailing newline. --- src/wp-includes/html-api/class-wp-html-tag-processor.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index d129f378ba2d1..389afcc84beb0 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -1195,9 +1195,13 @@ public function paused_at_incomplete_token(): bool { * $p = new WP_HTML_Tag_Processor( "
" ); * $p->next_tag(); * foreach ( $p->class_list() as $class_name ) { - * echo "{$class_name} "; + * echo "{$class_name}\n"; * } - * // Outputs (JSON-encoded): "free lang-en " + * // Outputs: + * // free + * // + * // lang-en + * // * ``` * * @since 6.4.0