- This topic has 10 replies, 4 voices, and was last updated 1 year, 6 months ago by Michael.
-
AuthorPosts
-
February 25, 2020 at 9:24 am #1176553Michael
Hi guys,
I disabled the blog website input field the other day and have just noticed that I should also update the associated label to remove the word “website”. Please can you tell me where I can find the comment cookies consent label text to change it? Thank you very much π
Michael.
https://www.dropbox.com/s/ld2yk39df4axg2z/comment-cookies-consent-label.jpg?dl=0
February 25, 2020 at 2:21 pm #1176782TomLead DeveloperLead DeveloperHi there,
This should do it:
add_filter( 'comment_form_default_fields', function( $fields ) { $commenter = wp_get_current_commenter(); $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; $fields['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 and email in this browser for the next time I comment.</label></p>'; return $fields; }, 20 );
February 25, 2020 at 3:34 pm #1176829MichaelTom, you’re the bomb. That works perfectly. Thank you very much π
February 25, 2020 at 3:55 pm #1176847TomLead DeveloperLead DeveloperYou’re very welcome π
September 27, 2021 at 10:32 am #1944738SimonHello Tom,
I wonder if the solution provided in your post #1176782 is translatable in other languages with a plug-in like WPML.
Thank you
September 27, 2021 at 12:03 pm #1944818YingStaffCustomer SupportHi Simon,
Not sure if it will compatible with the plugin, but you can have it a try, change this part:
Save my name and email in this browser for the next time I comment. to your language.September 27, 2021 at 12:18 pm #1944828SimonHi Ying,
Thank you for your reply.
I must be wrong but I’m asking the question because in the solution proposed by Tom I don’t see the syntax to make a text translatable.
I saw several times that to be translatable, a string must be written inside __() in your theme.
Best regardsSeptember 27, 2021 at 4:16 pm #1944928ElvinStaffCustomer SupportHi Simon,
Yeah that’s correct. having it inside __() w/ a textdomain allows it to be translatable.
Example:
add_filter( 'comment_form_default_fields', function( $fields ) { $commenter = wp_get_current_commenter(); $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; $fields['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 and email in this browser for the next time I comment.', 'generatepress' ) . '</label> </p>'; return $fields; }, 20 );
September 28, 2021 at 12:01 am #1945177SimonThank you, it is more clear for me now.
Best regards
September 28, 2021 at 12:19 am #1945193ElvinStaffCustomer SupportNice one. No problem. π
September 19, 2022 at 2:02 pm #2347885MichaelHey Tom,
Assuming the code you shared is still valid, where would I add in GeneratePress?
Thanks,
Mike -
AuthorPosts
- You must be logged in to reply to this topic.