From f28655081e7c9f46ea70f602c34c2a153abecc46 Mon Sep 17 00:00:00 2001 From: Mike Little Date: Wed, 10 Apr 2024 16:32:36 +0000 Subject: [PATCH] Use the returned modified copy. Remove the empty entries. --- inc/namespace.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/inc/namespace.php b/inc/namespace.php index 7c1b70f..d61877e 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -227,8 +227,9 @@ function remove_emoji() { /** * Remove domains from DNS prefetching. * - * @param array $urls URLs for resources. + * @param array $urls URLs for resources. * @param string $relation_type Relation type. + * * @return array New array with resources. */ function remove_domains_from_dns_prefetch( array $urls, string $relation_type ) : array { @@ -246,14 +247,14 @@ function remove_domains_from_dns_prefetch( array $urls, string $relation_type ) $url = $url['href']; } - array_map( function ( $domain ) use ( $key, $url, $urls ) { + $urls = array_map( function ( $domain ) use ( $key, $url, $urls ) { if ( str_contains( $url, $domain ) ) { unset( $urls[ $key ] ); } }, $domains_to_remove ); - } - return $urls; + + return array_filter( $urls ); } /** @@ -264,8 +265,8 @@ function remove_domains_from_dns_prefetch( array $urls, string $relation_type ) function get_prefetch_domains_to_remove() : array { $domains = [ 'https://s.w.org/images/core/emoji/', - ] ; - if ( defined('S3_UPLOADS_BUCKET_URL') ) { + ]; + if ( defined( 'S3_UPLOADS_BUCKET_URL' ) ) { $domains[] = S3_UPLOADS_BUCKET_URL; }