WordPress.org

Make WordPress Core

Changeset 19622


Ignore:
Timestamp:
12/21/2011 10:57:42 AM (6 years ago)
Author:
westi
Message:

Make it possible for commenter cookies to be disabled if someone wants to by setting them on an action instead of always. Fixes #17976 props SergeyBiryukov and pishmishy .

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-comments-post.php

    r18841 r19622  
    9191
    9292$comment = get_comment($comment_id);
    93 if ( !$user->ID ) {
    94     $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000);
    95     setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
    96     setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
    97     setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
    98 }
     93do_action('set_comment_cookies', $comment, $user);
    9994
    10095$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
  • trunk/wp-includes/comment.php

    r19593 r19622  
    571571}
    572572
     573/** 
     574 * Sets the cookies used to store an unauthenticated commentator's identity. Typically used 
     575 * to recall previous comments by this commentator that are still held in moderation. 
     576 * 
     577 * @param object $comment Comment object.
     578 * @param object $user Comment author's object.
     579 *
     580 * @since 3.4.0
     581 */ 
     582function wp_set_comment_cookies($comment, $user) { 
     583    if ( $user->ID )
     584        return;
     585
     586    $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000);
     587    setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     588    setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     589    setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     590
     591
    573592/**
    574593 * Sanitizes the cookies sent to the user already.
  • trunk/wp-includes/default-filters.php

    r19547 r19622  
    241241add_action( 'do_pings',                   'do_all_pings',                            10, 1 );
    242242add_action( 'do_robots',                  'do_robots'                                      );
     243add_action( 'set_comment_cookies',        'wp_set_comment_cookies',                  10, 2 );
    243244add_action( 'sanitize_comment_cookies',   'sanitize_comment_cookies'                       );
    244245add_action( 'admin_print_scripts',        'print_head_scripts',                      20    );
Note: See TracChangeset for help on using the changeset viewer.