[Resolved] Comment Cookies Consent Label

Home Forums Support [Resolved] Comment Cookies Consent Label

Home Forums Support Comment Cookies Consent Label

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1176553
    Michael

    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

    #1176782
    Tom
    Lead Developer
    Lead Developer

    Hi 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 );
    #1176829
    Michael

    Tom, you’re the bomb. That works perfectly. Thank you very much πŸ™‚

    #1176847
    Tom
    Lead Developer
    Lead Developer

    You’re very welcome πŸ™‚

    #1944738
    Simon

    Hello Tom,

    I wonder if the solution provided in your post #1176782 is translatable in other languages with a plug-in like WPML.

    Thank you

    #1944818
    Ying
    Staff
    Customer Support

    Hi 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.

    #1944828
    Simon

    Hi 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 regards

    #1944928
    Elvin
    Staff
    Customer Support

    Hi 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 );
    #1945177
    Simon

    Thank you, it is more clear for me now.

    Best regards

    #1945193
    Elvin
    Staff
    Customer Support

    Nice one. No problem. πŸ™‚

    #2347885
    Michael

    Hey Tom,

    Assuming the code you shared is still valid, where would I add in GeneratePress?

    Thanks,
    Mike

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.