WP Manifestindependent plugin directory
manifest / content / acf-input-counter

ACF Input Counter WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

Adds a counter to all text and textarea fields with character limits

★ 72stars
1.5.1latest · 4 years ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/hube2/acf-input-counter/archive/refs/heads/master.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Supports ACF 5

Adds a counter to all text and textarea fields with character limits.

This is a simple plugin that will add a counter below all ACF text and text area fields to show how many characters have been added and what the limit is. The display will look something like this:

chars: 25 of 55

This plugin will not work in ACF 4 for 2 reasons:

  • The acf/render_field hook is not supported by ACF 4
  • The JavaScript used in this plugin is specific to ACF 5

This plugin also serves as a simple example of how to extend the functionality of fields in ACF 5.

Add Counter Filter

By defaults, the counter is added to all text and textarea fields that have a max length. If you would like to only add the counter on specific fields you can filter them by either the ACF Wrapper Class or the ACF Wrapper ID of the field. You can allow multiple classes or ids. If classes or ID values are present then only fields that have one of the classes or ids will include a counter.

Filter by Class

add_filter('acf-input-counter/classes', 'my_input_counter_filter');
function my_input_counter_filter($classes=array()) {
  // add 1 or more classes to the array
    $classes[] = 'this-is-a-class';
    return $classes;
}

Fields that have one of the classes or ids will include a counter.

Filter by ID

add_filter('acf-input-counter/ids', 'my_input_counter_filter');
function my_input_counter_filter($ids=array()) {
  // add 1 or more classes to the array
    $ids[] = 'this-is-an-ID';
    return $ids;
}

Filter the Display

To filter the display add a filter wherever you would add a filter.

add_filter('acf-input-counter/display', 'my_acf_counter_filter');
function my_acf_counter_filter($display) {
    $display = sprintf(
        __('Characters = %1$s of %2$s', 'acf-counter'),
        '%%len%%',
        '%%max%%'
    );
    return $display;
}

In the example string above %%len%% represents where you want the current character count shown, %%max%% represents where you want the fields maximum length displayed and %%remain%% represents where you want the remaining character length displayed. You can generate this string any way you want. For example, you can translate it or use sprintf(), as long as it contains the two markers where the values should be shown. If you do not include these markers then they simply will not be shown. It's up to you to make sure they are present.

I've puzzled with how to allow this to be altered and this is the best I've been able to come up with. If you have a better idea, let me know in the issues.

Automatic Updates

Install GitHub Updater on your site if you want to recieve automatic updates for this plugin.

Remove Nag

You may notice that I've started adding a little nag to my plugins. It's just a box on some pages that lists my plugins that you're using with a request do consider making a donation for using them. If you want to disable them add the following filter to your functions.php file.

add_filter('remove_hube2_nag', '__return_true');

i18n

The plugin is now also internationalized and it has a .pot file. Also included is a Dutch translation by Beee.

Releases

11 releases.

Tag
Published
1.5.1 latest
Jun 5, 2022 4 years ago
Apr 29, 2017 9 years ago
Dec 29, 2016 9 years ago
Oct 9, 2016 10 years ago
Oct 9, 2016 10 years ago
Oct 8, 2016 10 years ago
Oct 8, 2016 10 years ago
Oct 8, 2016 10 years ago
Sep 27, 2016 10 years ago
Sep 26, 2016 10 years ago
Sep 26, 2016 10 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.

A grade

Security

ACF Input Counter 1.5.1 · audited by WP Registry

No security issues found.

Audited release
1.5.1
Findings
none
Worst severity
—
Content hash
03b822bbf2daeae316e7b1d9…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.