sanitize_comment_cookies

Sanitizes the cookies sent to the user already.

Description

sanitize_comment_cookies(); 

Will only do anything if the cookies have already been created for the user. Mostly used after cookies had been sent to use elsewhere.


Usage

  1. if ( !function_exists( 'sanitize_comment_cookies' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = sanitize_comment_cookies(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment.php  
  1. function sanitize_comment_cookies() { 
  2. if ( isset( $_COOKIE['comment_author_' . COOKIEHASH] ) ) { 
  3. /** 
  4. * Filters the comment author's name cookie before it is set. 
  5. * When this filter hook is evaluated in wp_filter_comment(),  
  6. * the comment author's name string is passed. 
  7. * @since 1.5.0 
  8. * @param string $author_cookie The comment author name cookie. 
  9. */ 
  10. $comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_' . COOKIEHASH] ); 
  11. $comment_author = wp_unslash($comment_author); 
  12. $comment_author = esc_attr($comment_author); 
  13. $_COOKIE['comment_author_' . COOKIEHASH] = $comment_author; 
  14.  
  15. if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) { 
  16. /** 
  17. * Filters the comment author's email cookie before it is set. 
  18. * When this filter hook is evaluated in wp_filter_comment(),  
  19. * the comment author's email string is passed. 
  20. * @since 1.5.0 
  21. * @param string $author_email_cookie The comment author email cookie. 
  22. */ 
  23. $comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_' . COOKIEHASH] ); 
  24. $comment_author_email = wp_unslash($comment_author_email); 
  25. $comment_author_email = esc_attr($comment_author_email); 
  26. $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email; 
  27.  
  28. if ( isset( $_COOKIE['comment_author_url_' . COOKIEHASH] ) ) { 
  29. /** 
  30. * Filters the comment author's URL cookie before it is set. 
  31. * When this filter hook is evaluated in wp_filter_comment(),  
  32. * the comment author's URL string is passed. 
  33. * @since 1.5.0 
  34. * @param string $author_url_cookie The comment author URL cookie. 
  35. */ 
  36. $comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE['comment_author_url_' . COOKIEHASH] ); 
  37. $comment_author_url = wp_unslash($comment_author_url); 
  38. $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;