Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Adds a shortcode to show all the currently used cookies
- function 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>' . htmlspecialchars($key);
- if ( !$novalue ) {
- $content .= $seperator . htmlspecialchars($val);
- }
- $content .= "</li>\n";
- }
- $content .= "</ul>\n";
- return do_shortcode( $content );
- }
- add_shortcode( 'cookies', 'get_cookies' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement