Skip to content

Instantly share code, notes, and snippets.

@fahadiqbal1
Created August 26, 2018 14:49
Show Gist options
  • Save fahadiqbal1/f94eb23168c8f2d01d51e59a7d383c2d to your computer and use it in GitHub Desktop.
Save fahadiqbal1/f94eb23168c8f2d01d51e59a7d383c2d to your computer and use it in GitHub Desktop.
Quick way to add leave site button on WordPress
/* Add to the bottom of the page */
<?php
function addHideSiteButton() {
?>
<div id="hide-site">
<button onclick="hideSite()">Leave this site</button>
</div>
<script>
function hideSite() {
window.open("http://www.comicrelief.com/", "_newtab");
location.replace("http://www.google.co.uk")
}
</script>
<?php
}
add_action('theme_after_body_tag_start','addHideSiteButton')
?>
/* I recommend putting this in the Theme >> Customize >> Additonal CSS section */
/* ------
Hide Site
------ */
div#hide-site {
position: fixed;
right: 10%;
top: 90px;
z-index: 1000;
}
div#hide-site button {
background: #fbe697;
color: #3b4248;
border: 2px solid #2bb1a8;
box-shadow: none;
font-weight: bold;
padding: 0.8em;
text-transform: uppercase;
transition: all 0.2s ease;
}
div#hide-site button:hover {
background: #FAAE3D;
}
@media screen and (max-width: 1139px) {
div#hide-site {
top: 0;
right: 10%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment