ovizii
4/12/2014 - 10:03 PM

Character count for content/excerpt

Character count for content/excerpt

/* letter counter */ 
add_action( 'admin_head-post.php', 'letter_count_js')); 
add_action( 'admin_head-post-new.php', 'letter_count_js' )); 
public function letter_count_js(){ echo '<script>jQuery(document).ready(function(){ jQuery("#postexcerpt .handlediv").after("<input type=\'text\' value=\'0\' maxlength=\'3\' size=\'3\' id=\'excerpt_counter\' readonly=\'\' style=\'background:#fff; position:absolute;top:0.2em;right:2em; color:#666;\'>"); jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); jQuery("#excerpt").keyup( function() {jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); }); jQuery("#wp-word-count").after("<td id=\'wp-character-count\'>Character count: <span class=\'character-count\'>0</span></td>"); jQuery("#wp-character-count .character-count").html(jQuery("#wp-content-wrap .wp-editor-area").val().length); jQuery("#wp-content-wrap .wp-editor-area").keyup( function() {jQuery("#wp-character-count .character-count").html(jQuery("#wp-content-wrap .wp-editor-area").val().length); }); });</script>'; }