Code goal:
Replace the words in the WP comment cookie consent that must be checked before commenting when not logged in.
CODE THAT WORKED:
function customize\_comment\_form\_cookies\_consent\_label( $translated, $original, $domain ) {
$strings = array(
‘Save my name, email, and website in this browser for the next time I comment.’ => ‘Save my name & email in this browser for the next time I comment.’
);
if ( ! empty( $strings\[$original\] ) ) {
$translations = &get\_translations\_for\_domain( $domain );
$translated = $translations->translate( $strings\[$original\] );
}
return $translated;
}
add\_filter( ‘gettext’, ‘customize\_comment\_form\_cookies\_consent\_label’, 10, 3 );
ChatGPT’s code that DIDNT WORK:
function change\_comment\_cookies\_consent\_text( $translated\_text, $text, $domain )
{
if ( $text === ‘wp-comment-cookies-consent’ )
{
$translated\_text = \_\_( ‘New Label Text’, ‘your-text-domain’ );
}
return $translated\_text;
}
add\_filter( ‘gettext’, ‘change\_comment\_cookies\_consent\_text’, 20, 3 );
[ad_2]
Try formatting that wall of text so that someone looking to help you has an easy job.