Skip to content

Instantly share code, notes, and snippets.

@sisaacrussell
Forked from SJ-James/functions.php
Created January 3, 2018 22:38
Show Gist options
  • Save sisaacrussell/6db8954aaae0e40734c66facaab146d0 to your computer and use it in GitHub Desktop.
Save sisaacrussell/6db8954aaae0e40734c66facaab146d0 to your computer and use it in GitHub Desktop.
Clear Local Storage Button For Divi
<?php
function ClearLocalCacheButton() { ?>
// Create Button
<a href="#" onclick="ClearLocalCache()" class="et-pb-layout-buttons et-pb-layout-buttons-cache" title="Clear Cache">
<span>Clear Cache</span>
</a>
<script type="text/javascript">
// Move Button to Divi Tabs
jQuery(window).load(function(){
jQuery(".et-pb-layout-buttons-cache").insertAfter(jQuery(".et-pb-layout-buttons-clear"));
});
function ClearLocalCache() {
// Clear Storage and Alert User
alert("Local storage has been cleared. Update the page now.");
window.localStorage.clear()
}
</script>
<?php }
add_action('admin_footer', 'ClearLocalCacheButton');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment