diff --git a/README.md b/README.md index 589ef3f..2988fea 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,30 @@ This plugin will not work in ACF 4 for 2 reasons: * 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; +} +```