From 995872941692c00674ae46afca848c58282e1c95 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 13 Mar 2024 10:41:14 +0000 Subject: [PATCH] =?UTF-8?q?Interactivity=20API:=20Do=20not=20process=20dir?= =?UTF-8?q?ectives=20when=20there=20aren=E2=80=99t=20any.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Short-circuits directive processing when the markup does not actually contain any `data-wp-*` attributes. This reduces function calls and memory usage for the best case scenario due to not involving `WP_HTML_Tag_Processor`. Props joemcgill, swissspidy, gziolo, cbravobernal, flixos90. Fixes #60749. Built from https://develop.svn.wordpress.org/trunk@57824 git-svn-id: http://core.svn.wordpress.org/trunk@57325 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/interactivity-api/class-wp-interactivity-api.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/interactivity-api/class-wp-interactivity-api.php b/wp-includes/interactivity-api/class-wp-interactivity-api.php index 9e5b1be1fa..28cb7ee20a 100644 --- a/wp-includes/interactivity-api/class-wp-interactivity-api.php +++ b/wp-includes/interactivity-api/class-wp-interactivity-api.php @@ -204,6 +204,10 @@ final class WP_Interactivity_API { * @return string The processed HTML content. It returns the original content when the HTML contains unbalanced tags. */ public function process_directives( string $html ): string { + if ( ! str_contains( $html, 'data-wp-' ) ) { + return $html; + } + $context_stack = array(); $namespace_stack = array(); $result = $this->process_directives_args( $html, $context_stack, $namespace_stack ); diff --git a/wp-includes/version.php b/wp-includes/version.php index a95a3318fe..103b54c62b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-57822'; +$wp_version = '6.6-alpha-57824'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.