Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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');
@muks999

This comment has been minimized.

Copy link

commented Jan 6, 2018

need help
What am i doing wong? i inserted a code in /themes/ExtraChild/functions.php
i deleted
Parse error: syntax error, unexpected '<' in /themes/ExtraChild/functions.php on line 34
lines 34-48:

`<!a href="#" onclick="ClearLocalCache()" class="et-pb-layout-buttons et-pb-layout-buttons-cache" title="Clear Cache">
Clear Cache

<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>

What's wrong with syntax of php file? it start from <?php and end ?> explain this please
function ClearLocalCacheButton() { ?>`

@innotag

This comment has been minimized.

Copy link

commented Jan 7, 2018

Working great for me. Thanks very much for the share! :)

@Antera

This comment has been minimized.

Copy link

commented Apr 7, 2019

Hi !
Is it still useful for new Divi version ?
Many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.