From 6ccf8b9a331e4345dfdb18aabad7d69b577e1d0a Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Mon, 20 Jul 2026 19:44:55 +0200 Subject: [PATCH 1/3] Update WP_HTML_Processor::class_list example to runnable snippet --- .../html-api/class-wp-html-processor.php | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index b2a597b938495..401b322446fae 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -5431,14 +5431,30 @@ public function has_class( $wanted_class ): ?bool { * * This generator function is designed to be used inside a "foreach" loop. * - * Example: - * - * $p = WP_HTML_Processor::create_fragment( "
" ); - * $p->next_tag(); - * foreach ( $p->class_list() as $class_name ) { - * echo "{$class_name} "; - * } - * // Outputs: "free lang-en " + * ```php + * " ); + * $p->next_tag(); + * foreach ( $p->class_list() as $class_name ) { + * var_dump( $class_name ); + * } + * ``` + * ```expected-output + * string(4) "free" + * string(5) "" + * string(7) "lang-en" + * ``` * * @since 6.6.0 Subclassed for the HTML Processor. */ From c4ec0fc4446dbe597b2d18db99d730cb20e99cc1 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 13 Aug 2026 15:48:56 +0400 Subject: [PATCH 2/3] Cleanup demo code --- src/wp-includes/html-api/class-wp-html-processor.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index 401b322446fae..b4c590ef5141a 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -5431,16 +5431,6 @@ public function has_class( $wanted_class ): ?bool { * * This generator function is designed to be used inside a "foreach" loop. * - * ```php - * Date: Thu, 13 Aug 2026 15:49:03 +0400 Subject: [PATCH 3/3] Apply to tag processor --- .../html-api/class-wp-html-tag-processor.php | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 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 5745207f38fc4..41788ba102a67 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 @@ -1178,14 +1178,20 @@ public function paused_at_incomplete_token(): bool { * * This generator function is designed to be used inside a "foreach" loop. * - * Example: - * - * $p = new WP_HTML_Tag_Processor( "
" ); - * $p->next_tag(); - * foreach ( $p->class_list() as $class_name ) { - * echo "{$class_name} "; - * } - * // Outputs: "free lang-en " + * ```php interactive + * " ); + * $p->next_tag(); + * foreach ( $p->class_list() as $class_name ) { + * var_dump( $class_name ); + * } + * ``` + * ```expected-output + * string(4) "free" + * string(5) "" + * string(7) "lang-en" + * ``` * * @since 6.4.0 *