get_custom_logo

The timeline below displays how wordpress function get_custom_logo has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.8

/**
 * Returns a custom logo, linked to home unless the theme supports removing the link on the home page.
 *
 * @since 4.5.0
 * @since 5.5.0 Added option to remove the link on the home page with `unlink-homepage-logo` theme support
 *              for the `custom-logo` theme feature.
 * @since 5.5.1 Disabled lazy-loading by default.
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    $switched_blog = false;
    if (is_multisite() && !empty($blog_id) && get_current_blog_id() !== (int) $blog_id) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $custom_logo_attr = array('class' => 'custom-logo', 'loading' => false);
        $unlink_homepage_logo = (bool) get_theme_support('custom-logo', 'unlink-homepage-logo');
        if ($unlink_homepage_logo && is_front_page() && !is_paged()) {
            /*
             * If on the home page, set the logo alt attribute to an empty string,
             * as the image is decorative and doesn't need its purpose to be described.
             */
            $custom_logo_attr['alt'] = '';
        } else {
            /*
             * If the logo alt attribute is empty, get the site title and explicitly pass it
             * to the attributes used by wp_get_attachment_image().
             */
            $image_alt = get_post_meta($custom_logo_id, '_wp_attachment_image_alt', true);
            if (empty($image_alt)) {
                $custom_logo_attr['alt'] = get_bloginfo('name', 'display');
            }
        }
        /**
         * Filters the list of custom logo image attributes.
         *
         * @since 5.5.0
         *
         * @param array $custom_logo_attr Custom logo image attributes.
         * @param int   $custom_logo_id   Custom logo attachment ID.
         * @param int   $blog_id          ID of the blog to get the custom logo for.
         */
        $custom_logo_attr = apply_filters('get_custom_logo_image_attributes', $custom_logo_attr, $custom_logo_id, $blog_id);
        /*
         * If the alt attribute is not empty, there's no need to explicitly pass it
         * because wp_get_attachment_image() already adds the alt attribute.
         */
        $image = wp_get_attachment_image($custom_logo_id, 'full', false, $custom_logo_attr);
        if ($unlink_homepage_logo && is_front_page() && !is_paged()) {
            // If on the home page, don't link the logo to home.
            $html = sprintf('<span class="custom-logo-link">%1$s</span>', $image);
        } else {
            $aria_current = (is_front_page() && !is_paged()) ? ' aria-current="page"' : '';
            $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home"%2$s>%3$s</a>', esc_url(home_url('/')), $aria_current, $image);
        }
    } elseif (is_customize_preview()) {
        // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo" alt="" /></a>', esc_url(home_url('/')));
    }
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 5.7

/**
 * Returns a custom logo, linked to home unless the theme supports removing the link on the home page.
 *
 * @since 4.5.0
 * @since 5.5.0 Added option to remove the link on the home page with `unlink-homepage-logo` theme support.
 * @since 5.5.1 Disabled lazy-loading by default.
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    $switched_blog = false;
    if (is_multisite() && !empty($blog_id) && get_current_blog_id() !== (int) $blog_id) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $custom_logo_attr = array('class' => 'custom-logo', 'loading' => false);
        $unlink_homepage_logo = (bool) get_theme_support('custom-logo', 'unlink-homepage-logo');
        if ($unlink_homepage_logo && is_front_page() && !is_paged()) {
            /*
             * If on the home page, set the logo alt attribute to an empty string,
             * as the image is decorative and doesn't need its purpose to be described.
             */
            $custom_logo_attr['alt'] = '';
        } else {
            /*
             * If the logo alt attribute is empty, get the site title and explicitly pass it
             * to the attributes used by wp_get_attachment_image().
             */
            $image_alt = get_post_meta($custom_logo_id, '_wp_attachment_image_alt', true);
            if (empty($image_alt)) {
                $custom_logo_attr['alt'] = get_bloginfo('name', 'display');
            }
        }
        /**
         * Filters the list of custom logo image attributes.
         *
         * @since 5.5.0
         *
         * @param array $custom_logo_attr Custom logo image attributes.
         * @param int   $custom_logo_id   Custom logo attachment ID.
         * @param int   $blog_id          ID of the blog to get the custom logo for.
         */
        $custom_logo_attr = apply_filters('get_custom_logo_image_attributes', $custom_logo_attr, $custom_logo_id, $blog_id);
        /*
         * If the alt attribute is not empty, there's no need to explicitly pass it
         * because wp_get_attachment_image() already adds the alt attribute.
         */
        $image = wp_get_attachment_image($custom_logo_id, 'full', false, $custom_logo_attr);
        if ($unlink_homepage_logo && is_front_page() && !is_paged()) {
            // If on the home page, don't link the logo to home.
            $html = sprintf('<span class="custom-logo-link">%1$s</span>', $image);
        } else {
            $aria_current = (is_front_page() && !is_paged()) ? ' aria-current="page"' : '';
            $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home"%2$s>%3$s</a>', esc_url(home_url('/')), $aria_current, $image);
        }
    } elseif (is_customize_preview()) {
        // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo" alt="" /></a>', esc_url(home_url('/')));
    }
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 5.1

/**
 * Returns a custom logo, linked to home unless the theme supports removing the link on the home page.
 *
 * @since 4.5.0
 * @since 5.5.0 Added option to remove the link on the home page with `unlink-homepage-logo` theme support.
 * @since 5.5.1 Disabled lazy-loading by default.
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    $switched_blog = false;
    if (is_multisite() && !empty($blog_id) && get_current_blog_id() !== (int) $blog_id) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $custom_logo_attr = array('class' => 'custom-logo', 'loading' => false);
        $unlink_homepage_logo = (bool) get_theme_support('custom-logo', 'unlink-homepage-logo');
        if ($unlink_homepage_logo && is_front_page() && !is_paged()) {
            /*
             * If on the home page, set the logo alt attribute to an empty string,
             * as the image is decorative and doesn't need its purpose to be described.
             */
            $custom_logo_attr['alt'] = '';
        } else {
            /*
             * If the logo alt attribute is empty, get the site title and explicitly pass it
             * to the attributes used by wp_get_attachment_image().
             */
            $image_alt = get_post_meta($custom_logo_id, '_wp_attachment_image_alt', true);
            if (empty($image_alt)) {
                $custom_logo_attr['alt'] = get_bloginfo('name', 'display');
            }
        }
        /**
         * Filters the list of custom logo image attributes.
         *
         * @since 5.5.0
         *
         * @param array $custom_logo_attr Custom logo image attributes.
         * @param int   $custom_logo_id   Custom logo attachment ID.
         * @param int   $blog_id          ID of the blog to get the custom logo for.
         */
        $custom_logo_attr = apply_filters('get_custom_logo_image_attributes', $custom_logo_attr, $custom_logo_id, $blog_id);
        /*
         * If the alt attribute is not empty, there's no need to explicitly pass it
         * because wp_get_attachment_image() already adds the alt attribute.
         */
        $image = wp_get_attachment_image($custom_logo_id, 'full', false, $custom_logo_attr);
        if ($unlink_homepage_logo && is_front_page() && !is_paged()) {
            // If on the home page, don't link the logo to home.
            $html = sprintf('<span class="custom-logo-link">%1$s</span>', $image);
        } else {
            $aria_current = (is_front_page() && !is_paged()) ? ' aria-current="page"' : '';
            $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home"%2$s>%3$s</a>', esc_url(home_url('/')), $aria_current, $image);
        }
    } elseif (is_customize_preview()) {
        // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', esc_url(home_url('/')));
    }
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 5.5

/**
 * Returns a custom logo, linked to home when on another page.
 *
 * @since 4.5.0
 * @since 5.5.0 Removed the link on the home page.
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    $switched_blog = false;
    if (is_multisite() && !empty($blog_id) && get_current_blog_id() !== (int) $blog_id) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $custom_logo_attr = array('class' => 'custom-logo');
        $unlink_homepage_logo = (bool) get_theme_support('custom-logo', 'unlink-homepage-logo');
        if ($unlink_homepage_logo && is_front_page() && !is_paged()) {
            /*
             * If on the home page, set the logo alt attribute to an empty string,
             * as the image is decorative and doesn't need its purpose to be described.
             */
            $custom_logo_attr['alt'] = '';
        } else {
            /*
             * If the logo alt attribute is empty, get the site title and explicitly pass it
             * to the attributes used by wp_get_attachment_image().
             */
            $image_alt = get_post_meta($custom_logo_id, '_wp_attachment_image_alt', true);
            if (empty($image_alt)) {
                $custom_logo_attr['alt'] = get_bloginfo('name', 'display');
            }
        }
        /**
         * Filters the list of custom logo image attributes.
         *
         * @since 5.5.0
         *
         * @param array $custom_logo_attr Custom logo image attributes.
         * @param int   $custom_logo_id   Custom logo attachment ID.
         * @param int   $blog_id          ID of the blog to get the custom logo for.
         */
        $custom_logo_attr = apply_filters('get_custom_logo_image_attributes', $custom_logo_attr, $custom_logo_id, $blog_id);
        /*
         * If the alt attribute is not empty, there's no need to explicitly pass it
         * because wp_get_attachment_image() already adds the alt attribute.
         */
        $image = wp_get_attachment_image($custom_logo_id, 'full', false, $custom_logo_attr);
        if ($unlink_homepage_logo && is_front_page() && !is_paged()) {
            // If on the home page, don't link the logo to home.
            $html = sprintf('<span class="custom-logo-link">%1$s</span>', $image);
        } else {
            $aria_current = (is_front_page() && !is_paged()) ? ' aria-current="page"' : '';
            $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home"%2$s>%3$s</a>', esc_url(home_url('/')), $aria_current, $image);
        }
    } elseif (is_customize_preview()) {
        // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', esc_url(home_url('/')));
    }
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 5.4

/**
 * Returns a custom logo, linked to home.
 *
 * @since 4.5.0
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    $switched_blog = false;
    if (is_multisite() && !empty($blog_id) && get_current_blog_id() !== (int) $blog_id) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $custom_logo_attr = array('class' => 'custom-logo');
        /*
         * If the logo alt attribute is empty, get the site title and explicitly
         * pass it to the attributes used by wp_get_attachment_image().
         */
        $image_alt = get_post_meta($custom_logo_id, '_wp_attachment_image_alt', true);
        if (empty($image_alt)) {
            $custom_logo_attr['alt'] = get_bloginfo('name', 'display');
        }
        /*
         * If the alt attribute is not empty, there's no need to explicitly pass
         * it because wp_get_attachment_image() already adds the alt attribute.
         */
        $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($custom_logo_id, 'full', false, $custom_logo_attr));
    } elseif (is_customize_preview()) {
        // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', esc_url(home_url('/')));
    }
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 5.2

/**
 * Returns a custom logo, linked to home.
 *
 * @since 4.5.0
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    $switched_blog = false;
    if (is_multisite() && !empty($blog_id) && (int) $blog_id !== get_current_blog_id()) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $custom_logo_attr = array('class' => 'custom-logo');
        /*
         * If the logo alt attribute is empty, get the site title and explicitly
         * pass it to the attributes used by wp_get_attachment_image().
         */
        $image_alt = get_post_meta($custom_logo_id, '_wp_attachment_image_alt', true);
        if (empty($image_alt)) {
            $custom_logo_attr['alt'] = get_bloginfo('name', 'display');
        }
        /*
         * If the alt attribute is not empty, there's no need to explicitly pass
         * it because wp_get_attachment_image() already adds the alt attribute.
         */
        $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($custom_logo_id, 'full', false, $custom_logo_attr));
    } elseif (is_customize_preview()) {
        // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', esc_url(home_url('/')));
    }
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 5.1

/**
 * Returns a custom logo, linked to home.
 *
 * @since 4.5.0
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    $switched_blog = false;
    if (is_multisite() && !empty($blog_id) && (int) $blog_id !== get_current_blog_id()) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $custom_logo_attr = array('class' => 'custom-logo', 'itemprop' => 'logo');
        /*
         * If the logo alt attribute is empty, get the site title and explicitly
         * pass it to the attributes used by wp_get_attachment_image().
         */
        $image_alt = get_post_meta($custom_logo_id, '_wp_attachment_image_alt', true);
        if (empty($image_alt)) {
            $custom_logo_attr['alt'] = get_bloginfo('name', 'display');
        }
        /*
         * If the alt attribute is not empty, there's no need to explicitly pass
         * it because wp_get_attachment_image() already adds the alt attribute.
         */
        $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($custom_logo_id, 'full', false, $custom_logo_attr));
    } elseif (is_customize_preview()) {
        // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', esc_url(home_url('/')));
    }
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 4.8

/**
 * Returns a custom logo, linked to home.
 *
 * @since 4.5.0
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    $switched_blog = false;
    if (is_multisite() && !empty($blog_id) && (int) $blog_id !== get_current_blog_id()) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $custom_logo_attr = array('class' => 'custom-logo', 'itemprop' => 'logo');
        /*
         * If the logo alt attribute is empty, get the site title and explicitly
         * pass it to the attributes used by wp_get_attachment_image().
         */
        $image_alt = get_post_meta($custom_logo_id, '_wp_attachment_image_alt', true);
        if (empty($image_alt)) {
            $custom_logo_attr['alt'] = get_bloginfo('name', 'display');
        }
        /*
         * If the alt attribute is not empty, there's no need to explicitly pass
         * it because wp_get_attachment_image() already adds the alt attribute.
         */
        $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($custom_logo_id, 'full', false, $custom_logo_attr));
    } elseif (is_customize_preview()) {
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', esc_url(home_url('/')));
    }
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 4.7

/**
 * Returns a custom logo, linked to home.
 *
 * @since 4.5.0
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    $switched_blog = false;
    if (is_multisite() && !empty($blog_id) && (int) $blog_id !== get_current_blog_id()) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($custom_logo_id, 'full', false, array('class' => 'custom-logo', 'itemprop' => 'logo')));
    } elseif (is_customize_preview()) {
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', esc_url(home_url('/')));
    }
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 4.6

/**
 * Returns a custom logo, linked to home.
 *
 * @since 4.5.0
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    if (is_multisite() && (int) $blog_id !== get_current_blog_id()) {
        switch_to_blog($blog_id);
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($custom_logo_id, 'full', false, array('class' => 'custom-logo', 'itemprop' => 'logo')));
    } elseif (is_customize_preview()) {
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', esc_url(home_url('/')));
    }
    if (is_multisite() && ms_is_switched()) {
        restore_current_blog();
    }
    /**
     * Filters the custom logo output.
     *
     * @since 4.5.0
     * @since 4.6.0 Added the `$blog_id` parameter.
     *
     * @param string $html    Custom logo HTML output.
     * @param int    $blog_id ID of the blog to get the custom logo for.
     */
    return apply_filters('get_custom_logo', $html, $blog_id);
}

WordPress Version: 4.5

/**
 * Returns a custom logo, linked to home.
 *
 * @since 4.5.0
 *
 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
 * @return string Custom logo markup.
 */
function get_custom_logo($blog_id = 0)
{
    $html = '';
    if (is_multisite() && (int) $blog_id !== get_current_blog_id()) {
        switch_to_blog($blog_id);
    }
    $custom_logo_id = get_theme_mod('custom_logo');
    // We have a logo. Logo is go.
    if ($custom_logo_id) {
        $html = sprintf('<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($custom_logo_id, 'full', false, array('class' => 'custom-logo', 'itemprop' => 'logo')));
    } elseif (is_customize_preview()) {
        $html = sprintf('<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>', esc_url(home_url('/')));
    }
    if (is_multisite() && ms_is_switched()) {
        restore_current_blog();
    }
    /**
     * Filter the custom logo output.
     *
     * @since 4.5.0
     *
     * @param string $html Custom logo HTML output.
     */
    return apply_filters('get_custom_logo', $html);
}