From 9abb1583ad96fa77d66764ce8237272f580dee2b Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 2 Oct 2025 12:05:01 -0400 Subject: [PATCH 1/2] refactor: Optimize editor assets endpoint URL processing Prefer the `str_starts_with` utility since it is available in PHP 8 and in a polyfill for WordPress 5.9.0 onward. Jetpack requires minimum of WordPress 6.7. - https://make.wordpress.org/core/2022/01/10/wordpress-5-9-and-php-8-0-8-1/ - https://github.com/Automattic/jetpack/blob/a5b0d2eb5fef8a5c59c95d0972c812ef2c6b994a/projects/plugins/jetpack/jetpack.php#L43 --- .../class-wpcom-rest-api-v2-endpoint-block-editor-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-block-editor-assets.php b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-block-editor-assets.php index 0fc7702ca7594..0c9c4f12ee035 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-block-editor-assets.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-block-editor-assets.php @@ -380,7 +380,7 @@ private function is_allowed_plugin_handle( $handle ) { * @return string The absolute URL. */ public function make_url_absolute( $src ) { - if ( ! empty( $src ) && strpos( $src, '/' ) === 0 && strpos( $src, '//' ) !== 0 ) { + if ( ! empty( $src ) && str_starts_with( $src, '/' ) && ! str_starts_with( $src, '//' ) ) { return site_url( $src ); } return $src; From c5f81409bd1b19a11b60f633c85567da7c2451fe Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 2 Oct 2025 12:07:14 -0400 Subject: [PATCH 2/2] changelog --- .../changelog/refactor-optimize-editor-assets-url-processing | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/refactor-optimize-editor-assets-url-processing diff --git a/projects/plugins/jetpack/changelog/refactor-optimize-editor-assets-url-processing b/projects/plugins/jetpack/changelog/refactor-optimize-editor-assets-url-processing new file mode 100644 index 0000000000000..914b1699de6d2 --- /dev/null +++ b/projects/plugins/jetpack/changelog/refactor-optimize-editor-assets-url-processing @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Editor assets endpoint: optimize URL processing