Make WordPress Core

Changeset 57170


Ignore:
Timestamp:
12/07/2023 10:55:28 PM (3 months ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r57136 r57170  
    907907    }
    908908
    909     $url = true;
    910 
    911     if ( ! str_contains( $show, 'url' )
    912         && ! str_contains( $show, 'directory' )
    913         && ! str_contains( $show, 'home' )
    914     ) {
    915         $url = false;
    916     }
    917 
    918909    if ( 'display' === $filter ) {
    919         if ( $url ) {
     910        if (
     911            str_contains( $show, 'url' )
     912            || str_contains( $show, 'directory' )
     913            || str_contains( $show, 'home' )
     914        ) {
    920915            /**
    921916             * Filters the URL returned by get_bloginfo().
Note: See TracChangeset for help on using the changeset viewer.