Changeset 42772 for trunk/src/wp-includes/comment.php
- Timestamp:
- 03/04/2018 04:40:43 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r42678 r42772 543 543 * @param WP_Comment $comment Comment object. 544 544 * @param object $user Comment author's object. 545 * @param boolean $cookies_consent Optional. Comment author's consent to store cookies. Default true. 545 546 * 546 547 * @since 3.4.0 547 548 */ 548 function wp_set_comment_cookies( $comment, $user ) { 549 function wp_set_comment_cookies( $comment, $user, $cookies_consent = true ) { 550 // If the user already exists, or the user opted out of cookies, don't set cookies. 549 551 if ( $user->exists() ) { 550 552 return; 551 553 } 552 554 555 if ( false === $cookies_consent ) { 556 // Remove any existing cookies. 557 $past = time() - YEAR_IN_SECONDS; 558 setcookie( 'comment_author_' . COOKIEHASH, ' ', $past, COOKIEPATH, COOKIE_DOMAIN ); 559 setcookie( 'comment_author_email_' . COOKIEHASH, ' ', $past, COOKIEPATH, COOKIE_DOMAIN ); 560 setcookie( 'comment_author_url_' . COOKIEHASH, ' ', $past, COOKIEPATH, COOKIE_DOMAIN ); 561 562 return; 563 } 564 553 565 /** 554 566 * Filters the lifetime of the comment cookie in seconds. … … 558 570 * @param int $seconds Comment cookie lifetime. Default 30000000. 559 571 */ 560 $comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );572 $comment_cookie_lifetime = time() + apply_filters( 'comment_cookie_lifetime', 30000000 ); 561 573 $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); 562 setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() +$comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );563 setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() +$comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );564 setcookie( 'comment_author_url_' . COOKIEHASH, esc_url( $comment->comment_author_url ), time() +$comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );574 setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); 575 setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); 576 setcookie( 'comment_author_url_' . COOKIEHASH, esc_url( $comment->comment_author_url ), $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); 565 577 } 566 578
Note: See TracChangeset
for help on using the changeset viewer.