From d859cbe79092b52dda5fa70daf1385f82f268a2a Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Thu, 7 Dec 2023 22:55:28 +0000 Subject: [PATCH] General: Avoid early initialization of variable in `get_bloginfo()`. This is a very minor, yet simple performance optimization in a commonly called function, avoiding unnecessary initialization of the `$url` variable when it may not be needed. The conditional is simple enough to not use a variable altogether. Props Cybr, swissspidy. Fixes #59450. git-svn-id: https://develop.svn.wordpress.org/trunk@57170 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/general-template.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 28fb3394d2..ddc34db34f 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -906,17 +906,12 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { break; } - $url = true; - - if ( ! str_contains( $show, 'url' ) - && ! str_contains( $show, 'directory' ) - && ! str_contains( $show, 'home' ) - ) { - $url = false; - } - if ( 'display' === $filter ) { - if ( $url ) { + if ( + str_contains( $show, 'url' ) + || str_contains( $show, 'directory' ) + || str_contains( $show, 'home' ) + ) { /** * Filters the URL returned by get_bloginfo(). *