Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_set_comment_cookies ›

Seit3.4.0
Veraltetn/v
wp_set_comment_cookies ( $comment, $user )
Parameter: (2)
  • (WP_Comment) $comment Comment object.
    Erforderlich: Ja
  • (object) $user Comment author's object.
    Erforderlich: Ja
Definiert in:
Codex:

Sets the cookies used to store an unauthenticated commentator's identity. Typically used to recall previous comments by this commentator that are still held in moderation.



Quellcode

function wp_set_comment_cookies($comment, $user) {
	if ( $user->exists() )
		return;

	/**
	 * Filters the lifetime of the comment cookie in seconds.
	 *
	 * @since 2.8.0
	 *
	 * @param int $seconds Comment cookie lifetime. Default 30000000.
	 */
	$comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
	$secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
	setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
	setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
	setcookie( 'comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
}