Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created May 17, 2014 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatch/1cfc5435a5013b298abd to your computer and use it in GitHub Desktop.
Save jaredatch/1cfc5435a5013b298abd to your computer and use it in GitHub Desktop.
Notice bar
jQuery(document).ready(function($){
// Notice bar
// Make sure and enqueue jquery cookie first - https://github.com/carhartl/jquery-cookie
var site_notice = $.cookie('site-notice');
if ( site_notice == null ) {
$('#site-notice').prependTo('body').slideToggle();
}
$('#site-notice .close').on( 'click', function() {
$('#sitenotice').slideToggle();
$.cookie('site-notice', 'hide', { expires: 60 });
return false;
});
});
<?php
/**
* Site notice bar
*
* @since 1.0.0
*/
function ja_site_notice() {
$notice = get_option( 'ja_site_notice' );
if ( !empty( $notice ) ) {
echo '<div id="ck-notice">' . $notice . ' <a href="#" class="close">Close</a></div>';
}
}
add_action( 'genesis_after', 'ja_site_notice' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment