Skip to content

Instantly share code, notes, and snippets.

@bacoords
Last active February 29, 2024 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bacoords/48beb404378a3124cad00dafb99aa5b5 to your computer and use it in GitHub Desktop.
Save bacoords/48beb404378a3124cad00dafb99aa5b5 to your computer and use it in GitHub Desktop.
<?php
/**
* Register block styles.
*
* @return void
*/
function prefix_register_block_styles() {
$site_icon = get_site_icon_url();
if ( $site_icon ) {
register_block_style(
'core/site-logo',
array(
'name' => 'mobile-site-icon',
'label' => __( 'Mobile Icon Only', 'agency-fifty-three' ),
'inline_style' => '@media (max-width: 551px){
.wp-block-site-logo.is-style-mobile-site-icon .custom-logo-link {
background-image: url(' . esc_url( $site_icon ) . ');
width:45px; height:45px;
background-size: contain;
}
.wp-block-site-logo.is-style-mobile-site-icon img {
display:none;
}
}',
)
);
}
}
add_action( 'init', 'prefix_register_block_styles' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment