Skip to content

Instantly share code, notes, and snippets.

@Christian-Roth
Last active July 8, 2018 13:28
Show Gist options
  • Save Christian-Roth/b13d137ab120510e8652422a198894b0 to your computer and use it in GitHub Desktop.
Save Christian-Roth/b13d137ab120510e8652422a198894b0 to your computer and use it in GitHub Desktop.
A shortcode to show content if cookies are not accepted
<?php /* Shortcode Cookie Not Accepted */
function custom_cn_cookies_not_accepted( $atts, $content = null ) {
if (function_exists('cn_cookies_accepted') && !cn_cookies_accepted()) {
return '<div class="box cookie-box">' . do_shortcode($content) . '</div>';
} else {
return '';
}
}
add_shortcode('cookies_not_accepted', 'custom_cn_cookies_not_accepted');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment