Advertisement
Guest User

Untitled

a guest
Oct 4th, 2014
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. // Adds a shortcode to show all the currently used cookies
  2.     function get_cookies( $paras = '', $content = '' ) {
  3.         if ( strtolower( $paras[ 0 ] ) == 'novalue' ) {
  4.             $novalue = true;
  5.         }
  6.         else {
  7.             $novalue = false;
  8.         }
  9.        
  10.         if ( $content == '' ) {
  11.             $seperator = ' : ';
  12.         } else {
  13.             $seperator = $content;
  14.         } $cookie = $_COOKIE;
  15.        
  16.         ksort( $cookie );
  17.        
  18.         $content = "<ul>\n";
  19.        
  20.         foreach ( $cookie as $key => $val ) {
  21.             $content .= '<li>' . htmlspecialchars($key);
  22.            
  23.             if ( !$novalue ) {
  24.                 $content .= $seperator . htmlspecialchars($val);
  25.             }
  26.            
  27.             $content .= "</li>\n";
  28.         }
  29.        
  30.         $content .= "</ul>\n";
  31.        
  32.         return do_shortcode( $content );
  33.     }
  34.    
  35.     add_shortcode( 'cookies', 'get_cookies' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement