Skip to content

Instantly share code, notes, and snippets.

@BinaryMoon
BinaryMoon / widgets.js
Last active May 27, 2019 21:40
Some javascript to fix media widget display issues in WordPress 4.8
// Use a timeout so we can ensure any resizing/ transitions are complete. May need to make the duration a little longer.
// This code should be called from the code that makes the hidden widgets visible. For example in the button click event.
// Requires jQuery for a couple of bits - shouldn't be a problem since most WordPress themes use it.
setTimeout(
function() {
// Remove any media elements currently initialised.
// Should change .sidebar-overlay to match the html on your site.
// This should be some sort of container that holds the hidden widgets.
// The container is used to ensure widgets in visible sidebars are not affected.