Logo dimensions as CSS variable

$logo = shortcode_parse_atts( cwp_icon( [ 'icon' => 'logo', 'group' => 'logo', 'size' => false, 'force' => true ] ) );
if ( ! empty( $logo['viewbox'] ) ) {
  $dimensions = explode( ' ', $logo['viewbox'] );
  $style = 'body { --cwp-logo-width: ' . $dimensions[2] . 'px; --cwp-logo-height: ' . $dimensions[3] . 'px;}';
  wp_add_inline_style( 'theme-style', $style );
}
Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk