Skip to content

Commit

Permalink
General: Avoid early initialization of variable in get_bloginfo().
Browse files Browse the repository at this point in the history
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
  • Loading branch information
felixarntz committed Dec 7, 2023
1 parent 8035bda commit d859cbe
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/wp-includes/general-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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().
*
Expand Down

0 comments on commit d859cbe

Please sign in to comment.