AdvancedCustomFields/acf

word and Character counter for ACF WYSIWYG Field

Closed this issue · 1 comments

I use This code found in GT Hub. Can someone give me a lead how to extent the events for counting At clicking on the field?

`function my_acf_input_admin_footer() {

?>

<script type="text/javascript"> (function($) { acf.add_action('wysiwyg_tinymce_init', function( ed, id, mceInit, $field ){ $('#wp-'+id+'-editor-container .mce-statusbar').append('
'); counter = function() { var value = $('#'+id).val(); if (value.length == 0) { $('#wp-'+id+'-editor-container .mce-statusbar .acfcounter .words').html('Word Count: 0'); $('#wp-'+id+'-editor-container .mce-statusbar .acfcounter .chars').html('Characters: 0'); return; } var regex = /\s+/gi; var wordCount = value.trim().replace(regex, ' ').split(' ').length; var totalChars = value.length; $('#wp-'+id+'-editor-container .mce-statusbar .acfcounter .words').html('Word Count: '+wordCount); $('#wp-'+id+'-editor-container .mce-statusbar .acfcounter .chars').html('Characters: '+totalChars); }; $('#wp-'+id+'-editor-container .mce-statusbar .acfcounter .words').html('Word Count: 0'); $('#wp-'+id+'-editor-container .mce-statusbar .acfcounter .chars').html('Characters: 0'); $('#'+id).change(counter); $('#'+id).keydown(counter); $('#'+id).keypress(counter); $('#'+id).keyup(counter); $('#'+id).blur(counter); $('#'+id).focus(counter); }); })(jQuery); </script>

Hey @JohnGiddi,

Please post this over at our community support forum, https://support.advancedcustomfields.com

We use GitHub issues only for technical bug reports. Thanks!