WordPress.org

Make WordPress Core

Ticket #17976: cookies.diff

File cookies.diff, 2.9 KB (added by pishmishy, 7 years ago)

Patch using actions

  • wp-comments-post.php

     
    9090$comment_id = wp_new_comment( $commentdata );
    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 }
    9993
    10094$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
    10195$location = apply_filters('comment_post_redirect', $location, $comment);
  • wp-includes/default-filters.php

     
    253253add_action( 'save_post',                  '_save_post_hook',          5, 2 );
    254254add_action( 'transition_post_status',     '_transition_post_status',  5, 3 );
    255255add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce'        );
     256add_action( 'comment_post', 'wp_set_comment_cookies');
    256257add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'            );
    257258add_action( 'before_wp_tiny_mce',         'wp_print_editor_js'             );
    258259add_action( 'after_wp_tiny_mce',          'wp_preload_dialogs',      10, 1 );
  • wp-includes/functions.php

     
    45494549        @header( 'X-Frame-Options: SAMEORIGIN' );
    45504550}
    45514551
     4552/**
     4553 * Sets the cookies used to store an unauthenticated commentator's identity. Typically used
     4554 * to recall previous comments by this commentator that are still held in moderation.
     4555 *
     4556 * @param string $id Comment id
     4557 *
     4558 */
     4559//function wp_set_comment_cookies($author,$email,$url) {
     4560function wp_set_comment_cookies($id) {
     4561        $comment = get_comment($id,ARRAY_A);
     4562        $author = $comment['author'];
     4563        $email = $comment['author_email'];
     4564        $url = $comment['author_url'];
     4565        if(!$user->ID){
     4566                $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000);
     4567                setcookie('comment_author_' . COOKIEHASH, $author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     4568                setcookie('comment_author_email_' . COOKIEHASH, $email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
     4569                setcookie('comment_author_url_' . COOKIEHASH, esc_url($url), time() + $comment_cookie_lifetime,         COOKIEPATH, COOKIE_DOMAIN);
     4570        }
     4571}
     4572
     4573
    45524574?>