Skip to content

Instantly share code, notes, and snippets.

@carasmo
Created September 2, 2017 15:12
Show Gist options
  • Save carasmo/a00eb27bdee8e83aed743e88c6f33f48 to your computer and use it in GitHub Desktop.
Save carasmo/a00eb27bdee8e83aed743e88c6f33f48 to your computer and use it in GitHub Desktop.
Close First Sidebar (widget area) by default.
<?php
// don't add again
/**
* Close First Widget Area by default
* @modified from: https://wordpress.stackexchange.com/a/114724/64742
*/
add_action( 'admin_footer-widgets.php' , function(){
?>
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
$( '#widgets-right .widgets-holder-wrap:first' ).addClass( 'closed' );
$( '#widgets-right' ).css( 'opacity', '1' );
} );
</script>
<?php
} );
add_action( 'admin_head-widgets.php', function(){
echo '<style type="text/css">
#widgets-right {opacity:0;transition: opacity .5s ease-out}
.no-js #widgets-right {opacity: 1}
</style>';
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment