• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / twentytwenty_get_custom_logo() – Get the information about the logo.

You appear to be a bot. Output may be restricted

Description

Get the information about the logo.

Usage

$string = twentytwenty_get_custom_logo( $html );

Parameters

$html
( string ) required – The HTML output from get_custom_logo (core function).

Returns

string

Source

File name: twentytwenty/functions.php
Lines:

1 to 47 of 47
function twentytwenty_get_custom_logo( $html ) {

  $logo_id = get_theme_mod( 'custom_logo' );

  if ( ! $logo_id ) {
    return $html;
  }

  $logo = wp_get_attachment_image_src( $logo_id, 'full' );

  if ( $logo ) {
    // For clarity.
    $logo_width  = esc_attr( $logo[1] );
    $logo_height = esc_attr( $logo[2] );

    // If the retina logo setting is active, reduce the width/height by half.
    if ( get_theme_mod( 'retina_logo', false ) ) {
      $logo_width  = floor( $logo_width / 2 );
      $logo_height = floor( $logo_height / 2 );

      $search = array(
        '/width=\"\d+\"/iU',
        '/height=\"\d+\"/iU',
      );

      $replace = array(
        "width=\"{$logo_width}\"",
        "height=\"{$logo_height}\"",
      );

      // Add a style attribute with the height, or append the height to the style attribute if the style attribute already exists.
      if ( strpos( $html, ' style=' ) === false ) {
        $search[]  = '/(src=)/';
        $replace[] = "style=\"height: {$logo_height}px;\" src=";
      } else {
        $search[]  = '/(style="[^"]*)/';
        $replace[] = "$1 height: {$logo_height}px;";
      }

      $html = preg_replace( $search, $replace, $html );

    }
  }

  return $html;

}
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 25th November 2019

Primary Sidebar

Information

Function name: twentytwenty_get_custom_logo
Plugin ref: Twenty Twenty
Version: 2.1
Sourcefile: functions.php
File ref: functions.php
Deprecated?: No
API Letters: C,G,L,T

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites