gdpr 隐私协议接受_如何在WordPress中添加GDPR评论隐私选择复选框

gdpr 隐私协议接受

Do you want to add a comment privacy optin checkbox in WordPress? European Union’s new GDPR law requires explicit consent for storing user’s personal information. If you have comments enabled on your website, then you need to add a comment privacy checkbox to comply with the new law. In this article, we will show you how to add a GDPR comment privacy opt-in checkbox in WordPress.

您是否要在WordPress中添加评论隐私选项复选框? 欧盟的新GDPR法律要求明确同意存储用户的个人信息。 如果您在网站上启用了评论,则需要添加评论隐私复选框以遵守新法律。 在本文中,我们将向您展示如何在WordPress中添加GDPR评论隐私选择加入复选框。

How to add comment privacy optin checkbox in WordPress
何时以及为何在WordPress中添加评论隐私优化复选框? (When and Why Add a Comment Privacy Optin Checkbox in WordPress?)

Recently, a new European Union law called GDPR (The General Data Protection Regulation) has become effective. The purpose of this law is to give EU citizens control over their personal data and change the data privacy approach of organizations across the world.

最近,一项称为GDPR(通用数据保护条例)的新欧盟法律已经生效。 该法律的目的是使欧盟公民能够控制其个人数据,并改变全球组织的数据隐私方法。

To learn more, see our ultimate guide to WordPress and GDPR compliance which answers all your questions in plain English.

要了解更多信息,请参阅我们的WordPress和GDPR合规性最终指南,该指南以通俗的英语回答您的所有问题。

WordPress recently addressed GDPR compliance in the latest 4.9.6 release. If you haven’t updated yet, then you need to immediately update to the latest WordPress version.

WordPress最近在最新的4.9.6版本中解决了GDPR合规性问题。 如果尚未更新,则需要立即更新到最新的WordPress版本

One of the ways WordPress stores and uses personal information is in the comment form. When a user leaves a comment on your website, their name, email address, and website information is stored in a browser cookie. This cookie allows WordPress to automatically fill in user’s information in the comment form on their next visit.

WordPress存储和使用个人信息的方式之一是在评论表单中。 当用户在您的网站上发表评论时,其名称,电子邮件地址和网站信息将存储在浏览器cookie中 。 此cookie使WordPress可以在下次访问时在评论表中自动填写用户的信息。

With WordPress 4.9.6, the default WordPress comment form will now show a comment privacy opt-in checkbox. All WordPress themes that use the default WordPress comment form will now automatically show this checkbox.

使用WordPress 4.9.6,默认的WordPress注释表单现在将显示“注释隐私选择加入”复选框。 现在,使用默认WordPress注释表单的所有WordPress主题将自动显示此复选框。

Comment privacy checkbox in default WordPress comment form

If your site is showing the comment privacy checkbox, then you don’t need to read further. However if the comment checkbox is not showing on your site, then you need to continue reading, and we will show you how to add comment privacy checkbox in WordPress.

如果您的网站显示“评论隐私”复选框,则无需进一步阅读。 但是,如果您的网站上未显示注释复选框,则您需要继续阅读,我们将向您展示如何在WordPress中添加注释隐私复选框。

在WordPress中添加评论隐私优化复选框 (Adding Comment Privacy Optin Checkbox in WordPress)

First, you need to make sure that you are using the latest version of WordPress and your theme. Simply go to Dashboard » Updates page to check for updates.

首先,您需要确保使用的是最新版本的WordPress和您的主题。 只需转到仪表板»更新页面以检查更新。

Check for WordPress and theme updates

If an update is available for your current theme or WordPress, then go ahead and install it. Next, check your website’s comment form to see if the update added the comment privacy checkbox.

如果您当前的主题或WordPress有可用的更新,请继续进行安装。 接下来,检查您网站的评论表单,以查看更新是否添加了评论隐私复选框。

If both your theme and WordPress are up to date, and you still can’t see the comment privacy checkbox, then this means that your WordPress theme is overriding the default WordPress comment form.

如果您的主题和WordPress都是最新的,但您仍然看不到评论隐私复选框,则意味着您的WordPress主题将覆盖默认的WordPress评论形式。

You can ask your theme author to fix this issue by opening a support ticket. You can also try to fix it yourself until your theme author releases an update.

您可以通过打开支持通知单要求主题作者解决此问题。 您也可以尝试自己修复它,直到主题作者发布更新为止。

There are two ways you can add the comment privacy checkbox to your WordPress theme. We will show you both methods, and you can try the one that works for you.

您可以通过两种方式将注释隐私复选框添加到WordPress主题。 我们将向您展示这两种方法,您可以尝试一种适合您的方法。

Both methods require you to add code to your WordPress theme files. If you haven’t done this before, then see our guide on how to copy and paste code in WordPress.

这两种方法都要求您将代码添加到WordPress主题文件中。 如果您以前没有做过,请参阅有关如何在WordPress中复制和粘贴代码的指南。

Method 1. Add comment privacy checkbox to your theme’s comment form

方法1.将注释隐私复选框添加到主题的注释表单

This method is recommended because it tries to protect your theme’s comment form style and layout.

推荐使用此方法,因为它会尝试保护主题的注释表单样式和布局。

First, you will need to find the code used to override the default WordPress comment form. Normally, you can find it in the comments.php or functions.php file in your theme folder.

首先,您需要找到用于覆盖默认WordPress注释表单的代码。 通常,您可以在主题文件夹中的comment.php或functions.php文件中找到它。

You will be looking for a code using the 'comment_form_default_fields' filter. This filter is used by themes to override the default WordPress comment form.

您将使用'comment_form_default_fields' 过滤器查找代码。 主题使用此过滤器来覆盖默认的WordPress评论表单。

It will have lines for all of your comment form fields in a specific format. Here is an example code to give you an idea of what you would be looking for:

它将以特定格式在所有评论表单字段中包含行。 这是一个示例代码,可让您大致了解所需的内容:


$comments_args = array(
	        // change the title of send button 
	        'label_submit'=> esc_html(__('Post Comments','themename')),
	        // change the title of the reply section
	        'title_reply'=> esc_html(__('Leave a Comment','themename')),
	        // redefine your own textarea (the comment body)
	        'comment_field' => ' 
	        <div class="form-group"><div class="input-field"><textarea class="materialize-textarea" type="text" rows="10" id="textarea1" name="comment" aria-required="true"></textarea></div></div>',

	        'fields' => apply_filters( 'comment_form_default_fields', array(
			    'author' =>'' .
			      '<div><div class="input-field">' .
			      '<input class="validate" id="name" name="author" placeholder="'. esc_attr(__('Name','themename')) .'" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
			      '" size="30"' . $aria_req . ' /></div></div>',

			    'email' =>'' .
			      '<div><div class="input-field">' .
			      '<input class="validate" id="email" name="email" placeholder="'. esc_attr(__('Email','themename')) .'" type="email" value="' . esc_attr(  $commenter['comment_author_email'] ) .
			      '" size="30"' . $aria_req . ' /></div></div>',

			    'url' =>'' .
			      '<div class="form-group">'.
			      '<div><div class="input-field"><input class="validate" placeholder="'. esc_attr(__('Website','themename')) .'" id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .
			      '" size="30" /></div></div>',
			    )
		    ),
	    );

	comment_form($comments_args); 	?> 


In this code, you can notice that comment_form_default_fields filter is used to modify the author, email, and URL fields. Inside the array, it uses the following format to display each field:

在此代码中,您会注意到comment_form_default_fields过滤器用于修改作者,电子邮件和URL字段。 在数组内部,它使用以下格式显示每个字段:


'fieldname' => 'HTML code to display the field', 
'anotherfield' => 'HTML code to display the field', 

We will add the comment privacy optin checkbox field towards the end. Here is what our code will look like now:

我们将在最后添加评论隐私选择复选框。 这是我们的代码现在的样子:


$comments_args = array(
	        // change the title of send button 
	        'label_submit'=> esc_html(__('Post Comments','themename')),
	        // change the title of the reply section
	        'title_reply'=> esc_html(__('Leave a Comment','themename')),
	        // redefine your own textarea (the comment body)
	        'comment_field' => ' 
	        <div class="form-group"><div class="input-field"><textarea class="materialize-textarea" type="text" rows="10" id="textarea1" name="comment" aria-required="true"></textarea></div></div>',

	        'fields' => apply_filters( 'comment_form_default_fields', array(
			    'author' =>'' .
			      '<div><div class="input-field">' .
			      '<input class="validate" id="name" name="author" placeholder="'. esc_attr(__('Name','themename')) .'" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
			      '" size="30"' . $aria_req . ' /></div></div>',

			    'email' =>'' .
			      '<div><div class="input-field">' .
			      '<input class="validate" id="email" name="email" placeholder="'. esc_attr(__('Email','themename')) .'" type="email" value="' . esc_attr(  $commenter['comment_author_email'] ) .
			      '" size="30"' . $aria_req . ' /></div></div>',

			    'url' =>'' .
			      '<div class="form-group">'.
			      '<div><div class="input-field"><input class="validate" placeholder="'. esc_attr(__('Website','themename')) .'" id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .
			      '" size="30" /></div></div>',

// Now we will add our new privacy checkbox optin

				'cookies' => '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
	                                         '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>',
			    )
		    ),
	    );

	comment_form($comments_args); 	?> 


Privacy checkbox in a custom WordPress comment form

Method 2. Replacing your theme’s comment form with WordPress default

方法2。用WordPress默认替换主题的评论表单

This method simply replaces your theme’s comment form with the default WordPress comment form. Using this method can affect your comment form’s appearance, and you may have to use custom CSS to style your comment form.

此方法仅用默认的WordPress注释表单替换主题的注释表单。 使用此方法可能会影响注释表单的外观,并且您可能必须使用自定义CSS来设置注释表单的样式

Edit your theme’s comments.php file and look for the line with the comment_form() function. Your theme will have a defined arguments, function, or a template inside it to load your theme’s custom comment form. Your comment_form line will look something like this:

编辑主题的comment.php文件,并使用comment_form()函数查找该行。 您的主题中将具有定义的参数,函数或模板,以加载​​主题的自定义注释表单。 您的comment_form行将如下所示:


<?php comment_form( custom_comment_form_function() ); ?>

You will need to replace it with the following line:

您需要将其替换为以下行:


<?php comment_form(); ?>

Don’t forget to save your changes and visit your website. You will now see the default WordPress comment form with the comment privacy optin checkbox.

不要忘记保存您的更改并访问您的网站。 您现在将看到带有评论隐私选项复选框的默认WordPress评论表单。

Default WordPress comment form

We hope this article helped you learn how to add the GDPR comment privacy optin checkbox in WordPress. You may also want to see our tips on getting more comments on your WordPress blog posts.

我们希望本文能帮助您学习如何在WordPress中添加GDPR评论隐私选择复选框。 您可能还想查看有关在WordPress博客文章获得更多评论的提示。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-themes/how-to-add-a-gdpr-comment-privacy-opt-in-checkbox-in-wordpress/

gdpr 隐私协议接受

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值