url(), PHP_URL_PATH ) ) ), 'template' => self::escape_pattern_string( trailingslashit( (string) wp_parse_url( get_stylesheet_directory_uri(), PHP_URL_PATH ) ) ), 'stylesheet' => self::escape_pattern_string( trailingslashit( (string) wp_parse_url( get_template_directory_uri(), PHP_URL_PATH ) ) ), ); } /** * Escapes a string for use in a URL pattern component. * * @since 6.8.0 * @see https://urlpattern.spec.whatwg.org/#escape-a-pattern-string * * @param string $str String to be escaped. * @return string String with backslashes added where required. */ private static function escape_pattern_string( string $str ): string { return addcslashes( $str, '+*?:{}()\\' ); } }