Skip to content

Instantly share code, notes, and snippets.

@SJ-James
Created January 3, 2018 11:39
Show Gist options
  • Save SJ-James/2034db86ed54dea09fa0ed4920261660 to your computer and use it in GitHub Desktop.
Save SJ-James/2034db86ed54dea09fa0ed4920261660 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');
@muks999
Copy link

muks999 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
Copy link

innotag commented Jan 7, 2018

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

@Antera
Copy link

Antera 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