Skip to content

Commit 38f67e2

Browse files
authored
Merge pull request #21 from Beee4life/remaining-characters
Remaining characters
2 parents 9b720d6 + 83e3df0 commit 38f67e2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ function my_acf_counter_filter($display) {
5757
return $display;
5858
}
5959
```
60-
In the example string above `%%len%%` represents where you want the current character count shown and `%%max%%`
61-
represents where you want the fields maximum length displayed. You can generate this string any way you want.
60+
In the example string above `%%len%%` represents where you want the current character count shown, `%%max%%`
61+
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.
6262
For example, you can translate it or use `sprintf()`, as long as it contains the two markers where the values
6363
should be shown. If you do not include these markers then they simply will not be shown. It's up to you to
6464
make sure they are present.

acf-input-counter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin Name: ACF Input Counter
55
Plugin URI: https://github.com/Hube2/acf-input-counter/
66
Description: Show character count for limited text and textarea fields
7-
Version: 1.4.1
7+
Version: 1.5
88
Author: John A. Huebner II
99
Author URI: https://github.com/Hube2/
1010
Text-domain: acf-counter
@@ -20,7 +20,7 @@
2020

2121
class acf_input_counter {
2222

23-
private $version = '1.4.1';
23+
private $version = '1.5';
2424

2525
public function __construct() {
2626
add_action('plugins_loaded', array($this, 'acf_counter_load_plugin_textdomain'));
@@ -71,7 +71,6 @@ public function scripts() {
7171
} // end public function scripts
7272

7373
public function render_field($field) {
74-
//echo '<pre>'; print_r($field); echo '</pre>';
7574
if (!$this->run() ||
7675
!$field['maxlength'] ||
7776
($field['type'] != 'text' && $field['type'] != 'textarea')) {
@@ -118,6 +117,7 @@ public function render_field($field) {
118117
$display = apply_filters('acf-input-counter/display', $display);
119118
$display = str_replace('%%len%%', '<span class="count">'.$len.'</span>', $display);
120119
$display = str_replace('%%max%%', $max, $display);
120+
$display = str_replace('%%remain%%', ( $max - $len ), $display);
121121
?>
122122
<span class="char-count">
123123
<?php

0 commit comments

Comments
 (0)