Last active
June 26, 2024 04:57
-
-
Save tripflex/7f4a10fb27c7e8c95c86010f93ac250b to your computer and use it in GitHub Desktop.
Fix Select2 issues with WordPress Admin Bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_head', 'smyles_output_select2_admin_bar_fix' ); | |
function smyles_output_select2_admin_bar_fix() { | |
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type = "text/css"'; | |
/** | |
* We use ~ here instead of + for any situations where something else ends up attaching to body as well | |
*/ | |
?> | |
<style<?php echo $type_attr; ?> media="screen"> | |
div#wpadminbar ~ span.select2-container, body.admin-bar > span.select2-container { | |
padding-top: 32px !important; | |
} | |
@media screen and ( max-width: 782px ) { | |
div#wpadminbar ~ span.select2-container, body.admin-bar > span.select2-container { | |
padding-top: 46px !important; | |
} | |
} | |
</style> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment