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 a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

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

Let's Talk