Created
November 25, 2019 17:45
-
-
Save sinebeef/0f5bfe107aa1caa419de2b36656e850a to your computer and use it in GitHub Desktop.
Wordpress Footer Banner Black Friday
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Black Friday Banner | |
Plugin URI: https://github.com/sinebeef | |
Description: A really basic black friday or message banner made upon request. | |
Author: sine | |
Version: 0.1 | |
Author URI: https://github.com/sinebeef | |
*/ | |
// If this file is called directly, abort. | |
if(!defined('WPINC')){ die; } | |
add_action('wp_head','mde_black_friday_cookies',10); | |
add_action('wp_head','mde_black_friday_css',20); | |
add_action('wp_footer','mde_black_friday_js',10); | |
function mde_black_friday_cookies() { | |
?> | |
<script src="https://cdn.jsdelivr.net/npm/js-cookie@beta/dist/js.cookie.min.js"></script> | |
<?php | |
} | |
function mde_black_friday_css() { | |
?> | |
<style type="text/css"> | |
.blackfriday{ | |
display: block; | |
position: fixed; | |
bottom:0; | |
left:0; | |
width: 100%; | |
padding: 2em 0; | |
background: #6b0f6b; | |
z-index:99999; | |
} | |
.bfin { | |
text-align: center; | |
} | |
.bfin p { | |
margin: 0; | |
} | |
.bftext{ | |
color: white; | |
font-size: 3rem; | |
padding: 0; | |
margin: 0; | |
font-weight: 700; | |
letter-spacing: -1px; | |
} | |
@media only screen and (max-width: 740px) { | |
.bftext { | |
font-size: 2rem; | |
} | |
.blackfriday{ | |
padding: 2em 0; | |
} | |
} | |
.bfbutton { | |
position: absolute; | |
top:10px; | |
right:10px; | |
width: 30px; | |
height: 30px; | |
color: #6b0f6b; | |
font-size: 30px; | |
background: white; | |
border-radius: 50%; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
transform: rotate(45deg); | |
} | |
</style> | |
<?php | |
} | |
function mde_black_friday_js() { | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function() { | |
var cookieValue = Cookies.get('blackfriday'); | |
if( cookieValue != 1){ | |
jQuery("body").append('<div class="blackfriday"><div class="bfbutton">+</div><div class="container"><div class="row"><div class="col-md-12 bfin"><p><span class="bftext">30% OFF BLACK FRIDAY</span></p></div></div></div></div>'); | |
jQuery( ".bfbutton" ).click(function() { | |
Cookies.set('blackfriday',1); | |
jQuery('.blackfriday').hide(); | |
}); | |
} | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment