Created
February 5, 2014 14:36
-
-
Save goliver79/8824930 to your computer and use it in GitHub Desktop.
[WORDPRESS] Show current cookies
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 | |
/** | |
* 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