How remove caps-lock from WordPress comments (retroactively)

There are people, sometimes whole departments of companies, who from the day they buy a keyboard to when they throw it away keep the caps-lock on. I don’t understand them and for this reason i made a plugin to convert everything they write to the correct case.

It may come in handy if you have a blog and some people leave you comments in caps lock, this way you can make comments written in capital letters lower case. Or if you’ve inherited a cooking blog written in all caps and want to do something about readability

HOW IT WORKS

After installation, the plugin automatically displays normalised texts. So the title, post content, widget titles and comments will be filtered and normalised by default.

You can customize/add/remove filters adding to functions.php the name of the hook and the number of allowed consecutive uppercase characters.


this is the method to create your own set of hook+rule

add_action( 'init', function() {
    add_filter( 'rcl_hook_filters', function () { return array(
        array( 'hook' => 'the_title', 'allowed_chars' => 6 ), // title
        array( 'hook' => 'comment_text', 'allowed_chars' => 5 ), // comments
        array( 'hook' => 'widget_title', 'allowed_chars' => 6 ), // widget
        );
    } );
} );

But what if I want to apply it only to comments?

add_filter( 'rcl_the_content', function () { return -1; } ); // disabled
add_action( 'init', function() {
    add_filter( 'rcl_hook_filters', function () { return array(
        array( 'hook' => 'comment_text', 'allowed_chars' => 5 ), // 2 or more uppercase digits triggers the text normalization
        );
    } );
} );

that’s it, anyhow I hope your comments to this post are lowercased 😛

Post navigation

You might be interested in...

No comments yet, be the first!

Comments

Your email address will not be published.