WordPress.org

Make WordPress Core

Ticket #17976: 17976.diff

File 17976.diff, 2.3 KB (added by pishmishy, 7 years ago)

Patch makes comment_ cookies pluggable

  • wp-comments-post.php

     
    9191
    9292$comment = get_comment($comment_id);
    9393if ( !$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);
     94        wp_set_comment_cookie($comment->comment_author,$comment->comment_author_email,$comment->comment_author_url);   
    9895}
    9996
    10097$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
  • wp-includes/pluggable.php

     
    18091809        return $r;
    18101810}
    18111811endif;
     1812
     1813if ( !function_exists('wp_set_comment_cookie') ) :
     1814/**
     1815 * Sets the cookies used to store an unauthenticated commentator's identity. Typically used
     1816 * to recall previous comments by this commentator that are still held in moderation.
     1817 *
     1818 * @param string $author Comment author's name
     1819 * @param string $email Comment author's e-mail address
     1820 * @param string $url Comment author's URL (typically optional)
     1821 *
     1822 * @uses apply_filters() Calls 'comment_cookie_lifetime' to adjust lifetime of these cookies
     1823 *
     1824 */
     1825function wp_set_comment_cookie($author,$email,$url) {
     1826        $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000);
     1827        setcookie('comment_author_' . COOKIEHASH, $author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     1828        setcookie('comment_author_email_' . COOKIEHASH, $email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     1829        setcookie('comment_author_url_' . COOKIEHASH, esc_url($url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     1830}
     1831endif;