Skip to content

Instantly share code, notes, and snippets.

@goliver79
Created February 5, 2014 14:36
Show Gist options
  • Save goliver79/8824930 to your computer and use it in GitHub Desktop.
Save goliver79/8824930 to your computer and use it in GitHub Desktop.
[WORDPRESS] Show current cookies
<?php
/**
* Function for show current cookies
* @param string $paras
* @param string $content
* @return Ambigous <string, string, mixed>
*/
function lgpd_get_cookies( $paras = '', $content = '' ) {
if ( strtolower( $paras[ 0 ] ) == 'novalue' ) {
$novalue = true;
} else {
$novalue = false;
}
if ( $content == '' ) {
$seperator = ' : ';
} else {
$seperator = $content;
}
$cookie = $_COOKIE;
ksort( $cookie );
$content = "<ul>\n";
foreach ( $cookie as $key => $val ) {
$content .= '<li>' . $key;
if ( !$novalue ) {
$content .= $seperator . $val;
}
$content .= "</li>\n";
}
$content .= "</ul>\n";
return do_shortcode( $content );
}
add_shortcode( 'lgpd_cookies', 'lgpd_get_cookies' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment